Error executing template "Designs/Rapido/Extranet/SP_Login.cshtml"
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
   at System.ThrowHelper.ThrowKeyNotFoundException()
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at Smartpage.FruHansensKaelder.MenuPDF.Observers.OnGlobalTags.OnNotify(String notification, NotificationArgs args) in D:\a\1\s\FruHansensKaelder\Smartpage.FruHansensKaelder.MenuPDF\Observers\OnGlobalTags.cs:line 55
   at Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs)
   at Dynamicweb.Frontend.PageView.GetGlobalTemplateTags()
   at Dynamicweb.Rendering.RazorTemplateBase`1.GetGlobalValue(String name)
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<RenderLoginForm>b__2_0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 59
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass46_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1947
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass45_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1857
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass46_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1980
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass45_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1885
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass46_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1980
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.<>c__DisplayClass45_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1874
   at CompiledRazorTemplates.Dynamic.RazorEngine_00572335bfb14ab299ca7f44d76f531a.Execute() in D:\Dynamicweb.net\Solutions\FruHansensKaelder.cloud.dynamicweb-cms.com\files\Templates\Designs\Rapido\Extranet\SP_Login.cshtml:line 1988
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using System.Web; 3 @using System.IO; 4 5 @functions { 6 BlocksPage loginPage = BlocksPage.GetBlockPage("Login"); 7 } 8 9 @{ 10 Block loginForm = new Block 11 { 12 Id = "LoginContainer", 13 SortId = 10, 14 Design = new Design 15 { 16 RenderType = RenderType.Row, 17 CssClass = "grid--justify-center" 18 }, 19 BlocksList = new List<Block> { 20 new Block { 21 Id = "LoginFormPlaceholder", 22 SortId = 10, 23 Design = new Design { 24 RenderType = RenderType.Column, 25 Size = "6", 26 CssClass = "grid__col--bleed paragraph-container u-middle" 27 } 28 } 29 } 30 }; 31 32 loginPage.Add(loginForm); 33 } 34 35 @* Include the Rendering helpers *@ 36 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 37 @using System.Web; 38 @using Dynamicweb.Rapido.Blocks 39 @using Dynamicweb.Rapido.Blocks.Components.General 40 @using Dynamicweb.Rapido.Blocks.Components 41 42 @functions { 43 BlocksPage loginFormPage = BlocksPage.GetBlockPage("Login"); 44 } 45 46 @{ 47 Block loginContainer = new Block 48 { 49 Id = "LoginForm", 50 Template = RenderLoginForm(), 51 SortId = 10 52 }; 53 loginFormPage.Add("LoginFormPlaceholder", loginContainer); 54 } 55 56 57 @helper RenderLoginForm() 58 { 59 string pageId = GetGlobalValue("Global:Page.ID"); 60 int signInProfilePageId = GetPageIdByNavigationTag("SignInPage"); 61 string specialRedirectPage = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("RedirectPageId")) ? "/Default.aspx?ID=" + HttpContext.Current.Request.QueryString.Get("RedirectPageId") : ""; 62 string redirectPage = !string.IsNullOrEmpty(GetString("UserManagement:User.Login.SuccessRedirectToPage")) ? GetString("UserManagement:User.Login.SuccessRedirectToPage") : specialRedirectPage; 63 string currentUserId = GetGlobalValue("Global:Extranet.UserID"); 64 if (!string.IsNullOrEmpty(redirectPage) && !string.IsNullOrEmpty(currentUserId) && currentUserId != "0") 65 { 66 <script> 67 location.href = "@redirectPage"; 68 </script> 69 } 70 71 Form form = new Form { Method = FormMethod.Post }; 72 73 @Render(new Heading { Title = Translate("Sign in"), Level = 2 }) 74 75 if (!string.IsNullOrEmpty(GetString("DW_extranet_error_dk"))) 76 { 77 @Render(new NotificationMessage 78 { 79 MessageType = NotificationMessageType.Error, 80 Message = GetString("DW_extranet_error_dk") 81 }); 82 } 83 84 form.Add(new HiddenField { Name = "ID", Value = pageId }); 85 form.Add(new HiddenField { Name = "DWExtranetUsernameRemember", Value = "True" }); 86 form.Add(new HiddenField { Name = "DWExtranetPasswordRemember", Value = "True" }); 87 form.Add(new HiddenField { Name = "LoginAction", Value = "Login" }); 88 form.Add(new TextField { Id = "login-username", Type = TextFieldType.Text, Name = "username", Label = Translate("Username"), Required = true }); 89 form.Add(new TextField { Id = "login-password", Type = TextFieldType.Password, Name = "password", Label = Translate("Password"), Required = true }); 90 form.Add(new CheckboxField { Id = "rememberMe", Value = "True", Name = "Autologin", Label = Translate("Remember me") }); 91 form.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Sign in") }); 92 93 foreach (LoopItem LoginProvider in GetLoop("DWExtranetExternalLoginProviders")) 94 { 95 var ProviderName = LoginProvider.GetString("ProviderName").ToLower(); 96 97 form.Add(new Link 98 { 99 Href = "/Admin/Public/Social/ExternalLogin.aspx?action=login&providerID=" + LoginProvider.GetValue("ProviderID"), 100 ButtonLayout = ButtonLayout.Clean, 101 Icon = new Icon() 102 { 103 Prefix = "fab", 104 Name = "fa-" + ProviderName, 105 CssClass = "fa-1_5x", 106 LabelPosition = IconLabelPosition.After 107 }, 108 CssClass = "btn--condensed u-no-margin u-color-" + ProviderName 109 }); 110 } 111 112 form.Add(new Link 113 { 114 Href = "/Default.aspx?id=" + signInProfilePageId + "&LoginAction=Recovery", 115 ButtonLayout = ButtonLayout.None, 116 Title = Translate("Forgot your password?"), 117 CssClass = "u-padding-top u-no-margin u-pull--right" 118 }); 119 120 @Render(form) 121 } 122 123 124 125 @using Dynamicweb.Rapido.Blocks.Components 126 @using Dynamicweb.Rapido.Blocks.Components.General 127 @using Dynamicweb.Rapido.Blocks 128 @using System.IO 129 130 @* Required *@ 131 @using Dynamicweb.Rapido.Blocks.Components 132 @using Dynamicweb.Rapido.Blocks.Components.General 133 @using Dynamicweb.Rapido.Blocks 134 135 136 @helper Render(ComponentBase component) 137 { 138 if (component != null) 139 { 140 @component.Render(this) 141 } 142 } 143 144 145 @* Components *@ 146 @using System.Reflection 147 @using Dynamicweb.Rapido.Blocks.Components.General 148 149 150 @* Component *@ 151 152 @helper RenderIcon(Icon settings) 153 { 154 if (settings != null) 155 { 156 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 157 158 if (settings.Name != null) 159 { 160 if (string.IsNullOrEmpty(settings.Label)) 161 { 162 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 163 } 164 else 165 { 166 if (settings.LabelPosition == IconLabelPosition.Before) 167 { 168 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 169 } 170 else 171 { 172 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 173 } 174 } 175 } 176 else if (!string.IsNullOrEmpty(settings.Label)) 177 { 178 @settings.Label 179 } 180 } 181 } 182 @using System.Reflection 183 @using Dynamicweb.Rapido.Blocks.Components.General 184 @using Dynamicweb.Rapido.Blocks.Components 185 @using Dynamicweb.Core 186 187 @* Component *@ 188 189 @helper RenderButton(Button settings) 190 { 191 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 192 { 193 Dictionary<string, string> attributes = new Dictionary<string, string>(); 194 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 195 if (settings.Disabled) { 196 attributes.Add("disabled", "true"); 197 classList.Add("disabled"); 198 } 199 200 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 201 { 202 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 203 @RenderConfirmDialog(settings); 204 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 205 } 206 207 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 208 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 209 if (!string.IsNullOrEmpty(settings.AltText)) 210 { 211 attributes.Add("title", settings.AltText); 212 } 213 else if (!string.IsNullOrEmpty(settings.Title)) 214 { 215 attributes.Add("title", settings.Title); 216 } 217 218 var onClickEvents = new List<string>(); 219 if (!string.IsNullOrEmpty(settings.OnClick)) 220 { 221 onClickEvents.Add(settings.OnClick); 222 } 223 if (!string.IsNullOrEmpty(settings.Href)) 224 { 225 onClickEvents.Add("location.href='" + settings.Href + "'"); 226 } 227 if (onClickEvents.Count > 0) 228 { 229 attributes.Add("onClick", string.Join(";", onClickEvents)); 230 } 231 232 if (settings.ButtonLayout != ButtonLayout.None) 233 { 234 classList.Add("btn"); 235 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 236 if (btnLayout == "linkclean") 237 { 238 btnLayout = "link-clean"; //fix 239 } 240 classList.Add("btn--" + btnLayout); 241 } 242 243 if (settings.Icon == null) 244 { 245 settings.Icon = new Icon(); 246 } 247 settings.Icon.Label = settings.Title; 248 249 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 250 251 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 252 } 253 } 254 255 @helper RenderConfirmDialog(Button settings) 256 { 257 Modal confirmDialog = new Modal { 258 Id = settings.Id, 259 Width = ModalWidth.Sm, 260 Heading = new Heading 261 { 262 Level = 2, 263 Title = settings.ConfirmTitle 264 }, 265 BodyText = settings.ConfirmText 266 }; 267 268 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 269 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 270 271 @Render(confirmDialog) 272 } 273 @using Dynamicweb.Rapido.Blocks.Components.General 274 @using Dynamicweb.Rapido.Blocks.Components 275 @using Dynamicweb.Core 276 277 @helper RenderDashboard(Dashboard settings) 278 { 279 var widgets = settings.GetWidgets(); 280 281 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 282 { 283 //set bg color for them 284 285 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 286 int r = Convert.ToInt16(color.R); 287 int g = Convert.ToInt16(color.G); 288 int b = Convert.ToInt16(color.B); 289 290 var count = widgets.Length; 291 var max = Math.Max(r, Math.Max(g, b)); 292 double step = 255.0 / (max * count); 293 var i = 0; 294 foreach (var widget in widgets) 295 { 296 i++; 297 298 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 299 widget.BackgroundColor = shade; 300 } 301 } 302 303 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 304 @foreach (var widget in widgets) 305 { 306 <div class="dashboard__widget"> 307 @Render(widget) 308 </div> 309 } 310 </div> 311 } 312 @using Dynamicweb.Rapido.Blocks.Components.General 313 @using Dynamicweb.Rapido.Blocks.Components 314 315 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 316 { 317 if (!string.IsNullOrEmpty(settings.Link)) 318 { 319 var backgroundStyles = ""; 320 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 321 { 322 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 323 } 324 325 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 326 <div class="u-center-middle u-color-light"> 327 @if (settings.Icon != null) 328 { 329 settings.Icon.CssClass += "widget__icon"; 330 @Render(settings.Icon) 331 } 332 <div class="widget__title">@settings.Title</div> 333 </div> 334 </a> 335 } 336 } 337 @using Dynamicweb.Rapido.Blocks.Components.General 338 @using Dynamicweb.Rapido.Blocks.Components 339 340 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 341 { 342 var backgroundStyles = ""; 343 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 344 { 345 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 346 } 347 348 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 349 <div class="u-center-middle u-color-light"> 350 @if (settings.Icon != null) 351 { 352 settings.Icon.CssClass += "widget__icon"; 353 @Render(settings.Icon) 354 } 355 <div class="widget__counter">@settings.Count</div> 356 <div class="widget__title">@settings.Title</div> 357 </div> 358 </div> 359 } 360 @using System.Reflection 361 @using Dynamicweb.Rapido.Blocks.Components.General 362 @using Dynamicweb.Rapido.Blocks.Components 363 @using Dynamicweb.Core 364 365 @* Component *@ 366 367 @helper RenderLink(Link settings) 368 { 369 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 370 { 371 Dictionary<string, string> attributes = new Dictionary<string, string>(); 372 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 373 if (settings.Disabled) 374 { 375 attributes.Add("disabled", "true"); 376 classList.Add("disabled"); 377 } 378 379 if (!string.IsNullOrEmpty(settings.AltText)) 380 { 381 attributes.Add("title", settings.AltText); 382 } 383 else if (!string.IsNullOrEmpty(settings.Title)) 384 { 385 attributes.Add("title", settings.Title); 386 } 387 388 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 389 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 390 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 391 attributes.Add("href", settings.Href); 392 393 if (settings.ButtonLayout != ButtonLayout.None) 394 { 395 classList.Add("btn"); 396 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 397 if (btnLayout == "linkclean") 398 { 399 btnLayout = "link-clean"; //fix 400 } 401 classList.Add("btn--" + btnLayout); 402 } 403 404 if (settings.Icon == null) 405 { 406 settings.Icon = new Icon(); 407 } 408 settings.Icon.Label = settings.Title; 409 410 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 411 { 412 settings.Rel = LinkRelType.Noopener; 413 } 414 if (settings.Target != LinkTargetType.None) 415 { 416 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 417 } 418 if (settings.Download) 419 { 420 attributes.Add("download", "true"); 421 } 422 if (settings.Rel != LinkRelType.None) 423 { 424 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 425 } 426 427 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 428 } 429 } 430 @using System.Reflection 431 @using Dynamicweb.Rapido.Blocks.Components 432 @using Dynamicweb.Rapido.Blocks.Components.General 433 @using Dynamicweb.Rapido.Blocks 434 435 436 @* Component *@ 437 438 @helper RenderRating(Rating settings) 439 { 440 if (settings.Score > 0) 441 { 442 int rating = settings.Score; 443 string iconType = "fa-star"; 444 445 switch (settings.Type.ToString()) { 446 case "Stars": 447 iconType = "fa-star"; 448 break; 449 case "Hearts": 450 iconType = "fa-heart"; 451 break; 452 case "Lemons": 453 iconType = "fa-lemon"; 454 break; 455 case "Bombs": 456 iconType = "fa-bomb"; 457 break; 458 } 459 460 <div class="u-ta-right"> 461 @for (int i = 0; i < settings.OutOf; i++) 462 { 463 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 464 } 465 </div> 466 } 467 } 468 @using System.Reflection 469 @using Dynamicweb.Rapido.Blocks.Components.General 470 @using Dynamicweb.Rapido.Blocks.Components 471 472 473 @* Component *@ 474 475 @helper RenderSelectFieldOption(SelectFieldOption settings) 476 { 477 Dictionary<string, string> attributes = new Dictionary<string, string>(); 478 if (settings.Checked) { attributes.Add("selected", "true"); } 479 if (settings.Disabled) { attributes.Add("disabled", "true"); } 480 if (settings.Value != null) { attributes.Add("value", settings.Value); } 481 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 482 483 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 484 } 485 @using System.Reflection 486 @using Dynamicweb.Rapido.Blocks.Components.General 487 @using Dynamicweb.Rapido.Blocks.Components 488 489 490 @* Component *@ 491 492 @helper RenderNavigation(Navigation settings) { 493 @RenderNavigation(new 494 { 495 id = settings.Id, 496 cssclass = settings.CssClass, 497 startLevel = settings.StartLevel, 498 endlevel = settings.EndLevel, 499 expandmode = settings.Expandmode, 500 sitemapmode = settings.SitemapMode, 501 template = settings.Template 502 }) 503 } 504 @using Dynamicweb.Rapido.Blocks.Components.General 505 @using Dynamicweb.Rapido.Blocks.Components 506 507 508 @* Component *@ 509 510 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 511 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 512 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 513 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 514 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 515 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 516 settings.SitemapMode = false; 517 518 @RenderNavigation(settings) 519 } 520 @using Dynamicweb.Rapido.Blocks.Components.General 521 @using Dynamicweb.Rapido.Blocks.Components 522 523 524 @* Component *@ 525 526 @helper RenderLeftNavigation(LeftNavigation settings) { 527 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 528 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 529 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 530 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 531 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 532 533 <div class="grid__cell"> 534 @RenderNavigation(settings) 535 </div> 536 } 537 @using System.Reflection 538 @using Dynamicweb.Rapido.Blocks.Components.General 539 @using Dynamicweb.Core 540 541 @* Component *@ 542 543 @helper RenderHeading(Heading settings) 544 { 545 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 546 { 547 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 548 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 549 550 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 551 if (!string.IsNullOrEmpty(settings.Link)) 552 { 553 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 554 } 555 else 556 { 557 if (settings.Icon == null) 558 { 559 settings.Icon = new Icon(); 560 } 561 settings.Icon.Label = settings.Title; 562 @Render(settings.Icon) 563 } 564 @("</" + tagName + ">"); 565 } 566 } 567 @using Dynamicweb.Rapido.Blocks.Components 568 @using Dynamicweb.Rapido.Blocks.Components.General 569 @using Dynamicweb.Rapido.Blocks 570 571 572 @* Component *@ 573 574 @helper RenderImage(Image settings) 575 { 576 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 577 { 578 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 579 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 580 581 if (settings.Caption != null) 582 { 583 @:<div> 584 } 585 586 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 587 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 588 589 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 590 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 591 @if (settings.Link != null) 592 { 593 <a href="@settings.Link"> 594 @RenderTheImage(settings) 595 </a> 596 } 597 else 598 { 599 @RenderTheImage(settings) 600 } 601 </div> 602 </div> 603 604 if (settings.Caption != null) 605 { 606 <span class="image-caption dw-mod">@settings.Caption</span> 607 @:</div> 608 } 609 } 610 else 611 { 612 if (settings.Caption != null) 613 { 614 @:<div> 615 } 616 if (!string.IsNullOrEmpty(settings.Link)) 617 { 618 <a href="@settings.Link"> 619 @RenderTheImage(settings) 620 </a> 621 } 622 else 623 { 624 @RenderTheImage(settings) 625 } 626 627 if (settings.Caption != null) 628 { 629 <span class="image-caption dw-mod">@settings.Caption</span> 630 @:</div> 631 } 632 } 633 } 634 635 @helper RenderTheImage(Image settings) 636 { 637 if (settings != null) 638 { 639 string placeholderImage = "/Files/Images/placeholder.gif"; 640 string imageEngine = "/Admin/Public/GetImage.ashx?"; 641 642 string imageStyle = ""; 643 644 switch (settings.Style) 645 { 646 case ImageStyle.Ball: 647 imageStyle = "grid__cell-img--ball"; 648 break; 649 } 650 651 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 652 { 653 if (settings.ImageDefault != null) 654 { 655 settings.ImageDefault.Height = settings.ImageDefault.Width; 656 } 657 if (settings.ImageMedium != null) 658 { 659 settings.ImageMedium.Height = settings.ImageMedium.Width; 660 } 661 if (settings.ImageSmall != null) 662 { 663 settings.ImageSmall.Height = settings.ImageSmall.Width; 664 } 665 } 666 667 string defaultImage = imageEngine; 668 string imageSmall = ""; 669 string imageMedium = ""; 670 671 if (settings.DisableImageEngine) 672 { 673 defaultImage = settings.Path; 674 } 675 else 676 { 677 if (settings.ImageDefault != null) 678 { 679 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 680 681 if (settings.Path.GetType() != typeof(string)) 682 { 683 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 684 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 685 } 686 else 687 { 688 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 689 } 690 } 691 692 if (settings.ImageSmall != null) 693 { 694 imageSmall = "data-src-small=\"" + imageEngine; 695 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 696 697 if (settings.Path.GetType() != typeof(string)) 698 { 699 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 700 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 701 } 702 else 703 { 704 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 705 } 706 707 imageSmall += "\""; 708 } 709 710 if (settings.ImageMedium != null) 711 { 712 imageMedium = "data-src-medium=\"" + imageEngine; 713 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 714 715 if (settings.Path.GetType() != typeof(string)) 716 { 717 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 718 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 719 } 720 else 721 { 722 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 723 } 724 725 imageMedium += "\""; 726 } 727 } 728 729 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 730 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 731 if (!string.IsNullOrEmpty(settings.Title)) 732 { 733 optionalAttributes.Add("alt", settings.Title); 734 optionalAttributes.Add("title", settings.Title); 735 } 736 737 if (settings.DisableLazyLoad) 738 { 739 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 740 } 741 else 742 { 743 <img id="@settings.Id" class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 744 } 745 } 746 } 747 @using System.Reflection 748 @using Dynamicweb.Rapido.Blocks.Components.General 749 @using Dynamicweb.Rapido.Blocks.Components 750 751 @* Component *@ 752 753 @helper RenderFileField(FileField settings) 754 { 755 var attributes = new Dictionary<string, string>(); 756 if (string.IsNullOrEmpty(settings.Id)) 757 { 758 settings.Id = Guid.NewGuid().ToString("N"); 759 } 760 761 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 762 if (settings.Disabled) { attributes.Add("disabled", "true"); } 763 if (settings.Required) { attributes.Add("required", "true"); } 764 if (settings.Multiple) { attributes.Add("multiple", "true"); } 765 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 766 if (string.IsNullOrEmpty(settings.ChooseFileText)) 767 { 768 settings.ChooseFileText = Translate("Choose file"); 769 } 770 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 771 { 772 settings.NoFilesChosenText = Translate("No files chosen..."); 773 } 774 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 775 776 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 777 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 778 779 attributes.Add("type", "file"); 780 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 781 settings.CssClass = "u-full-width " + settings.CssClass; 782 783 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 784 785 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 786 @if (!string.IsNullOrEmpty(settings.Label)) 787 { 788 <label for="@settings.Id">@settings.Label</label> 789 } 790 @if (!string.IsNullOrEmpty(settings.HelpText)) 791 { 792 <small class="form__help-text">@settings.HelpText</small> 793 } 794 795 <div class="form__field-combi file-input u-no-margin dw-mod"> 796 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 797 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 798 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 799 @if (settings.UploadButton != null) 800 { 801 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 802 @Render(settings.UploadButton) 803 } 804 </div> 805 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 806 </div> 807 } 808 @using System.Reflection 809 @using Dynamicweb.Rapido.Blocks.Components.General 810 @using Dynamicweb.Rapido.Blocks.Components 811 @using Dynamicweb.Core 812 @using System.Linq 813 814 @* Component *@ 815 816 @helper RenderDateTimeField(DateTimeField settings) 817 { 818 if (string.IsNullOrEmpty(settings.Id)) 819 { 820 settings.Id = Guid.NewGuid().ToString("N"); 821 } 822 823 var textField = new TextField { 824 Name = settings.Name, 825 Id = settings.Id, 826 Label = settings.Label, 827 HelpText = settings.HelpText, 828 Value = settings.Value, 829 Disabled = settings.Disabled, 830 Required = settings.Required, 831 ErrorMessage = settings.ErrorMessage, 832 CssClass = settings.CssClass, 833 WrapperCssClass = settings.WrapperCssClass, 834 OnChange = settings.OnChange, 835 OnClick = settings.OnClick, 836 ExtraAttributes = settings.ExtraAttributes, 837 // 838 Placeholder = settings.Placeholder 839 }; 840 841 @Render(textField) 842 843 List<string> jsAttributes = new List<string>(); 844 845 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 846 847 if (!string.IsNullOrEmpty(settings.DateFormat)) 848 { 849 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 850 } 851 if (!string.IsNullOrEmpty(settings.MinDate)) 852 { 853 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 854 } 855 if (!string.IsNullOrEmpty(settings.MaxDate)) 856 { 857 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 858 } 859 if (settings.IsInline) 860 { 861 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 862 } 863 if (settings.EnableTime) 864 { 865 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 866 } 867 if (settings.EnableWeekNumbers) 868 { 869 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 870 } 871 872 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 873 874 <script> 875 document.addEventListener("DOMContentLoaded", function () { 876 flatpickr("#@textField.Id", { 877 @string.Join(",", jsAttributes) 878 }); 879 }); 880 </script> 881 } 882 @using System.Reflection 883 @using Dynamicweb.Rapido.Blocks.Components.General 884 @using Dynamicweb.Rapido.Blocks.Components 885 886 @* Component *@ 887 888 @helper RenderTextField(TextField settings) 889 { 890 var attributes = new Dictionary<string, string>(); 891 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 892 { 893 settings.Id = Guid.NewGuid().ToString("N"); 894 } 895 896 /*base settings*/ 897 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 898 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 899 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 900 if (settings.Disabled) { attributes.Add("disabled", "true"); } 901 if (settings.Required) { attributes.Add("required", "true"); } 902 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 903 /*end*/ 904 905 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 906 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 907 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 908 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 909 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 910 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 911 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 912 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 913 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 914 settings.CssClass = "u-full-width " + settings.CssClass; 915 916 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 917 918 string noMargin = "u-no-margin"; 919 if (!settings.ReadOnly) { 920 noMargin = ""; 921 } 922 923 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 924 @if (!string.IsNullOrEmpty(settings.Label)) 925 { 926 <label for="@settings.Id">@settings.Label</label> 927 } 928 @if (!string.IsNullOrEmpty(settings.HelpText)) 929 { 930 <small class="form__help-text">@settings.HelpText</small> 931 } 932 933 @if (settings.ActionButton != null) 934 { 935 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 936 <div class="form__field-combi u-no-margin dw-mod"> 937 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 938 @Render(settings.ActionButton) 939 </div> 940 } 941 else 942 { 943 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 944 } 945 946 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 947 </div> 948 } 949 @using System.Reflection 950 @using Dynamicweb.Rapido.Blocks.Components.General 951 @using Dynamicweb.Rapido.Blocks.Components 952 953 @* Component *@ 954 955 @helper RenderNumberField(NumberField settings) 956 { 957 var attributes = new Dictionary<string, string>(); 958 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 959 { 960 settings.Id = Guid.NewGuid().ToString("N"); 961 } 962 963 /*base settings*/ 964 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 965 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 966 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 967 if (settings.Disabled) { attributes.Add("disabled", "true"); } 968 if (settings.Required) { attributes.Add("required", "true"); } 969 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 970 /*end*/ 971 972 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 973 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 974 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 975 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 976 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 977 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 978 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 979 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 980 attributes.Add("type", "number"); 981 982 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 983 984 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 985 @if (!string.IsNullOrEmpty(settings.Label)) 986 { 987 <label for="@settings.Id">@settings.Label</label> 988 } 989 @if (!string.IsNullOrEmpty(settings.HelpText)) 990 { 991 <small class="form__help-text">@settings.HelpText</small> 992 } 993 994 @if (settings.ActionButton != null) 995 { 996 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 997 <div class="form__field-combi u-no-margin dw-mod"> 998 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 999 @Render(settings.ActionButton) 1000 </div> 1001 } 1002 else 1003 { 1004 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1005 } 1006 1007 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1008 </div> 1009 } 1010 @using System.Reflection 1011 @using Dynamicweb.Rapido.Blocks.Components.General 1012 @using Dynamicweb.Rapido.Blocks.Components 1013 1014 1015 @* Component *@ 1016 1017 @helper RenderTextareaField(TextareaField settings) 1018 { 1019 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1020 string id = settings.Id; 1021 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1022 { 1023 id = Guid.NewGuid().ToString("N"); 1024 } 1025 1026 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1027 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1028 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1029 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1030 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1031 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1032 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1033 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1034 if (settings.Required) { attributes.Add("required", "true"); } 1035 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1036 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1037 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1038 attributes.Add("name", settings.Name); 1039 1040 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1041 @if (!string.IsNullOrEmpty(settings.Label)) 1042 { 1043 <label for="@id">@settings.Label</label> 1044 } 1045 @if (!string.IsNullOrEmpty(settings.HelpText)) 1046 { 1047 <small class="form__help-text">@settings.HelpText</small> 1048 } 1049 1050 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1051 1052 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1053 </div> 1054 } 1055 @using System.Reflection 1056 @using Dynamicweb.Rapido.Blocks.Components.General 1057 @using Dynamicweb.Rapido.Blocks.Components 1058 1059 1060 @* Component *@ 1061 1062 @helper RenderHiddenField(HiddenField settings) { 1063 var attributes = new Dictionary<string, string>(); 1064 attributes.Add("type", "hidden"); 1065 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1066 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1067 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1068 1069 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1070 } 1071 @using System.Reflection 1072 @using Dynamicweb.Rapido.Blocks.Components.General 1073 @using Dynamicweb.Rapido.Blocks.Components 1074 1075 @* Component *@ 1076 1077 @helper RenderCheckboxField(CheckboxField settings) 1078 { 1079 var attributes = new Dictionary<string, string>(); 1080 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1081 { 1082 settings.Id = Guid.NewGuid().ToString("N"); 1083 } 1084 1085 /*base settings*/ 1086 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1087 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1088 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1089 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1090 if (settings.Required) { attributes.Add("required", "true"); } 1091 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1092 /*end*/ 1093 1094 attributes.Add("type", "checkbox"); 1095 if (settings.Checked) { attributes.Add("checked", "true"); } 1096 settings.CssClass = "form__control " + settings.CssClass; 1097 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1098 1099 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1100 1101 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1102 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1103 @if (!string.IsNullOrEmpty(settings.Label)) 1104 { 1105 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1106 } 1107 @if (!string.IsNullOrEmpty(settings.HelpText)) 1108 { 1109 <small class="form__help-text">@settings.HelpText</small> 1110 } 1111 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1112 </div> 1113 } 1114 @using System.Reflection 1115 @using Dynamicweb.Rapido.Blocks.Components.General 1116 @using Dynamicweb.Rapido.Blocks.Components 1117 1118 1119 @* Component *@ 1120 1121 @helper RenderCheckboxListField(CheckboxListField settings) 1122 { 1123 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1124 @if (!string.IsNullOrEmpty(settings.Label)) 1125 { 1126 <label>@settings.Label</label> 1127 } 1128 @if (!string.IsNullOrEmpty(settings.HelpText)) 1129 { 1130 <small class="form__help-text">@settings.HelpText</small> 1131 } 1132 1133 @foreach (var item in settings.Options) 1134 { 1135 if (settings.Required) 1136 { 1137 item.Required = true; 1138 } 1139 if (settings.Disabled) 1140 { 1141 item.Disabled = true; 1142 } 1143 if (!string.IsNullOrEmpty(settings.Name)) 1144 { 1145 item.Name = settings.Name; 1146 } 1147 if (!string.IsNullOrEmpty(settings.CssClass)) 1148 { 1149 item.CssClass += settings.CssClass; 1150 } 1151 1152 /* value is not supported */ 1153 1154 if (!string.IsNullOrEmpty(settings.OnClick)) 1155 { 1156 item.OnClick += settings.OnClick; 1157 } 1158 if (!string.IsNullOrEmpty(settings.OnChange)) 1159 { 1160 item.OnChange += settings.OnChange; 1161 } 1162 @Render(item) 1163 } 1164 1165 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1166 </div> 1167 } 1168 @using System.Reflection 1169 @using Dynamicweb.Rapido.Blocks.Components.General 1170 @using Dynamicweb.Rapido.Blocks.Components 1171 1172 1173 @* Component *@ 1174 1175 @helper RenderSelectField(SelectField settings) 1176 { 1177 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1178 { 1179 settings.Id = Guid.NewGuid().ToString("N"); 1180 } 1181 1182 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1183 @if (!string.IsNullOrEmpty(settings.Label)) 1184 { 1185 <label for="@settings.Id">@settings.Label</label> 1186 } 1187 @if (!string.IsNullOrEmpty(settings.HelpText)) 1188 { 1189 <small class="form__help-text">@settings.HelpText</small> 1190 } 1191 1192 @if (settings.ActionButton != null) 1193 { 1194 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1195 <div class="form__field-combi u-no-margin dw-mod"> 1196 @RenderSelectBase(settings) 1197 @Render(settings.ActionButton) 1198 </div> 1199 } 1200 else 1201 { 1202 @RenderSelectBase(settings) 1203 } 1204 1205 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1206 </div> 1207 } 1208 1209 @helper RenderSelectBase(SelectField settings) 1210 { 1211 var attributes = new Dictionary<string, string>(); 1212 1213 /*base settings*/ 1214 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1215 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1216 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1217 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1218 if (settings.Required) { attributes.Add("required", "true"); } 1219 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1220 /*end*/ 1221 1222 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1223 1224 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1225 @if (settings.Default != null) 1226 { 1227 @Render(settings.Default) 1228 } 1229 1230 @foreach (var item in settings.Options) 1231 { 1232 if (!string.IsNullOrEmpty(settings.Value)) { 1233 item.Checked = item.Value == settings.Value; 1234 } 1235 @Render(item) 1236 } 1237 </select> 1238 } 1239 @using System.Reflection 1240 @using Dynamicweb.Rapido.Blocks.Components.General 1241 @using Dynamicweb.Rapido.Blocks.Components 1242 1243 @* Component *@ 1244 1245 @helper RenderRadioButtonField(RadioButtonField settings) 1246 { 1247 var attributes = new Dictionary<string, string>(); 1248 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1249 { 1250 settings.Id = Guid.NewGuid().ToString("N"); 1251 } 1252 1253 /*base settings*/ 1254 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1255 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1256 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1257 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1258 if (settings.Required) { attributes.Add("required", "true"); } 1259 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1260 /*end*/ 1261 1262 attributes.Add("type", "radio"); 1263 if (settings.Checked) { attributes.Add("checked", "true"); } 1264 settings.CssClass = "form__control " + settings.CssClass; 1265 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1266 1267 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1268 1269 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1270 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1271 @if (!string.IsNullOrEmpty(settings.Label)) 1272 { 1273 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1274 } 1275 @if (!string.IsNullOrEmpty(settings.HelpText)) 1276 { 1277 <small class="form__help-text">@settings.HelpText</small> 1278 } 1279 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1280 </div> 1281 } 1282 @using System.Reflection 1283 @using Dynamicweb.Rapido.Blocks.Components.General 1284 @using Dynamicweb.Rapido.Blocks.Components 1285 1286 1287 @* Component *@ 1288 1289 @helper RenderRadioButtonListField(RadioButtonListField settings) 1290 { 1291 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1292 @if (!string.IsNullOrEmpty(settings.Label)) 1293 { 1294 <label>@settings.Label</label> 1295 } 1296 @if (!string.IsNullOrEmpty(settings.HelpText)) 1297 { 1298 <small class="form__help-text">@settings.HelpText</small> 1299 } 1300 1301 @foreach (var item in settings.Options) 1302 { 1303 if (settings.Required) 1304 { 1305 item.Required = true; 1306 } 1307 if (settings.Disabled) 1308 { 1309 item.Disabled = true; 1310 } 1311 if (!string.IsNullOrEmpty(settings.Name)) 1312 { 1313 item.Name = settings.Name; 1314 } 1315 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1316 { 1317 item.Checked = true; 1318 } 1319 if (!string.IsNullOrEmpty(settings.OnClick)) 1320 { 1321 item.OnClick += settings.OnClick; 1322 } 1323 if (!string.IsNullOrEmpty(settings.OnChange)) 1324 { 1325 item.OnChange += settings.OnChange; 1326 } 1327 if (!string.IsNullOrEmpty(settings.CssClass)) 1328 { 1329 item.CssClass += settings.CssClass; 1330 } 1331 @Render(item) 1332 } 1333 1334 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1335 </div> 1336 } 1337 @using System.Reflection 1338 @using Dynamicweb.Rapido.Blocks.Components.General 1339 @using Dynamicweb.Rapido.Blocks.Components 1340 1341 1342 @* Component *@ 1343 1344 @helper RenderNotificationMessage(NotificationMessage settings) 1345 { 1346 if (!string.IsNullOrEmpty(settings.Message)) 1347 { 1348 var attributes = new Dictionary<string, string>(); 1349 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1350 1351 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1352 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1353 } 1354 } 1355 @using Dynamicweb.Rapido.Blocks.Components.General 1356 1357 1358 @* Component *@ 1359 1360 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1361 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1362 1363 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1364 @if (settings.SubBlocks != null) { 1365 @RenderBlockList(settings.SubBlocks) 1366 } 1367 </div> 1368 } 1369 @using System.Reflection 1370 @using Dynamicweb.Rapido.Blocks.Components.General 1371 @using Dynamicweb.Rapido.Blocks.Components 1372 @using System.Text.RegularExpressions 1373 1374 1375 @* Component *@ 1376 1377 @helper RenderSticker(Sticker settings) { 1378 if (!String.IsNullOrEmpty(settings.Title)) { 1379 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1380 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1381 1382 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1383 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1384 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1385 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1386 optionalAttributes.Add("style", styleTag); 1387 } 1388 1389 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1390 } 1391 } 1392 1393 @using System.Reflection 1394 @using Dynamicweb.Rapido.Blocks.Components.General 1395 @using Dynamicweb.Rapido.Blocks.Components 1396 1397 1398 @* Component *@ 1399 1400 @helper RenderStickersCollection(StickersCollection settings) 1401 { 1402 if (settings.Stickers.Count > 0) 1403 { 1404 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1405 1406 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1407 @foreach (Sticker sticker in settings.Stickers) 1408 { 1409 @Render(sticker) 1410 } 1411 </div> 1412 } 1413 } 1414 1415 @using Dynamicweb.Rapido.Blocks.Components.General 1416 1417 1418 @* Component *@ 1419 1420 @helper RenderForm(Form settings) { 1421 if (settings != null) 1422 { 1423 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1424 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1425 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1426 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1427 var enctypes = new Dictionary<string, string> 1428 { 1429 { "multipart", "multipart/form-data" }, 1430 { "text", "text/plain" }, 1431 { "application", "application/x-www-form-urlencoded" } 1432 }; 1433 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1434 optionalAttributes.Add("method", settings.Method.ToString()); 1435 1436 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1437 { 1438 @settings.FormStartMarkup 1439 } 1440 else 1441 { 1442 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1443 } 1444 1445 foreach (var field in settings.GetFields()) 1446 { 1447 @Render(field) 1448 } 1449 1450 @:</form> 1451 } 1452 } 1453 @using System.Reflection 1454 @using Dynamicweb.Rapido.Blocks.Components.General 1455 @using Dynamicweb.Rapido.Blocks.Components 1456 1457 1458 @* Component *@ 1459 1460 @helper RenderText(Text settings) 1461 { 1462 @settings.Content 1463 } 1464 @using System.Reflection 1465 @using Dynamicweb.Rapido.Blocks.Components.General 1466 @using Dynamicweb.Rapido.Blocks.Components 1467 1468 1469 @* Component *@ 1470 1471 @helper RenderContentModule(ContentModule settings) { 1472 if (!string.IsNullOrEmpty(settings.Content)) 1473 { 1474 @settings.Content 1475 } 1476 } 1477 @using System.Reflection 1478 @using Dynamicweb.Rapido.Blocks.Components.General 1479 @using Dynamicweb.Rapido.Blocks.Components 1480 1481 1482 @* Component *@ 1483 1484 @helper RenderModal(Modal settings) { 1485 if (settings != null) 1486 { 1487 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1488 1489 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1490 1491 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1492 1493 <div class="modal-container"> 1494 @if (!settings.DisableDarkOverlay) 1495 { 1496 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1497 } 1498 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1499 @if (settings.Heading != null) 1500 { 1501 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1502 { 1503 <div class="modal__header"> 1504 @Render(settings.Heading) 1505 </div> 1506 } 1507 } 1508 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1509 @if (!string.IsNullOrEmpty(settings.BodyText)) 1510 { 1511 @settings.BodyText 1512 } 1513 @if (settings.BodyTemplate != null) 1514 { 1515 @settings.BodyTemplate 1516 } 1517 @{ 1518 var actions = settings.GetActions(); 1519 } 1520 </div> 1521 @if (actions.Length > 0) 1522 { 1523 <div class="modal__footer"> 1524 @foreach (var action in actions) 1525 { 1526 action.CssClass += " u-no-margin"; 1527 @Render(action) 1528 } 1529 </div> 1530 } 1531 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1532 </div> 1533 </div> 1534 } 1535 } 1536 @using Dynamicweb.Rapido.Blocks.Components.General 1537 1538 @* Component *@ 1539 1540 @helper RenderMediaListItem(MediaListItem settings) 1541 { 1542 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1543 @if (!string.IsNullOrEmpty(settings.Label)) 1544 { 1545 if (!string.IsNullOrEmpty(settings.Link)) 1546 { 1547 @Render(new Link 1548 { 1549 Href = settings.Link, 1550 CssClass = "media-list-item__sticker dw-mod", 1551 ButtonLayout = ButtonLayout.None, 1552 Title = settings.Label, 1553 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1554 }) 1555 } 1556 else if (!string.IsNullOrEmpty(settings.OnClick)) 1557 { 1558 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1559 <span class="u-uppercase">@settings.Label</span> 1560 </span> 1561 } 1562 else 1563 { 1564 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1565 <span class="u-uppercase">@settings.Label</span> 1566 </span> 1567 } 1568 } 1569 <div class="media-list-item__wrap"> 1570 <div class="media-list-item__info dw-mod"> 1571 <div class="media-list-item__header dw-mod"> 1572 @if (!string.IsNullOrEmpty(settings.Title)) 1573 { 1574 if (!string.IsNullOrEmpty(settings.Link)) 1575 { 1576 @Render(new Link 1577 { 1578 Href = settings.Link, 1579 CssClass = "media-list-item__name dw-mod", 1580 ButtonLayout = ButtonLayout.None, 1581 Title = settings.Title, 1582 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1583 }) 1584 } 1585 else if (!string.IsNullOrEmpty(settings.OnClick)) 1586 { 1587 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1588 } 1589 else 1590 { 1591 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1592 } 1593 } 1594 1595 @if (!string.IsNullOrEmpty(settings.Status)) 1596 { 1597 <div class="media-list-item__state dw-mod">@settings.Status</div> 1598 } 1599 </div> 1600 @{ 1601 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1602 } 1603 1604 @Render(settings.InfoTable) 1605 </div> 1606 <div class="media-list-item__actions dw-mod"> 1607 <div class="media-list-item__actions-list dw-mod"> 1608 @{ 1609 var actions = settings.GetActions(); 1610 1611 foreach (ButtonBase action in actions) 1612 { 1613 action.ButtonLayout = ButtonLayout.None; 1614 action.CssClass += " media-list-item__action link"; 1615 1616 @Render(action) 1617 } 1618 } 1619 </div> 1620 1621 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1622 { 1623 settings.SelectButton.CssClass += " u-no-margin"; 1624 1625 <div class="media-list-item__action-button"> 1626 @Render(settings.SelectButton) 1627 </div> 1628 } 1629 </div> 1630 </div> 1631 </div> 1632 } 1633 @using Dynamicweb.Rapido.Blocks.Components.General 1634 @using Dynamicweb.Rapido.Blocks.Components 1635 1636 @helper RenderTable(Table settings) 1637 { 1638 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1639 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1640 1641 var enumToClasses = new Dictionary<TableDesign, string> 1642 { 1643 { TableDesign.Clean, "table--clean" }, 1644 { TableDesign.Bordered, "table--bordered" }, 1645 { TableDesign.Striped, "table--striped" }, 1646 { TableDesign.Hover, "table--hover" }, 1647 { TableDesign.Compact, "table--compact" }, 1648 { TableDesign.Condensed, "table--condensed" }, 1649 { TableDesign.NoTopBorder, "table--no-top-border" } 1650 }; 1651 string tableDesignClass = ""; 1652 if (settings.Design != TableDesign.None) 1653 { 1654 tableDesignClass = enumToClasses[settings.Design]; 1655 } 1656 1657 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1658 1659 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1660 1661 <table @ComponentMethods.AddAttributes(resultAttributes)> 1662 @if (settings.Header != null) 1663 { 1664 <thead> 1665 @Render(settings.Header) 1666 </thead> 1667 } 1668 <tbody> 1669 @foreach (var row in settings.Rows) 1670 { 1671 @Render(row) 1672 } 1673 </tbody> 1674 @if (settings.Footer != null) 1675 { 1676 <tfoot> 1677 @Render(settings.Footer) 1678 </tfoot> 1679 } 1680 </table> 1681 } 1682 @using Dynamicweb.Rapido.Blocks.Components.General 1683 @using Dynamicweb.Rapido.Blocks.Components 1684 1685 @helper RenderTableRow(TableRow settings) 1686 { 1687 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1688 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1689 1690 var enumToClasses = new Dictionary<TableRowDesign, string> 1691 { 1692 { TableRowDesign.NoBorder, "table__row--no-border" }, 1693 { TableRowDesign.Border, "table__row--border" }, 1694 { TableRowDesign.TopBorder, "table__row--top-line" }, 1695 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1696 { TableRowDesign.Solid, "table__row--solid" } 1697 }; 1698 1699 string tableRowDesignClass = ""; 1700 if (settings.Design != TableRowDesign.None) 1701 { 1702 tableRowDesignClass = enumToClasses[settings.Design]; 1703 } 1704 1705 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1706 1707 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1708 1709 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1710 @foreach (var cell in settings.Cells) 1711 { 1712 if (settings.IsHeaderRow) 1713 { 1714 cell.IsHeader = true; 1715 } 1716 @Render(cell) 1717 } 1718 </tr> 1719 } 1720 @using Dynamicweb.Rapido.Blocks.Components.General 1721 @using Dynamicweb.Rapido.Blocks.Components 1722 @using Dynamicweb.Core 1723 1724 @helper RenderTableCell(TableCell settings) 1725 { 1726 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1727 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1728 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1729 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1730 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1731 1732 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1733 1734 string tagName = settings.IsHeader ? "th" : "td"; 1735 1736 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1737 @settings.Content 1738 @("</" + tagName + ">"); 1739 } 1740 @using System.Linq 1741 @using Dynamicweb.Rapido.Blocks.Components.General 1742 1743 @* Component *@ 1744 1745 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1746 { 1747 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1748 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1749 1750 if (settings.NumberOfPages > 1) 1751 { 1752 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1753 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1754 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1755 1756 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1757 @if (settings.ShowPagingInfo) 1758 { 1759 <div class="pager__info dw-mod"> 1760 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1761 </div> 1762 } 1763 <ul class="pager__list dw-mod"> 1764 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1765 { 1766 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1767 } 1768 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1769 { 1770 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1771 } 1772 @if (settings.GetPages().Any()) 1773 { 1774 foreach (var page in settings.GetPages()) 1775 { 1776 @Render(page) 1777 } 1778 } 1779 else 1780 { 1781 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1782 { 1783 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1784 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1785 } 1786 } 1787 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1788 { 1789 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1790 } 1791 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1792 { 1793 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1794 } 1795 </ul> 1796 </div> 1797 } 1798 } 1799 1800 @helper RenderPaginationItem(PaginationItem settings) 1801 { 1802 if (settings.Icon == null) 1803 { 1804 settings.Icon = new Icon(); 1805 } 1806 1807 settings.Icon.Label = settings.Label; 1808 <li class="pager__btn dw-mod"> 1809 @if (settings.IsActive) 1810 { 1811 <span class="pager__num pager__num--current dw-mod"> 1812 @Render(settings.Icon) 1813 </span> 1814 } 1815 else 1816 { 1817 <a href="@settings.Link" class="pager__num dw-mod"> 1818 @Render(settings.Icon) 1819 </a> 1820 } 1821 </li> 1822 } 1823 1824 1825 @using Dynamicweb.Rapido.Blocks.Components.General 1826 1827 1828 1829 1830 1831 @using System.Text.RegularExpressions 1832 @using System.Collections.Generic 1833 @using System.Reflection 1834 @using System.Web 1835 @using System.Web.UI.HtmlControls 1836 @using Dynamicweb.Rapido.Blocks.Components 1837 @using Dynamicweb.Rapido.Blocks.Components.Articles 1838 @using Dynamicweb.Rapido.Blocks.Components.Documentation 1839 @using Dynamicweb.Rapido.Blocks 1840 1841 1842 @*--- START: Base block renderers ---*@ 1843 1844 @helper RenderBlockList(List<Block> blocks) 1845 { 1846 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 1847 blocks = blocks.OrderBy(item => item.SortId).ToList(); 1848 1849 foreach (Block item in blocks) 1850 { 1851 if (debug) { 1852 <!-- Block START: @item.Id --> 1853 } 1854 1855 if (item.Design == null) 1856 { 1857 @RenderBlock(item) 1858 } 1859 else if (item.Design.RenderType == RenderType.None) { 1860 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 1861 1862 <div class="@cssClass dw-mod"> 1863 @RenderBlock(item) 1864 </div> 1865 } 1866 else if (item.Design.RenderType != RenderType.Hide) 1867 { 1868 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 1869 1870 if (!item.SkipRenderBlocksList) { 1871 if (item.Design.RenderType == RenderType.Row) 1872 { 1873 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 1874 @RenderBlock(item) 1875 </div> 1876 } 1877 1878 if (item.Design.RenderType == RenderType.Column) 1879 { 1880 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 1881 string size = item.Design.Size ?? "12"; 1882 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 1883 1884 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id"> 1885 @RenderBlock(item) 1886 </div> 1887 } 1888 1889 if (item.Design.RenderType == RenderType.Table) 1890 { 1891 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 1892 @RenderBlock(item) 1893 </table> 1894 } 1895 1896 if (item.Design.RenderType == RenderType.TableRow) 1897 { 1898 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 1899 @RenderBlock(item) 1900 </tr> 1901 } 1902 1903 if (item.Design.RenderType == RenderType.TableColumn) 1904 { 1905 <td class="@cssClass dw-mod" id="Block__@item.Id"> 1906 @RenderBlock(item) 1907 </td> 1908 } 1909 1910 if (item.Design.RenderType == RenderType.CardHeader) 1911 { 1912 <div class="card-header @cssClass dw-mod"> 1913 @RenderBlock(item) 1914 </div> 1915 } 1916 1917 if (item.Design.RenderType == RenderType.CardBody) 1918 { 1919 <div class="card @cssClass dw-mod"> 1920 @RenderBlock(item) 1921 </div> 1922 } 1923 1924 if (item.Design.RenderType == RenderType.CardFooter) 1925 { 1926 <div class="card-footer @cssClass dw-mod"> 1927 @RenderBlock(item) 1928 </div> 1929 } 1930 } 1931 else 1932 { 1933 @RenderBlock(item) 1934 } 1935 } 1936 1937 if (debug) { 1938 <!-- Block END: @item.Id --> 1939 } 1940 } 1941 } 1942 1943 @helper RenderBlock(Block item) 1944 { 1945 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 1946 1947 if (item.Template != null) 1948 { 1949 @BlocksPage.RenderTemplate(item.Template) 1950 } 1951 1952 if (item.Component != null) 1953 { 1954 string customSufix = "Custom"; 1955 string methodName = item.Component.HelperName; 1956 1957 ComponentBase[] methodParameters = new ComponentBase[1]; 1958 methodParameters[0] = item.Component; 1959 Type methodType = this.GetType(); 1960 1961 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 1962 MethodInfo generalMethod = methodType.GetMethod(methodName); 1963 1964 try { 1965 if (debug) { 1966 <!-- Component: @methodName.Replace("Render", "") --> 1967 } 1968 @customMethod.Invoke(this, methodParameters).ToString(); 1969 } catch { 1970 try { 1971 @generalMethod.Invoke(this, methodParameters).ToString(); 1972 } catch(Exception ex) { 1973 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 1974 } 1975 } 1976 } 1977 1978 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 1979 { 1980 @RenderBlockList(item.BlocksList) 1981 } 1982 } 1983 1984 @*--- END: Base block renderers ---*@ 1985 1986 1987 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 1988 @RenderBlockList(loginPage.BlocksRoot.BlocksList) 1989