Cart

Error executing template "Designs/Rapido/eCom7/CartV2/Step/Custom__Cart.cshtml"
System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.b__48_0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 2177
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 237
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 173
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 268
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 162
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 268
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 173
   at CompiledRazorTemplates.Dynamic.RazorEngine_7d3e0f5ccde0400da5424f87aeacfbe6.Execute() in e:\WGOIISShare\WGO_Prod\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Custom__Cart.cshtml:line 3095
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using Dynamicweb.Ecommerce.Orders 7 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 8 @using System 9 @using System.IO 10 @using Dynamicweb.Rapido.Blocks 11 12 13 @functions{ 14 BlocksPage checkoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 15 string checkoutPageType = "onestep"; 16 } 17 18 @{ 19 string pageId = GetGlobalValue("Global:Page.ID"); 20 21 Block checkoutTopSnippets = new Block() 22 { 23 Id = "CheckoutTopSnippets", 24 SortId = 10 25 }; 26 checkoutPage.Add(checkoutTopSnippets); 27 28 Block checkoutForm = new Block 29 { 30 Id = "CheckoutForm", 31 SortId = 20, 32 SkipRenderBlocksList = true, 33 BlocksList = new List<Block> 34 { 35 new Block() 36 { 37 Id = "OrderContainer", 38 SortId = 30, 39 Design = new Design 40 { 41 RenderType = RenderType.Column, 42 Size = "12", 43 HidePadding = true 44 }, 45 BlocksList = new List<Block> { 46 new Block() 47 { 48 Id = "OrderContainerRow", 49 SortId = 10, 50 Design = new Design 51 { 52 RenderType = RenderType.Row 53 } 54 } 55 } 56 } 57 } 58 }; 59 60 checkoutPage.Add(checkoutForm); 61 62 Block addressContainer = new Block() 63 { 64 Id = "AddressContainer", 65 SortId = 20, 66 Design = new Design 67 { 68 RenderType = RenderType.Column, 69 Size = "9", 70 HidePadding = true 71 }, 72 BlocksList = new List<Block> { 73 new Block() 74 { 75 Id = "AddressContainerRow", 76 SortId = 10, 77 Design = new Design 78 { 79 RenderType = RenderType.Row 80 } 81 } 82 } 83 }; 84 checkoutPage.Add(addressContainer); 85 86 Block orderContainer = new Block() 87 { 88 Id = "OrderContainer", 89 SortId = 30, 90 Design = new Design 91 { 92 RenderType = RenderType.Column, 93 Size = "3", 94 HidePadding = true 95 }, 96 BlocksList = new List<Block> { 97 new Block() 98 { 99 Id = "SummaryContainerRow", 100 SortId = 10, 101 Design = new Design 102 { 103 RenderType = RenderType.Row 104 } 105 } 106 } 107 }; 108 checkoutPage.Add(orderContainer); 109 110 Block checkoutBottomSnippets = new Block() 111 { 112 Id = "CheckoutBottomSnippets", 113 SortId = 50 114 }; 115 checkoutPage.Add(checkoutBottomSnippets); 116 } 117 118 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 119 @using System.Text.RegularExpressions 120 @using System.Collections.Generic 121 @using System.Reflection 122 @using System.Web 123 @using System.Web.UI.HtmlControls 124 @using Dynamicweb.Rapido.Blocks.Components 125 @using Dynamicweb.Rapido.Blocks.Components.Articles 126 @using Dynamicweb.Rapido.Blocks.Components.Documentation 127 @using Dynamicweb.Rapido.Blocks 128 129 130 @*--- START: Base block renderers ---*@ 131 132 @helper RenderBlockList(List<Block> blocks) 133 { 134 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 135 blocks = blocks.OrderBy(item => item.SortId).ToList(); 136 137 foreach (Block item in blocks) 138 { 139 if (debug) { 140 <!-- Block START: @item.Id --> 141 } 142 143 if (item.Design == null) 144 { 145 @RenderBlock(item) 146 } 147 else if (item.Design.RenderType == RenderType.None) { 148 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 149 150 <div class="@cssClass dw-mod"> 151 @RenderBlock(item) 152 </div> 153 } 154 else if (item.Design.RenderType != RenderType.Hide) 155 { 156 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 157 158 if (!item.SkipRenderBlocksList) { 159 if (item.Design.RenderType == RenderType.Row) 160 { 161 <div class="grid grid--align-content-start @cssClass dw-mod" id="[email protected]"> 162 @RenderBlock(item) 163 </div> 164 } 165 166 if (item.Design.RenderType == RenderType.Column) 167 { 168 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 169 string size = item.Design.Size ?? "12"; 170 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 171 172 <div class="[email protected] [email protected] grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="[email protected]"> 173 @RenderBlock(item) 174 </div> 175 } 176 177 if (item.Design.RenderType == RenderType.Table) 178 { 179 <table class="table @cssClass dw-mod" id="[email protected]"> 180 @RenderBlock(item) 181 </table> 182 } 183 184 if (item.Design.RenderType == RenderType.TableRow) 185 { 186 <tr class="@cssClass dw-mod" id="[email protected]"> 187 @RenderBlock(item) 188 </tr> 189 } 190 191 if (item.Design.RenderType == RenderType.TableColumn) 192 { 193 <td class="@cssClass dw-mod" id="[email protected]"> 194 @RenderBlock(item) 195 </td> 196 } 197 198 if (item.Design.RenderType == RenderType.CardHeader) 199 { 200 <div class="card-header @cssClass dw-mod"> 201 @RenderBlock(item) 202 </div> 203 } 204 205 if (item.Design.RenderType == RenderType.CardBody) 206 { 207 <div class="card @cssClass dw-mod"> 208 @RenderBlock(item) 209 </div> 210 } 211 212 if (item.Design.RenderType == RenderType.CardFooter) 213 { 214 <div class="card-footer @cssClass dw-mod"> 215 @RenderBlock(item) 216 </div> 217 } 218 } 219 else 220 { 221 @RenderBlock(item) 222 } 223 } 224 225 if (debug) { 226 <!-- Block END: @item.Id --> 227 } 228 } 229 } 230 231 @helper RenderBlock(Block item) 232 { 233 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 234 235 if (item.Template != null) 236 { 237 @BlocksPage.RenderTemplate(item.Template) 238 } 239 240 if (item.Component != null) 241 { 242 string customSufix = "Custom"; 243 string methodName = item.Component.HelperName; 244 245 ComponentBase[] methodParameters = new ComponentBase[1]; 246 methodParameters[0] = item.Component; 247 Type methodType = this.GetType(); 248 249 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 250 MethodInfo generalMethod = methodType.GetMethod(methodName); 251 252 try { 253 if (debug) { 254 <!-- Component: @methodName.Replace("Render", "") --> 255 } 256 @customMethod.Invoke(this, methodParameters).ToString(); 257 } catch { 258 try { 259 @generalMethod.Invoke(this, methodParameters).ToString(); 260 } catch(Exception ex) { 261 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 262 } 263 } 264 } 265 266 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 267 { 268 @RenderBlockList(item.BlocksList) 269 } 270 } 271 272 @*--- END: Base block renderers ---*@ 273 274 275 @* Include the Blocks for the page *@ 276 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 277 @using Dynamicweb.Core 278 @using System 279 @using System.Web 280 @using System.Collections.Generic 281 @using System.Linq 282 @using Dynamicweb.Rapido.Blocks 283 @using Dynamicweb.Rapido.Blocks.Components.General 284 @using Dynamicweb.UI.Elements.Html 285 @using Dynamicweb.Rendering; 286 287 @{ 288 BlocksPage billingAddressCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 289 290 Block shippingAddressBlock = new Block() 291 { 292 Id = "ShippingAddress", 293 SortId = 10, 294 Template = RenderCustomerAddress(), 295 BlocksList = new List<Block> { 296 new Block() 297 { 298 Id = "BillingAddress", 299 SortId = 20, 300 Template = RenderBillingAddressCustom() 301 }, 302 new Block() 303 { 304 Id = "AdditionalInformation", 305 SortId = 30, 306 Template = RenderAdditionalInformationCustom() 307 } 308 309 }, 310 Design = new Design 311 { 312 RenderType = RenderType.Column, 313 Size = "12" 314 } 315 }; 316 billingAddressCheckoutPage.Add("AddressContainerRow", shippingAddressBlock); 317 } 318 319 @using Dynamicweb.Rapido.Blocks.Components 320 @using Dynamicweb.Rapido.Blocks.Components.General 321 @using Dynamicweb.Rapido.Blocks 322 @using System.IO 323 324 @* Required *@ 325 @using Dynamicweb.Rapido.Blocks.Components 326 @using Dynamicweb.Rapido.Blocks.Components.General 327 @using Dynamicweb.Rapido.Blocks 328 329 330 @helper Render(ComponentBase component) 331 { 332 if (component != null) 333 { 334 @component.Render(this) 335 } 336 } 337 338 339 @* Components *@ 340 @using System.Reflection 341 @using Dynamicweb.Rapido.Blocks.Components.General 342 343 344 @* Component *@ 345 346 @helper RenderIcon(Icon settings) 347 { 348 if (settings != null) 349 { 350 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 351 352 if (settings.Name != null) 353 { 354 if (string.IsNullOrEmpty(settings.Label)) 355 { 356 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 357 } 358 else 359 { 360 if (settings.LabelPosition == IconLabelPosition.Before) 361 { 362 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 363 } 364 else 365 { 366 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 367 } 368 } 369 } 370 else if (!string.IsNullOrEmpty(settings.Label)) 371 { 372 @settings.Label 373 } 374 } 375 } 376 @using System.Reflection 377 @using Dynamicweb.Rapido.Blocks.Components.General 378 @using Dynamicweb.Rapido.Blocks.Components 379 @using Dynamicweb.Core 380 381 @* Component *@ 382 383 @helper RenderButton(Button settings) 384 { 385 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 386 { 387 Dictionary<string, string> attributes = new Dictionary<string, string>(); 388 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 389 if (settings.Disabled) { 390 attributes.Add("disabled", "true"); 391 classList.Add("disabled"); 392 } 393 394 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 395 { 396 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 397 @RenderConfirmDialog(settings); 398 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 399 } 400 401 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 402 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 403 if (!string.IsNullOrEmpty(settings.AltText)) 404 { 405 attributes.Add("aria-label", settings.AltText); 406 } 407 408 var onClickEvents = new List<string>(); 409 if (!string.IsNullOrEmpty(settings.OnClick)) 410 { 411 onClickEvents.Add(settings.OnClick); 412 } 413 if (!string.IsNullOrEmpty(settings.Href)) 414 { 415 onClickEvents.Add("location.href='" + settings.Href + "'"); 416 } 417 if (onClickEvents.Count > 0) 418 { 419 attributes.Add("onClick", string.Join(";", onClickEvents)); 420 } 421 422 if (settings.ButtonLayout != ButtonLayout.None) 423 { 424 classList.Add("btn"); 425 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 426 if (btnLayout == "linkclean") 427 { 428 btnLayout = "link-clean"; //fix 429 } 430 classList.Add("btn--" + btnLayout); 431 } 432 433 if (settings.Icon == null) 434 { 435 settings.Icon = new Icon(); 436 } 437 settings.Icon.Label = settings.Title; 438 439 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 440 441 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 442 } 443 } 444 445 @helper RenderConfirmDialog(Button settings) 446 { 447 Modal confirmDialog = new Modal { 448 Id = settings.Id, 449 Width = ModalWidth.Sm, 450 Heading = new Heading 451 { 452 Level = 2, 453 Title = settings.ConfirmTitle 454 }, 455 BodyText = settings.ConfirmText 456 }; 457 458 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 459 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 460 461 @Render(confirmDialog) 462 } 463 @using Dynamicweb.Rapido.Blocks.Components.General 464 @using Dynamicweb.Rapido.Blocks.Components 465 @using Dynamicweb.Core 466 467 @helper RenderDashboard(Dashboard settings) 468 { 469 var widgets = settings.GetWidgets(); 470 471 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 472 { 473 //set bg color for them 474 475 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 476 int r = Convert.ToInt16(color.R); 477 int g = Convert.ToInt16(color.G); 478 int b = Convert.ToInt16(color.B); 479 480 var count = widgets.Length; 481 var max = Math.Max(r, Math.Max(g, b)); 482 double step = 255.0 / (max * count); 483 var i = 0; 484 foreach (var widget in widgets) 485 { 486 i++; 487 488 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 489 widget.BackgroundColor = shade; 490 } 491 } 492 493 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 494 @foreach (var widget in widgets) 495 { 496 <div class="dashboard__widget"> 497 @Render(widget) 498 </div> 499 } 500 </div> 501 } 502 @using Dynamicweb.Rapido.Blocks.Components.General 503 @using Dynamicweb.Rapido.Blocks.Components 504 505 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 506 { 507 if (!string.IsNullOrEmpty(settings.Link)) 508 { 509 var backgroundStyles = ""; 510 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 511 { 512 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 513 } 514 515 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 516 <div class="u-center-middle u-color-light"> 517 @if (settings.Icon != null) 518 { 519 settings.Icon.CssClass += "widget__icon"; 520 @Render(settings.Icon) 521 } 522 <div class="widget__title">@settings.Title</div> 523 </div> 524 </a> 525 } 526 } 527 @using Dynamicweb.Rapido.Blocks.Components.General 528 @using Dynamicweb.Rapido.Blocks.Components 529 530 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 531 { 532 var backgroundStyles = ""; 533 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 534 { 535 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 536 } 537 538 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 539 <div class="u-center-middle u-color-light"> 540 @if (settings.Icon != null) 541 { 542 settings.Icon.CssClass += "widget__icon"; 543 @Render(settings.Icon) 544 } 545 <div class="widget__counter">@settings.Count</div> 546 <div class="widget__title">@settings.Title</div> 547 </div> 548 </div> 549 } 550 @using System.Reflection 551 @using Dynamicweb.Rapido.Blocks.Components.General 552 @using Dynamicweb.Rapido.Blocks.Components 553 @using Dynamicweb.Core 554 555 @* Component *@ 556 557 @helper RenderLink(Link settings) 558 { 559 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 560 { 561 Dictionary<string, string> attributes = new Dictionary<string, string>(); 562 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 563 if (settings.Disabled) 564 { 565 attributes.Add("disabled", "true"); 566 classList.Add("disabled"); 567 } 568 569 if (!string.IsNullOrEmpty(settings.AltText)) 570 { 571 attributes.Add("aria-label", settings.AltText); 572 } 573 574 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 575 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 576 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 577 attributes.Add("href", settings.Href); 578 579 if (settings.ButtonLayout != ButtonLayout.None) 580 { 581 classList.Add("btn"); 582 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 583 if (btnLayout == "linkclean") 584 { 585 btnLayout = "link-clean"; //fix 586 } 587 classList.Add("btn--" + btnLayout); 588 } 589 590 if (settings.Icon == null) 591 { 592 settings.Icon = new Icon(); 593 } 594 settings.Icon.Label = settings.Title; 595 596 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 597 { 598 settings.Rel = LinkRelType.Noopener; 599 } 600 if (settings.Target != LinkTargetType.None) 601 { 602 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 603 } 604 if (settings.Download) 605 { 606 attributes.Add("download", "true"); 607 } 608 if (settings.Rel != LinkRelType.None) 609 { 610 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 611 } 612 613 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 614 } 615 } 616 @using System.Reflection 617 @using Dynamicweb.Rapido.Blocks.Components 618 @using Dynamicweb.Rapido.Blocks.Components.General 619 @using Dynamicweb.Rapido.Blocks 620 621 622 @* Component *@ 623 624 @helper RenderRating(Rating settings) 625 { 626 if (settings.Score > 0) 627 { 628 int rating = settings.Score; 629 string iconType = "fa-star"; 630 631 switch (settings.Type.ToString()) { 632 case "Stars": 633 iconType = "fa-star"; 634 break; 635 case "Hearts": 636 iconType = "fa-heart"; 637 break; 638 case "Lemons": 639 iconType = "fa-lemon"; 640 break; 641 case "Bombs": 642 iconType = "fa-bomb"; 643 break; 644 } 645 646 <div class="u-ta-right"> 647 @for (int i = 0; i < settings.OutOf; i++) 648 { 649 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 650 } 651 </div> 652 } 653 } 654 @using System.Reflection 655 @using Dynamicweb.Rapido.Blocks.Components.General 656 @using Dynamicweb.Rapido.Blocks.Components 657 658 659 @* Component *@ 660 661 @helper RenderSelectFieldOption(SelectFieldOption settings) 662 { 663 Dictionary<string, string> attributes = new Dictionary<string, string>(); 664 if (settings.Checked) { attributes.Add("selected", "true"); } 665 if (settings.Disabled) { attributes.Add("disabled", "true"); } 666 if (settings.Value != null) { attributes.Add("value", settings.Value); } 667 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 668 669 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 670 } 671 @using System.Reflection 672 @using Dynamicweb.Rapido.Blocks.Components.General 673 @using Dynamicweb.Rapido.Blocks.Components 674 675 676 @* Component *@ 677 678 @helper RenderNavigation(Navigation settings) { 679 @RenderNavigation(new 680 { 681 id = settings.Id, 682 cssclass = settings.CssClass, 683 startLevel = settings.StartLevel, 684 endlevel = settings.EndLevel, 685 expandmode = settings.Expandmode, 686 sitemapmode = settings.SitemapMode, 687 template = settings.Template 688 }) 689 } 690 @using Dynamicweb.Rapido.Blocks.Components.General 691 @using Dynamicweb.Rapido.Blocks.Components 692 693 694 @* Component *@ 695 696 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 697 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 698 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 699 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 700 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 701 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 702 settings.SitemapMode = false; 703 704 @RenderNavigation(settings) 705 } 706 @using Dynamicweb.Rapido.Blocks.Components.General 707 @using Dynamicweb.Rapido.Blocks.Components 708 709 710 @* Component *@ 711 712 @helper RenderLeftNavigation(LeftNavigation settings) { 713 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 714 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 715 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 716 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 717 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 718 719 <div class="grid__cell"> 720 @RenderNavigation(settings) 721 </div> 722 } 723 @using System.Reflection 724 @using Dynamicweb.Rapido.Blocks.Components.General 725 @using Dynamicweb.Core 726 727 @* Component *@ 728 729 @helper RenderHeading(Heading settings) 730 { 731 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 732 { 733 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 734 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 735 736 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 737 if (!string.IsNullOrEmpty(settings.Link)) 738 { 739 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 740 } 741 else 742 { 743 if (settings.Icon == null) 744 { 745 settings.Icon = new Icon(); 746 } 747 settings.Icon.Label = settings.Title; 748 @Render(settings.Icon) 749 } 750 @("</" + tagName + ">"); 751 } 752 } 753 @using Dynamicweb.Rapido.Blocks.Components 754 @using Dynamicweb.Rapido.Blocks.Components.General 755 @using Dynamicweb.Rapido.Blocks 756 757 758 @* Component *@ 759 760 @helper RenderImage(Image settings) 761 { 762 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 763 { 764 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 765 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 766 767 if (settings.Caption != null) 768 { 769 @:<div> 770 } 771 772 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 773 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 774 775 <div class="image-filter [email protected] u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 776 <div class="image-filter [email protected] dw-mod"> 777 @if (settings.Link != null) 778 { 779 <a href="@settings.Link" tabindex="-1"> 780 @RenderTheImage(settings) 781 </a> 782 } 783 else 784 { 785 @RenderTheImage(settings) 786 } 787 </div> 788 </div> 789 790 if (settings.Caption != null) 791 { 792 <span class="image-caption dw-mod">@settings.Caption</span> 793 @:</div> 794 } 795 } 796 else 797 { 798 if (settings.Caption != null) 799 { 800 @:<div> 801 } 802 if (!string.IsNullOrEmpty(settings.Link)) 803 { 804 <a href="@settings.Link" tabindex="-1"> 805 @RenderTheImage(settings) 806 </a> 807 } 808 else 809 { 810 @RenderTheImage(settings) 811 } 812 813 if (settings.Caption != null) 814 { 815 <span class="image-caption dw-mod">@settings.Caption</span> 816 @:</div> 817 } 818 } 819 } 820 821 @helper RenderTheImage(Image settings) 822 { 823 if (settings != null) 824 { 825 string placeholderImage = "/Files/Images/placeholder.gif"; 826 string imageEngine = "/Admin/Public/GetImage.ashx?Format=jpg&"; 827 828 string imageStyle = ""; 829 830 switch (settings.Style) 831 { 832 case ImageStyle.Ball: 833 imageStyle = "grid__cell-img--ball"; 834 break; 835 } 836 837 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 838 { 839 if (settings.ImageDefault != null) 840 { 841 settings.ImageDefault.Height = settings.ImageDefault.Width; 842 } 843 if (settings.ImageMedium != null) 844 { 845 settings.ImageMedium.Height = settings.ImageMedium.Width; 846 } 847 if (settings.ImageSmall != null) 848 { 849 settings.ImageSmall.Height = settings.ImageSmall.Width; 850 } 851 } 852 853 string defaultImage = imageEngine; 854 string imageSmall = ""; 855 string imageMedium = ""; 856 857 if (settings.DisableImageEngine) 858 { 859 defaultImage = settings.Path; 860 } 861 else 862 { 863 if (settings.ImageDefault != null) 864 { 865 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 866 867 if (settings.Path.GetType() != typeof(string)) 868 { 869 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 870 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 871 } 872 else 873 { 874 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 875 } 876 } 877 878 if (settings.ImageSmall != null) 879 { 880 imageSmall = "data-src-small=\"" + imageEngine; 881 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 882 883 if (settings.Path.GetType() != typeof(string)) 884 { 885 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 886 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 887 } 888 else 889 { 890 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 891 } 892 893 imageSmall += "\""; 894 } 895 896 if (settings.ImageMedium != null) 897 { 898 imageMedium = "data-src-medium=\"" + imageEngine; 899 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 900 901 if (settings.Path.GetType() != typeof(string)) 902 { 903 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 904 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 905 } 906 else 907 { 908 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 909 } 910 911 imageMedium += "\""; 912 } 913 } 914 915 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 916 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 917 if (!string.IsNullOrEmpty(settings.Title)) 918 { 919 optionalAttributes.Add("alt", settings.Title); 920 } 921 else 922 { 923 optionalAttributes.Add("alt", ""); 924 } 925 926 if (settings.DisableLazyLoad) 927 { 928 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 929 } 930 else 931 { 932 <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) /> 933 } 934 } 935 } 936 @using System.Reflection 937 @using Dynamicweb.Rapido.Blocks.Components.General 938 @using Dynamicweb.Rapido.Blocks.Components 939 940 @* Component *@ 941 942 @helper RenderFileField(FileField settings) 943 { 944 var attributes = new Dictionary<string, string>(); 945 if (string.IsNullOrEmpty(settings.Id)) 946 { 947 settings.Id = Guid.NewGuid().ToString("N"); 948 } 949 950 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 951 if (settings.Disabled) { attributes.Add("disabled", "true"); } 952 if (settings.Required) { attributes.Add("required", "true"); } 953 if (settings.Multiple) { attributes.Add("multiple", "true"); } 954 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 955 if (string.IsNullOrEmpty(settings.ChooseFileText)) 956 { 957 settings.ChooseFileText = Translate("Choose file"); 958 } 959 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 960 { 961 settings.NoFilesChosenText = Translate("No files chosen..."); 962 } 963 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 964 965 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 966 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 967 968 attributes.Add("type", "file"); 969 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 970 settings.CssClass = "u-full-width " + settings.CssClass; 971 972 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 973 974 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 975 @if (!string.IsNullOrEmpty(settings.Label)) 976 { 977 <label for="@settings.Id">@settings.Label</label> 978 } 979 @if (!string.IsNullOrEmpty(settings.HelpText)) 980 { 981 <small class="form__help-text">@settings.HelpText</small> 982 } 983 984 <div class="form__field-combi file-input u-no-margin dw-mod"> 985 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 986 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 987 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 988 @if (settings.UploadButton != null) 989 { 990 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 991 @Render(settings.UploadButton) 992 } 993 </div> 994 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 995 </div> 996 } 997 @using System.Reflection 998 @using Dynamicweb.Rapido.Blocks.Components.General 999 @using Dynamicweb.Rapido.Blocks.Components 1000 @using Dynamicweb.Core 1001 @using System.Linq 1002 1003 @* Component *@ 1004 1005 @helper RenderDateTimeField(DateTimeField settings) 1006 { 1007 if (string.IsNullOrEmpty(settings.Id)) 1008 { 1009 settings.Id = Guid.NewGuid().ToString("N"); 1010 } 1011 1012 var textField = new TextField { 1013 Name = settings.Name, 1014 Id = settings.Id, 1015 Label = settings.Label, 1016 HelpText = settings.HelpText, 1017 Value = settings.Value, 1018 Disabled = settings.Disabled, 1019 Required = settings.Required, 1020 ErrorMessage = settings.ErrorMessage, 1021 CssClass = settings.CssClass, 1022 WrapperCssClass = settings.WrapperCssClass, 1023 OnChange = settings.OnChange, 1024 OnClick = settings.OnClick, 1025 ExtraAttributes = settings.ExtraAttributes, 1026 // 1027 Placeholder = settings.Placeholder 1028 }; 1029 1030 @Render(textField) 1031 1032 List<string> jsAttributes = new List<string>(); 1033 1034 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1035 1036 if (!string.IsNullOrEmpty(settings.DateFormat)) 1037 { 1038 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1039 } 1040 if (!string.IsNullOrEmpty(settings.MinDate)) 1041 { 1042 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1043 } 1044 if (!string.IsNullOrEmpty(settings.MaxDate)) 1045 { 1046 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1047 } 1048 if (settings.IsInline) 1049 { 1050 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1051 } 1052 if (settings.EnableTime) 1053 { 1054 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1055 } 1056 if (settings.EnableWeekNumbers) 1057 { 1058 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1059 } 1060 1061 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1062 1063 <script> 1064 document.addEventListener("DOMContentLoaded", function () { 1065 flatpickr("#@textField.Id", { 1066 @string.Join(",", jsAttributes) 1067 }); 1068 }); 1069 </script> 1070 } 1071 @using System.Reflection 1072 @using Dynamicweb.Rapido.Blocks.Components.General 1073 @using Dynamicweb.Rapido.Blocks.Components 1074 1075 @* Component *@ 1076 1077 @helper RenderTextField(TextField 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 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1095 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1096 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1097 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1098 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1099 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1100 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1101 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1102 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1103 settings.CssClass = "u-full-width " + settings.CssClass; 1104 1105 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1106 1107 string noMargin = "u-no-margin"; 1108 if (!settings.ReadOnly) { 1109 noMargin = ""; 1110 } 1111 1112 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1113 @if (!string.IsNullOrEmpty(settings.Label)) 1114 { 1115 <label for="@settings.Id">@settings.Label</label> 1116 } 1117 @if (!string.IsNullOrEmpty(settings.HelpText)) 1118 { 1119 <small class="form__help-text">@settings.HelpText</small> 1120 } 1121 1122 @if (settings.ActionButton != null) 1123 { 1124 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1125 <div class="form__field-combi u-no-margin dw-mod"> 1126 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1127 @Render(settings.ActionButton) 1128 </div> 1129 } 1130 else 1131 { 1132 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1133 } 1134 1135 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1136 </div> 1137 } 1138 @using System.Reflection 1139 @using Dynamicweb.Rapido.Blocks.Components.General 1140 @using Dynamicweb.Rapido.Blocks.Components 1141 1142 @* Component *@ 1143 1144 @helper RenderNumberField(NumberField settings) 1145 { 1146 var attributes = new Dictionary<string, string>(); 1147 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1148 { 1149 settings.Id = Guid.NewGuid().ToString("N"); 1150 } 1151 1152 /*base settings*/ 1153 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1154 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1155 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1156 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1157 if (settings.Required) { attributes.Add("required", "true"); } 1158 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1159 /*end*/ 1160 1161 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1162 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1163 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1164 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1165 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1166 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1167 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1168 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1169 attributes.Add("type", "number"); 1170 1171 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1172 1173 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1174 @if (!string.IsNullOrEmpty(settings.Label)) 1175 { 1176 <label for="@settings.Id">@settings.Label</label> 1177 } 1178 @if (!string.IsNullOrEmpty(settings.HelpText)) 1179 { 1180 <small class="form__help-text">@settings.HelpText</small> 1181 } 1182 1183 @if (settings.ActionButton != null) 1184 { 1185 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1186 <div class="form__field-combi u-no-margin dw-mod"> 1187 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1188 @Render(settings.ActionButton) 1189 </div> 1190 } 1191 else 1192 { 1193 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1194 } 1195 1196 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1197 </div> 1198 } 1199 @using System.Reflection 1200 @using Dynamicweb.Rapido.Blocks.Components.General 1201 @using Dynamicweb.Rapido.Blocks.Components 1202 1203 1204 @* Component *@ 1205 1206 @helper RenderTextareaField(TextareaField settings) 1207 { 1208 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1209 string id = settings.Id; 1210 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1211 { 1212 id = Guid.NewGuid().ToString("N"); 1213 } 1214 1215 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1216 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1217 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1218 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1219 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1220 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1221 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1222 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1223 if (settings.Required) { attributes.Add("required", "true"); } 1224 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1225 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1226 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1227 attributes.Add("name", settings.Name); 1228 1229 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1230 @if (!string.IsNullOrEmpty(settings.Label)) 1231 { 1232 <label for="@id">@settings.Label</label> 1233 } 1234 @if (!string.IsNullOrEmpty(settings.HelpText)) 1235 { 1236 <small class="form__help-text">@settings.HelpText</small> 1237 } 1238 1239 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1240 1241 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1242 </div> 1243 } 1244 @using System.Reflection 1245 @using Dynamicweb.Rapido.Blocks.Components.General 1246 @using Dynamicweb.Rapido.Blocks.Components 1247 1248 1249 @* Component *@ 1250 1251 @helper RenderHiddenField(HiddenField settings) { 1252 var attributes = new Dictionary<string, string>(); 1253 attributes.Add("type", "hidden"); 1254 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1255 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1256 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1257 1258 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1259 } 1260 @using System.Reflection 1261 @using Dynamicweb.Rapido.Blocks.Components.General 1262 @using Dynamicweb.Rapido.Blocks.Components 1263 1264 @* Component *@ 1265 1266 @helper RenderCheckboxField(CheckboxField settings) 1267 { 1268 var attributes = new Dictionary<string, string>(); 1269 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1270 { 1271 settings.Id = Guid.NewGuid().ToString("N"); 1272 } 1273 1274 /*base settings*/ 1275 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1276 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1277 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1278 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1279 if (settings.Required) { attributes.Add("required", "true"); } 1280 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1281 /*end*/ 1282 1283 attributes.Add("type", "checkbox"); 1284 if (settings.Checked) { attributes.Add("checked", "true"); } 1285 settings.CssClass = "form__control " + settings.CssClass; 1286 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1287 1288 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1289 1290 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1291 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1292 @if (!string.IsNullOrEmpty(settings.Label)) 1293 { 1294 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1295 } 1296 @if (!string.IsNullOrEmpty(settings.HelpText)) 1297 { 1298 <small class="form__help-text">@settings.HelpText</small> 1299 } 1300 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1301 </div> 1302 } 1303 @using System.Reflection 1304 @using Dynamicweb.Rapido.Blocks.Components.General 1305 @using Dynamicweb.Rapido.Blocks.Components 1306 1307 1308 @* Component *@ 1309 1310 @helper RenderCheckboxListField(CheckboxListField settings) 1311 { 1312 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1313 @if (!string.IsNullOrEmpty(settings.Label)) 1314 { 1315 <label>@settings.Label</label> 1316 } 1317 @if (!string.IsNullOrEmpty(settings.HelpText)) 1318 { 1319 <small class="form__help-text">@settings.HelpText</small> 1320 } 1321 1322 @foreach (var item in settings.Options) 1323 { 1324 if (settings.Required) 1325 { 1326 item.Required = true; 1327 } 1328 if (settings.Disabled) 1329 { 1330 item.Disabled = true; 1331 } 1332 if (!string.IsNullOrEmpty(settings.Name)) 1333 { 1334 item.Name = settings.Name; 1335 } 1336 if (!string.IsNullOrEmpty(settings.CssClass)) 1337 { 1338 item.CssClass += settings.CssClass; 1339 } 1340 1341 /* value is not supported */ 1342 1343 if (!string.IsNullOrEmpty(settings.OnClick)) 1344 { 1345 item.OnClick += settings.OnClick; 1346 } 1347 if (!string.IsNullOrEmpty(settings.OnChange)) 1348 { 1349 item.OnChange += settings.OnChange; 1350 } 1351 @Render(item) 1352 } 1353 1354 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1355 </div> 1356 } 1357 @using System.Reflection 1358 @using Dynamicweb.Rapido.Blocks.Components.General 1359 @using Dynamicweb.Rapido.Blocks.Components 1360 1361 1362 @* Component *@ 1363 1364 @helper RenderSelectField(SelectField settings) 1365 { 1366 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1367 { 1368 settings.Id = Guid.NewGuid().ToString("N"); 1369 } 1370 1371 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1372 @if (!string.IsNullOrEmpty(settings.Label)) 1373 { 1374 <label for="@settings.Id">@settings.Label</label> 1375 } 1376 @if (!string.IsNullOrEmpty(settings.HelpText)) 1377 { 1378 <small class="form__help-text">@settings.HelpText</small> 1379 } 1380 1381 @if (settings.ActionButton != null) 1382 { 1383 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1384 <div class="form__field-combi u-no-margin dw-mod"> 1385 @RenderSelectBase(settings) 1386 @Render(settings.ActionButton) 1387 </div> 1388 } 1389 else 1390 { 1391 @RenderSelectBase(settings) 1392 } 1393 1394 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1395 </div> 1396 } 1397 1398 @helper RenderSelectBase(SelectField settings) 1399 { 1400 var attributes = new Dictionary<string, string>(); 1401 1402 /*base settings*/ 1403 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1404 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1405 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1406 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1407 if (settings.Required) { attributes.Add("required", "true"); } 1408 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1409 /*end*/ 1410 1411 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1412 1413 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1414 @if (settings.Default != null) 1415 { 1416 @Render(settings.Default) 1417 } 1418 1419 @foreach (var item in settings.Options) 1420 { 1421 if (!string.IsNullOrEmpty(settings.Value)) { 1422 item.Checked = item.Value == settings.Value; 1423 } 1424 @Render(item) 1425 } 1426 </select> 1427 } 1428 @using System.Reflection 1429 @using Dynamicweb.Rapido.Blocks.Components.General 1430 @using Dynamicweb.Rapido.Blocks.Components 1431 1432 @* Component *@ 1433 1434 @helper RenderRadioButtonField(RadioButtonField settings) 1435 { 1436 var attributes = new Dictionary<string, string>(); 1437 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1438 { 1439 settings.Id = Guid.NewGuid().ToString("N"); 1440 } 1441 1442 /*base settings*/ 1443 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1444 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1445 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1446 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1447 if (settings.Required) { attributes.Add("required", "true"); } 1448 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1449 /*end*/ 1450 1451 attributes.Add("type", "radio"); 1452 if (settings.Checked) { attributes.Add("checked", "true"); } 1453 settings.CssClass = "form__control " + settings.CssClass; 1454 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1455 1456 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1457 1458 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1459 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1460 @if (!string.IsNullOrEmpty(settings.Label)) 1461 { 1462 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1463 } 1464 @if (!string.IsNullOrEmpty(settings.HelpText)) 1465 { 1466 <small class="form__help-text">@settings.HelpText</small> 1467 } 1468 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1469 </div> 1470 } 1471 @using System.Reflection 1472 @using Dynamicweb.Rapido.Blocks.Components.General 1473 @using Dynamicweb.Rapido.Blocks.Components 1474 1475 1476 @* Component *@ 1477 1478 @helper RenderRadioButtonListField(RadioButtonListField settings) 1479 { 1480 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1481 @if (!string.IsNullOrEmpty(settings.Label)) 1482 { 1483 <label>@settings.Label</label> 1484 } 1485 @if (!string.IsNullOrEmpty(settings.HelpText)) 1486 { 1487 <small class="form__help-text">@settings.HelpText</small> 1488 } 1489 1490 @foreach (var item in settings.Options) 1491 { 1492 if (settings.Required) 1493 { 1494 item.Required = true; 1495 } 1496 if (settings.Disabled) 1497 { 1498 item.Disabled = true; 1499 } 1500 if (!string.IsNullOrEmpty(settings.Name)) 1501 { 1502 item.Name = settings.Name; 1503 } 1504 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1505 { 1506 item.Checked = true; 1507 } 1508 if (!string.IsNullOrEmpty(settings.OnClick)) 1509 { 1510 item.OnClick += settings.OnClick; 1511 } 1512 if (!string.IsNullOrEmpty(settings.OnChange)) 1513 { 1514 item.OnChange += settings.OnChange; 1515 } 1516 if (!string.IsNullOrEmpty(settings.CssClass)) 1517 { 1518 item.CssClass += settings.CssClass; 1519 } 1520 @Render(item) 1521 } 1522 1523 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1524 </div> 1525 } 1526 @using System.Reflection 1527 @using Dynamicweb.Rapido.Blocks.Components.General 1528 @using Dynamicweb.Rapido.Blocks.Components 1529 1530 1531 @* Component *@ 1532 1533 @helper RenderNotificationMessage(NotificationMessage settings) 1534 { 1535 if (!string.IsNullOrEmpty(settings.Message)) 1536 { 1537 var attributes = new Dictionary<string, string>(); 1538 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1539 1540 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1541 <div class="[email protected] @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1542 } 1543 } 1544 @using Dynamicweb.Rapido.Blocks.Components.General 1545 1546 1547 @* Component *@ 1548 1549 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1550 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1551 1552 <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> 1553 @if (settings.SubBlocks != null) { 1554 @RenderBlockList(settings.SubBlocks) 1555 } 1556 </div> 1557 } 1558 @using System.Reflection 1559 @using Dynamicweb.Rapido.Blocks.Components.General 1560 @using Dynamicweb.Rapido.Blocks.Components 1561 @using System.Text.RegularExpressions 1562 1563 1564 @* Component *@ 1565 1566 @helper RenderSticker(Sticker settings) { 1567 if (!String.IsNullOrEmpty(settings.Title)) { 1568 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1569 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1570 1571 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1572 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1573 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1574 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1575 optionalAttributes.Add("style", styleTag); 1576 } 1577 1578 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1579 } 1580 } 1581 1582 @using System.Reflection 1583 @using Dynamicweb.Rapido.Blocks.Components.General 1584 @using Dynamicweb.Rapido.Blocks.Components 1585 1586 1587 @* Component *@ 1588 1589 @helper RenderStickersCollection(StickersCollection settings) 1590 { 1591 if (settings.Stickers.Count > 0) 1592 { 1593 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1594 1595 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1596 @foreach (Sticker sticker in settings.Stickers) 1597 { 1598 @Render(sticker) 1599 } 1600 </div> 1601 } 1602 } 1603 1604 @using Dynamicweb.Rapido.Blocks.Components.General 1605 1606 1607 @* Component *@ 1608 1609 @helper RenderForm(Form settings) { 1610 if (settings != null) 1611 { 1612 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1613 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1614 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1615 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1616 var enctypes = new Dictionary<string, string> 1617 { 1618 { "multipart", "multipart/form-data" }, 1619 { "text", "text/plain" }, 1620 { "application", "application/x-www-form-urlencoded" } 1621 }; 1622 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1623 optionalAttributes.Add("method", settings.Method.ToString()); 1624 1625 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1626 { 1627 @settings.FormStartMarkup 1628 } 1629 else 1630 { 1631 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1632 } 1633 1634 foreach (var field in settings.GetFields()) 1635 { 1636 @Render(field) 1637 } 1638 1639 @:</form> 1640 } 1641 } 1642 @using System.Reflection 1643 @using Dynamicweb.Rapido.Blocks.Components.General 1644 @using Dynamicweb.Rapido.Blocks.Components 1645 1646 1647 @* Component *@ 1648 1649 @helper RenderText(Text settings) 1650 { 1651 @settings.Content 1652 } 1653 @using System.Reflection 1654 @using Dynamicweb.Rapido.Blocks.Components.General 1655 @using Dynamicweb.Rapido.Blocks.Components 1656 1657 1658 @* Component *@ 1659 1660 @helper RenderContentModule(ContentModule settings) { 1661 if (!string.IsNullOrEmpty(settings.Content)) 1662 { 1663 @settings.Content 1664 } 1665 } 1666 @using System.Reflection 1667 @using Dynamicweb.Rapido.Blocks.Components.General 1668 @using Dynamicweb.Rapido.Blocks.Components 1669 1670 1671 @* Component *@ 1672 1673 @helper RenderModal(Modal settings) { 1674 if (settings != null) 1675 { 1676 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1677 1678 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1679 1680 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1681 1682 <div class="modal-container"> 1683 @if (!settings.DisableDarkOverlay) 1684 { 1685 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1686 } 1687 <div class="modal [email protected]().ToLower() [email protected]().ToLower()" id="@(modalId)Modal"> 1688 @if (settings.Heading != null) 1689 { 1690 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1691 { 1692 <div class="modal__header"> 1693 @Render(settings.Heading) 1694 </div> 1695 } 1696 } 1697 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1698 @if (!string.IsNullOrEmpty(settings.BodyText)) 1699 { 1700 @settings.BodyText 1701 } 1702 @if (settings.BodyTemplate != null) 1703 { 1704 @settings.BodyTemplate 1705 } 1706 @{ 1707 var actions = settings.GetActions(); 1708 } 1709 </div> 1710 @if (actions.Length > 0) 1711 { 1712 <div class="modal__footer"> 1713 @foreach (var action in actions) 1714 { 1715 action.CssClass += " u-no-margin"; 1716 @Render(action) 1717 } 1718 </div> 1719 } 1720 <label class="modal__close-btn" for="@(modalId)ModalTrigger" tabindex="0" onkeypress="fakeClickWithEnterKey(event, this)"></label> 1721 </div> 1722 </div> 1723 } 1724 } 1725 @using Dynamicweb.Rapido.Blocks.Components.General 1726 1727 @* Component *@ 1728 1729 @helper RenderMediaListItem(MediaListItem settings) 1730 { 1731 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1732 @if (!string.IsNullOrEmpty(settings.Label)) 1733 { 1734 if (!string.IsNullOrEmpty(settings.Link)) 1735 { 1736 @Render(new Link 1737 { 1738 Href = settings.Link, 1739 CssClass = "media-list-item__sticker dw-mod", 1740 ButtonLayout = ButtonLayout.None, 1741 Title = settings.Label, 1742 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1743 }) 1744 } 1745 else if (!string.IsNullOrEmpty(settings.OnClick)) 1746 { 1747 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1748 <span class="u-uppercase">@settings.Label</span> 1749 </span> 1750 } 1751 else 1752 { 1753 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1754 <span class="u-uppercase">@settings.Label</span> 1755 </span> 1756 } 1757 } 1758 <div class="media-list-item__wrap"> 1759 <div class="media-list-item__info dw-mod"> 1760 <div class="media-list-item__header dw-mod"> 1761 @if (!string.IsNullOrEmpty(settings.Title)) 1762 { 1763 if (!string.IsNullOrEmpty(settings.Link)) 1764 { 1765 @Render(new Link 1766 { 1767 Href = settings.Link, 1768 CssClass = "media-list-item__name dw-mod", 1769 ButtonLayout = ButtonLayout.None, 1770 Title = settings.Title, 1771 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1772 }) 1773 } 1774 else if (!string.IsNullOrEmpty(settings.OnClick)) 1775 { 1776 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1777 } 1778 else 1779 { 1780 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1781 } 1782 } 1783 1784 @if (!string.IsNullOrEmpty(settings.Status)) 1785 { 1786 <div class="media-list-item__state dw-mod">@settings.Status</div> 1787 } 1788 </div> 1789 @{ 1790 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1791 } 1792 1793 @Render(settings.InfoTable) 1794 </div> 1795 <div class="media-list-item__actions dw-mod"> 1796 <div class="media-list-item__actions-list dw-mod"> 1797 @{ 1798 var actions = settings.GetActions(); 1799 1800 foreach (ButtonBase action in actions) 1801 { 1802 action.ButtonLayout = ButtonLayout.None; 1803 action.CssClass += " media-list-item__action link"; 1804 1805 @Render(action) 1806 } 1807 } 1808 </div> 1809 1810 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1811 { 1812 settings.SelectButton.CssClass += " u-no-margin"; 1813 1814 <div class="media-list-item__action-button"> 1815 @Render(settings.SelectButton) 1816 </div> 1817 } 1818 </div> 1819 </div> 1820 </div> 1821 } 1822 @using Dynamicweb.Rapido.Blocks.Components.General 1823 @using Dynamicweb.Rapido.Blocks.Components 1824 1825 @helper RenderTable(Table settings) 1826 { 1827 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1828 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1829 1830 var enumToClasses = new Dictionary<TableDesign, string> 1831 { 1832 { TableDesign.Clean, "table--clean" }, 1833 { TableDesign.Bordered, "table--bordered" }, 1834 { TableDesign.Striped, "table--striped" }, 1835 { TableDesign.Hover, "table--hover" }, 1836 { TableDesign.Compact, "table--compact" }, 1837 { TableDesign.Condensed, "table--condensed" }, 1838 { TableDesign.NoTopBorder, "table--no-top-border" } 1839 }; 1840 string tableDesignClass = ""; 1841 if (settings.Design != TableDesign.None) 1842 { 1843 tableDesignClass = enumToClasses[settings.Design]; 1844 } 1845 1846 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1847 1848 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1849 1850 <table @ComponentMethods.AddAttributes(resultAttributes)> 1851 @if (settings.Header != null) 1852 { 1853 <thead> 1854 @Render(settings.Header) 1855 </thead> 1856 } 1857 <tbody> 1858 @foreach (var row in settings.Rows) 1859 { 1860 @Render(row) 1861 } 1862 </tbody> 1863 @if (settings.Footer != null) 1864 { 1865 <tfoot> 1866 @Render(settings.Footer) 1867 </tfoot> 1868 } 1869 </table> 1870 } 1871 @using Dynamicweb.Rapido.Blocks.Components.General 1872 @using Dynamicweb.Rapido.Blocks.Components 1873 1874 @helper RenderTableRow(TableRow settings) 1875 { 1876 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1877 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1878 1879 var enumToClasses = new Dictionary<TableRowDesign, string> 1880 { 1881 { TableRowDesign.NoBorder, "table__row--no-border" }, 1882 { TableRowDesign.Border, "table__row--border" }, 1883 { TableRowDesign.TopBorder, "table__row--top-line" }, 1884 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1885 { TableRowDesign.Solid, "table__row--solid" } 1886 }; 1887 1888 string tableRowDesignClass = ""; 1889 if (settings.Design != TableRowDesign.None) 1890 { 1891 tableRowDesignClass = enumToClasses[settings.Design]; 1892 } 1893 1894 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1895 1896 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1897 1898 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1899 @foreach (var cell in settings.Cells) 1900 { 1901 if (settings.IsHeaderRow) 1902 { 1903 cell.IsHeader = true; 1904 } 1905 @Render(cell) 1906 } 1907 </tr> 1908 } 1909 @using Dynamicweb.Rapido.Blocks.Components.General 1910 @using Dynamicweb.Rapido.Blocks.Components 1911 @using Dynamicweb.Core 1912 1913 @helper RenderTableCell(TableCell settings) 1914 { 1915 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1916 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1917 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1918 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1919 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1920 1921 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1922 1923 string tagName = settings.IsHeader ? "th" : "td"; 1924 1925 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1926 @settings.Content 1927 @("</" + tagName + ">"); 1928 } 1929 @using System.Linq 1930 @using Dynamicweb.Rapido.Blocks.Components.General 1931 1932 @* Component *@ 1933 1934 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1935 { 1936 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1937 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1938 1939 if (settings.NumberOfPages > 1) 1940 { 1941 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1942 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Pagination"); 1943 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1944 1945 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1946 @if (settings.ShowPagingInfo) 1947 { 1948 <div class="pager__info dw-mod"> 1949 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1950 </div> 1951 } 1952 <ul class="pager__list dw-mod" role="navigation" aria-label='@Translate("Pagination")'> 1953 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1954 { 1955 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1956 } 1957 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1958 { 1959 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon, HelperName = "Prev"}) 1960 } 1961 @if (settings.GetPages().Any()) 1962 { 1963 foreach (var page in settings.GetPages()) 1964 { 1965 @Render(page) 1966 } 1967 } 1968 else 1969 { 1970 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1971 { 1972 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1973 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1974 } 1975 } 1976 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1977 { 1978 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon, HelperName = "Next" }) 1979 } 1980 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1981 { 1982 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1983 } 1984 </ul> 1985 </div> 1986 } 1987 } 1988 1989 @helper RenderPaginationItem(PaginationItem settings) 1990 { 1991 var ariaLabel = settings.HelperName == "Prev" ? Translate("Go to Previous page") : settings.HelperName == "Next" ? Translate("Go to Next page") : $"{Translate("Go to page")} {settings.Label}"; 1992 1993 if (settings.Icon == null) 1994 { 1995 settings.Icon = new Icon(); 1996 } 1997 1998 settings.Icon.Label = settings.Label; 1999 <li class="pager__btn dw-mod"> 2000 @if (settings.IsActive) 2001 { 2002 <span class="pager__num pager__num--current dw-mod"> 2003 <span class="u-sr-only">@Translate("Current page")</span> 2004 @Render(settings.Icon) 2005 </span> 2006 } 2007 else 2008 { 2009 <a href="@settings.Link" class="pager__num dw-mod" aria-label="@ariaLabel"> 2010 @Render(settings.Icon) 2011 </a> 2012 } 2013 </li> 2014 } 2015 2016 2017 @using System 2018 @using Dynamicweb.Rapido.Blocks.Components.General 2019 @using Dynamicweb.Rapido.Blocks.Components.Articles 2020 2021 2022 2023 @helper RenderArticleBannerCustom(ArticleHeader settings) { 2024 string filterClasses = "image-filter image-filter--darken"; 2025 settings.Layout = ArticleHeaderLayout.Banner; 2026 2027 if (settings.Image != null) 2028 { 2029 if (settings.Image.Path != null) 2030 { 2031 <section class="multiple-paragraphs-container u-color-light paragraph-container--full-width"> 2032 <div class="background-image @filterClasses dw-mod"> 2033 <div class="background-image__wrapper @filterClasses dw-mod"> 2034 @{ 2035 settings.Image.CssClass += "background-image__cover dw-mod"; 2036 } 2037 @Render(settings.Image) 2038 </div> 2039 </div> 2040 <div class="center-container dw-mod"> 2041 <div class="grid"> 2042 <div class="grid__col-md-8 grid__col-xs-12 paragraph-container paragraph-container--height-lg"> 2043 <div class="u-left-middle"> 2044 <div> 2045 <div class="article--date--and--category u-flex grid--align-center grid--justify-center"> 2046 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2047 { 2048 <div class="article__post-info dw-mod item" style="color: @settings.TextColor">@settings.Author @settings.Date</div> 2049 } 2050 @if (!String.IsNullOrEmpty(settings.Category)) 2051 { 2052 <div class="item"> 2053 <div class="article__category dw-mod">@settings.Category</div> 2054 </div> 2055 } 2056 </div> 2057 @if (!String.IsNullOrEmpty(settings.Heading)) 2058 { 2059 <h1 class="article__header article__header--giant dw-mod" style="color: @settings.TextColor">@settings.Heading</h1> 2060 } 2061 @if (!String.IsNullOrEmpty(settings.Subheading)) 2062 { 2063 <div class="article__leadtext dw-mod" style="color: @settings.TextColor">@settings.Subheading</div> 2064 } 2065 @if (!String.IsNullOrEmpty(settings.Link)) 2066 { 2067 <small class="article__post-info u-margin-bottom--lg dw-mod" style="color: @settings.TextColor">@settings.Author @settings.Date</small> 2068 } 2069 @if (!String.IsNullOrEmpty(settings.Link)) { 2070 <div class="grid__cell"> 2071 @Render(new Link {Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout}) 2072 </div> 2073 } 2074 </div> 2075 </div> 2076 </div> 2077 @if (settings.ExternalParagraphId != 0) 2078 { 2079 <div class="grid__col-md-4 grid__col-sm-12 grid__col-xs-12 paragraph-container paragraph-container--height-auto dw-mod"> 2080 <div class="u-color-light-gray--bg u-color-dark dw-mod"> 2081 @RenderParagraphContent(settings.ExternalParagraphId) 2082 </div> 2083 </div> 2084 } 2085 2086 </div> 2087 </div> 2088 </section> 2089 if (!String.IsNullOrEmpty(settings.Image.Caption)) { 2090 <div class="image-caption dw-mod">@settings.Image.Caption</div> 2091 } 2092 } 2093 else 2094 { 2095 settings.Layout = ArticleHeaderLayout.Clean; 2096 @RenderArticleCleanHeaderCustom(settings); 2097 } 2098 } 2099 else 2100 { 2101 settings.Layout = ArticleHeaderLayout.Clean; 2102 @RenderArticleCleanHeaderCustom(settings); 2103 } 2104 } 2105 2106 @helper RenderArticleCleanHeaderCustom(ArticleHeader settings) { 2107 string contentColumns = settings.TextLayout != ArticleHeaderTextLayout.Full ? "8" : "12"; 2108 2109 <div class="grid grid--align-content-start grid--justify-start"> 2110 <div class="[email protected] grid__col-sm-12 u-padding--lg dw-mod"> 2111 @if (!String.IsNullOrEmpty(settings.Category) || !String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date) || settings.RatingOutOf != 0) 2112 { 2113 <div class="article--date--and--category u-flex grid--align-center grid--justify-center"> 2114 @if (!String.IsNullOrEmpty(settings.Author) || !String.IsNullOrEmpty(settings.Date)) 2115 { 2116 <div class="article__post-info dw-mod item" style="color: @settings.TextColor">@settings.Author @settings.Date</div> 2117 } 2118 @if (!String.IsNullOrEmpty(settings.Category)) 2119 { 2120 <div class="item"> 2121 <div class="article__category dw-mod">@settings.Category</div> 2122 </div> 2123 } 2124 </div> 2125 } 2126 2127 <div class="grid__cell"> 2128 @if (!String.IsNullOrEmpty(settings.Heading)) 2129 { 2130 <h1 class="article__header article__header--giant dw-mod">@settings.Heading</h1> 2131 } 2132 @if (settings.Image != null) 2133 { 2134 if (settings.Image.Path != null) 2135 { 2136 <div class="u-padding-bottom--lg"> 2137 @Render(settings.Image) 2138 </div> 2139 } 2140 } 2141 @if (!String.IsNullOrEmpty(settings.Subheading)) 2142 { 2143 <div class="article__leadtext dw-mod">@settings.Subheading</div> 2144 } 2145 @if (!String.IsNullOrEmpty(settings.Link)) 2146 { 2147 <div class="grid__cell"> 2148 @Render(new Link { Href = settings.Link, Title = settings.LinkText, ButtonLayout = settings.ButtonLayout }) 2149 </div> 2150 } 2151 </div> 2152 </div> 2153 @if (settings.ExternalParagraphId != 0) 2154 { 2155 <div class="grid__col-md-4 grid__col-sm-12 u-padding--lg u-color-light-gray--bg dw-mod"> 2156 @RenderParagraphContent(settings.ExternalParagraphId) 2157 </div> 2158 } 2159 </div> 2160 } 2161 2162 2163 2164 @foreach (LoopItem country in GetLoop("Countries")) 2165 { 2166 <div class="country u-hidden" country-name="@country.GetString("Ecom:Country.Name")" country-code="@country.GetString("Ecom:Country.Code2")"> 2167 @foreach (LoopItem region in country.GetLoop("Regions")) 2168 { 2169 <span class="region" region-name="@region.GetString("Ecom:Region.Name")" region-code="@region.GetString("Ecom:Region.RegionCode")"></span> 2170 } 2171 </div> 2172 } 2173 2174 @helper RenderCustomerAddress() { 2175 var _countriesLoop = GetLoop("Countries"); 2176 var _customerRegionsLoop = GetLoop("CustomerRegions"); 2177 var firstRegion = _customerRegionsLoop.First().GetString("Ecom:CustomerRegion.Name"); 2178 <div class="card-header u-color-light--bg dw-mod"> 2179 <h3>@Translate("Customer Information")</h3> 2180 </div> 2181 2182 <div class="card u-color-light--bg dw-mod customer-info-wrapper" data-error="@Translate("One or more customer information fields are missing value")" data-phone-length="@Translate("Phone number should have at least 10 digits")" data-invalid-email="@Translate("Invalid email")"> 2183 @if (!Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")) || GetLoop("ValidationErrors").Any()) 2184 { 2185 <div class="form__field-group dw-mod"> 2186 @Render(new TextField 2187 { 2188 Label = Translate("Name"), 2189 Id = "EcomOrderDeliveryName", 2190 Name = "EcomOrderDeliveryName", 2191 Value = GetString("Ecom:Order.Delivery.Name"), 2192 Required = true, 2193 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage"), 2194 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage")) ? "error-field" : "" 2195 }) 2196 </div> 2197 @* used First() because there will always be only one orderline in the cart *@ 2198 var isMembershipRenewal = GetLoop("OrderLines").First().GetBoolean("Ecom:Product:Field.IsMemberShipRenewal"); 2199 if (isMembershipRenewal) 2200 { 2201 <div class="form__field-group dw-mod"> 2202 @Render(new TextField 2203 { 2204 Label = Translate("WIT Number"), 2205 Id = "WITNumber", 2206 Name = "WITNumber", 2207 Value = GetString("WITNumber.Clean"), 2208 ErrorMessage = GetString("Ecom:Cart.ValidationError.WITNumber.ErrorMessage"), 2209 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.WITNumber.ErrorMessage")) ? "error-field" : "" 2210 }) 2211 </div> 2212 } 2213 2214 <div class="form__field-group dw-mod"> 2215 @Render(new TextField 2216 { 2217 Label = Translate("RV Serial Number or VIN"), 2218 Id = "RVSerialNumber", 2219 Name = "RVSerialNumber", 2220 Value = GetString("RVSerialNumber.Clean"), 2221 Required = true, 2222 ErrorMessage = GetString("Ecom:Cart.ValidationError.RVSerialNumber.ErrorMessage"), 2223 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.RVSerialNumber.ErrorMessage")) ? "error-field" : "", 2224 ExtraAttributes = new Dictionary<string, string> {{"maxlength", "17" }} 2225 }) 2226 <p class="font-size-075em u-margin-bottom">(@Translate("Motorized Vehicles begin with 10, 15, 70, or 80 and have 11 or 12 digits").)</p> 2227 <p class="font-size-075em">(@Translate("Towables can have up to 17 digits").)</p> 2228 </div> 2229 2230 <div class="form__fields-collection form__fields-collection--3-3"> 2231 <div class="form__field-group dw-mod"> 2232 @if (GetBoolean("Ecom:Cart.CreateUserInCheckout") && string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 2233 { 2234 @Render(new TextField 2235 { 2236 Label = Translate("Email"), 2237 Id = "EcomOrderDeliveryEmail", 2238 Name = "EcomOrderDeliveryEmail", 2239 Value = GetString("Ecom:Order.Delivery.Email"), 2240 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage"), 2241 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage")) ? "error-field u-full-width" : "u-full-width", 2242 ExtraAttributes = new Dictionary<string, string> {{ "onchange", "document.getElementById('EcomUserCreateUserName').value = this.value;" }} 2243 }) 2244 @Render(new HiddenField {Id = "EcomUserCreateUserName" , Value = @GetString("Ecom:Order.Customer.Email")}) 2245 @Render(new HiddenField {Id = "EcomUserCreateNew" , Value = "True"}) 2246 string pass = Guid.NewGuid().ToString(); 2247 @Render(new HiddenField {Id = "EcomUserCreatePassword" , Value = @pass}) 2248 @Render(new HiddenField {Id = "EcomUserCreateConfirmPassword" , Value = @pass}) 2249 } 2250 else 2251 { 2252 @Render(new TextField 2253 { 2254 Label = Translate("Email"), 2255 Id = "EcomOrderDeliveryEmail", 2256 Name = "EcomOrderDeliveryEmail", 2257 Value = GetString("Ecom:Order.Delivery.Email"), 2258 Required = true, 2259 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage"), 2260 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage")) ? "error-field u-full-width" : "u-full-width" 2261 }) 2262 2263 } 2264 </div> 2265 2266 <div class="form__field-group dw-mod"> 2267 @Render(new TextField 2268 { 2269 Label = Translate("Cell Phone"), 2270 Id = "EcomOrderDeliveryPhone", 2271 Name = "EcomOrderDeliveryPhone", 2272 Value = GetString("Ecom:Order.Delivery.Phone"), 2273 Required = true, 2274 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage"), 2275 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage")) ? "error-field" : "" 2276 }) 2277 </div> 2278 </div> 2279 2280 <div class="form__fields-collection form__fields-collection--3-2"> 2281 <div class="form__field-group dw-mod"> 2282 @Render(new TextField 2283 { 2284 Label = Translate("Home Address"), 2285 Id = "EcomOrderDeliveryAddress", 2286 Name = "EcomOrderDeliveryAddress", 2287 Value = GetString("Ecom:Order.Delivery.Address"), 2288 Required = true, 2289 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage"), 2290 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage")) ? "error-field" : "" 2291 }) 2292 </div> 2293 2294 <div class="form__field-group dw-mod"> 2295 @Render(new TextField 2296 { 2297 Label = Translate("Apt/Suite"), 2298 Id = "Apt", 2299 Name = "Apt", 2300 Value = GetString("Apt.Clean"), 2301 ErrorMessage = GetString("Ecom:Cart.ValidationError.Apt.ErrorMessage"), 2302 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.Apt.ErrorMessage")) ? "error-field" : "" 2303 }) 2304 </div> 2305 </div> 2306 2307 2308 <div class="form__fields-collection form__fields-collection--3-2"> 2309 <div class="form__field-group dw-mod"> 2310 @{ 2311 var EcomOrderDeliveryCountry = new SelectField 2312 { 2313 Id = "EcomOrderDeliveryCountry", 2314 Name = "EcomOrderDeliveryCountry", 2315 Label = Translate("Country"), 2316 OnChange = "countryChangeHandler(event)", 2317 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCountry.ErrorMessage"), 2318 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCountry.ErrorMessage")) ? "error-field" : "custom-select u-hidden", 2319 ExtraAttributes = new Dictionary<string, string> {{ "name", "EcomOrderDeliveryCountry" }} 2320 }; 2321 2322 foreach (LoopItem country2 in _countriesLoop) 2323 { 2324 2325 bool selected = GetString("Ecom:Order.Customer.Country.Code") == country2.GetString("Ecom:Country.Code2"); 2326 if (selected) 2327 { 2328 EcomOrderDeliveryCountry.Options.Add(new SelectFieldOption {ExtraAttributes = new Dictionary<string, string> {{ "selected", "true" }} , Label = country2.GetString("Ecom:Country.Name"), Value = country2.GetString("Ecom:Country.Code2")}); 2329 } 2330 else 2331 { 2332 EcomOrderDeliveryCountry.Options.Add(new SelectFieldOption {Label = country2.GetString("Ecom:Country.Name"), Value = country2.GetString("Ecom:Country.Code2")}); 2333 } 2334 2335 2336 } 2337 } 2338 @Render(EcomOrderDeliveryCountry) 2339 </div> 2340 2341 <div class="form__field-group dw-mod"> 2342 @Render(new TextField 2343 { 2344 Label = Translate("City"), 2345 Id = "EcomOrderDeliveryCity", 2346 Name = "EcomOrderDeliveryCity", 2347 Value = GetString("Ecom:Order.Delivery.City"), 2348 Required = true, 2349 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage"), 2350 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage")) ? "error-field" : "" 2351 }) 2352 </div> 2353 2354 <div class="form__field-group dw-mod"> 2355 2356 @{ 2357 var EcomDeliveryRegionSelect = new SelectField 2358 { 2359 Id = "EcomOrderDeliveryRegion", 2360 Name = "EcomOrderDeliveryRegion", 2361 Label = Translate("State/Region"), 2362 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryRegion.ErrorMessage"), 2363 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryRegion.ErrorMessage")) ? "error-field" : "custom-select u-hidden", 2364 ExtraAttributes = new Dictionary<string, string> {{"name", "EcomOrderDeliveryRegion"}} 2365 }; 2366 2367 foreach (LoopItem state in _customerRegionsLoop) 2368 { 2369 EcomDeliveryRegionSelect.Options.Add(new SelectFieldOption {Label = state.GetString("Ecom:CustomerRegion.Name"), Value = state.GetString("Ecom:CustomerRegion.Name")}); 2370 } 2371 } 2372 2373 2374 @Render(EcomDeliveryRegionSelect) 2375 </div> 2376 2377 <div class="form__field-group dw-mod"> 2378 @Render(new TextField 2379 { 2380 Label = Translate("Zip"), 2381 Id = "EcomOrderDeliveryZip", 2382 Name = "EcomOrderDeliveryZip", 2383 Value = GetString("Ecom:Order.Delivery.Zip"), 2384 Required = true, 2385 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage"), 2386 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage")) ? "error-field" : "" 2387 }) 2388 </div> 2389 </div> 2390 } 2391 else 2392 { 2393 var customerRegionsLoop = GetLoop("CustomerRegions"); 2394 var countriesLoop = GetLoop("Countries"); 2395 var selectedStateName = ""; 2396 if (customerRegionsLoop.Any()) 2397 { 2398 2399 foreach (LoopItem state in customerRegionsLoop) 2400 { 2401 if (GetString("Ecom:Order.Customer.Region") == state.GetString("Ecom:CustomerRegion.Name")) { 2402 selectedStateName = state.GetString("Ecom:CustomerRegion.Name"); 2403 } 2404 } 2405 } 2406 2407 //When the user is signed in, show static address fields 2408 @Render(new Table { 2409 Design = TableDesign.Clean, 2410 CssClass = "table--compact", 2411 Rows = new List<TableRow> { 2412 new TableRow ( 2413 new TableCell { Content = Translate("Company")}, 2414 new TableCell { Content = Converter.ToString(Render(new TextField 2415 { 2416 CssClass = "u-full-width u-truncate-text", 2417 Name = "EcomOrderCustomerCompany", 2418 Id = "EcomOrderCustomerCompany", 2419 Value = GetString("Ecom:Order.Customer.Company"), 2420 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2421 }))} 2422 ), 2423 new TableRow ( 2424 new TableCell { Content = Translate("Name") }, 2425 new TableCell { Content = Converter.ToString(Render(new TextField 2426 { 2427 CssClass = "u-full-width u-truncate-text", 2428 Name = "EcomOrderCustomerName", 2429 Id = "EcomOrderCustomerName", 2430 Value = GetString("Ecom:Order.Customer.Name"), 2431 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2432 })) } 2433 ), 2434 new TableRow ( 2435 new TableCell { Content = Translate("Phone") }, 2436 new TableCell { Content = Converter.ToString(Render(new TextField 2437 { 2438 CssClass = "u-full-width u-truncate-text", 2439 Name = "EcomOrderCustomerPhone", 2440 Id = "EcomOrderCustomerPhone", 2441 Value = GetString("Ecom:Order.Customer.Phone"), 2442 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2443 })) } 2444 ), 2445 new TableRow ( 2446 new TableCell { Content = Translate("Email") }, 2447 new TableCell { Content = Converter.ToString(Render(new TextField 2448 { 2449 CssClass = "u-full-width u-truncate-text", 2450 Name = "EcomOrderCustomerEmail", 2451 Id = "EcomOrderCustomerEmail", 2452 Value = GetString("Ecom:Order.Customer.Email"), 2453 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2454 })) } 2455 ), 2456 new TableRow ( 2457 new TableCell { Content = Translate("Address")}, 2458 new TableCell { Content = Converter.ToString(Render(new TextField 2459 { 2460 CssClass = "u-full-width u-truncate-text", 2461 Name = "EcomOrderCustomerAddress", 2462 Id = "EcomOrderCustomerAddress", 2463 Value = GetString("Ecom:Order.Customer.Address"), 2464 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2465 })) } 2466 ), 2467 new TableRow ( 2468 new TableCell { Content = Translate("Zip code")}, 2469 new TableCell { Content = Converter.ToString(Render(new TextField 2470 { 2471 CssClass = "u-full-width u-truncate-text", 2472 Name = "EcomOrderCustomerZip", 2473 Id = "EcomOrderCustomerZip", 2474 Value = GetString("Ecom:Order.Customer.Zip"), 2475 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2476 })) } 2477 ), 2478 new TableRow ( 2479 new TableCell { Content = Translate("City")}, 2480 new TableCell { Content = Converter.ToString(Render(new TextField 2481 { 2482 CssClass = "u-full-width u-truncate-text", 2483 Name = "EcomOrderCustomerCity", 2484 Id = "EcomOrderCustomerCity", 2485 Value = GetString("Ecom:Order.Customer.City"), 2486 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2487 }))} 2488 ), 2489 new TableRow ( 2490 new TableCell { Content = Translate("State/Region")}, 2491 new TableCell { Content = Converter.ToString(Render(new TextField 2492 { 2493 CssClass = "u-full-width u-truncate-text", 2494 Name = "EcomOrderCustomerRegion", 2495 Id = "EcomOrderCustomerRegion", 2496 Value = selectedStateName, 2497 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2498 }))} 2499 ), 2500 new TableRow ( 2501 new TableCell { Content = Translate("Country")}, 2502 new TableCell { Content = Converter.ToString(Render(new TextField 2503 { 2504 CssClass = "u-full-width u-truncate-text", 2505 Name = "EcomOrderCustomerCountry", 2506 Id = "EcomOrderCustomerCountry", 2507 Value = GetString("Ecom:Order.Customer.Country"), 2508 ExtraAttributes = new Dictionary<string, string> {{"readonly", "true"}} 2509 }))} 2510 ), 2511 } 2512 }); 2513 } 2514 </div> 2515 } 2516 2517 @helper RenderNextButtonCustom() 2518 { 2519 <div class="u-pull--right"> 2520 @Render(new Button 2521 { 2522 ButtonType = ButtonType.Submit, 2523 ButtonLayout = ButtonLayout.Primary, 2524 CssClass = "u-no-margin u-pull--right", 2525 Name = GetString("CartV2.NextStepButtonName"), 2526 Title = Translate("Next"), 2527 Id = GetString("CartV2.NextStepButtonName") 2528 }) 2529 </div> 2530 } 2531 2532 2533 @helper RenderBillingAddressCustom() 2534 { 2535 var _countriesLoop2 = GetLoop("Countries"); 2536 var _customerRegionsLoop2 = GetLoop("CustomerRegions"); 2537 var firstRegion2 = _customerRegionsLoop2.First().GetString("Ecom:CustomerRegion.Name"); 2538 <div class="card-header u-color-light--bg dw-mod"> 2539 <h3>@Translate("Billing Address")</h3> 2540 </div> 2541 <div class="card u-color-light--bg dw-mod billing-address-area" data-error="@Translate("One or more billing information fields are missing value")"> 2542 2543 2544 <div class="form__field-group dw-mod"> 2545 @Render(new CheckboxField 2546 { 2547 Label = Translate("Billing address is the same as home address"), 2548 Checked = true, 2549 CssClass = "billing-same-as-home-address" 2550 }) 2551 </div> 2552 2553 <div class="billing-address-wrapper u-hidden"> 2554 <div class="form__fields-collection form__fields-collection--3-2"> 2555 <div class="form__field-group dw-mod u-hidden"> 2556 @Render(new HiddenField 2557 { 2558 Id = "EcomOrderCustomerEmail", 2559 Name = "EcomOrderCustomerEmail", 2560 Value = GetString("Ecom:Order.Customer.Email") 2561 }) 2562 </div> 2563 2564 <div class="form__field-group dw-mod u-hidden"> 2565 @Render(new HiddenField 2566 { 2567 Id = "EcomOrderCustomerPhone", 2568 Name = "EcomOrderCustomerPhone", 2569 Value = GetString("Ecom:Order.Customer.Phone") 2570 }) 2571 </div> 2572 2573 <div class="form__field-group dw-mod"> 2574 @Render(new TextField 2575 { 2576 Label = Translate("Address"), 2577 Id = "EcomOrderCustomerAddress", 2578 Name = "EcomOrderCustomerAddress", 2579 Value = GetString("Ecom:Order.Customer.Address"), 2580 Required = true, 2581 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage"), 2582 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage")) ? "error-field" : "" 2583 }) 2584 </div> 2585 2586 <div class="form__field-group dw-mod"> 2587 @Render(new TextField 2588 { 2589 Label = Translate("Apt/Suite"), 2590 Id = "AptCustomer", 2591 Name = "AptCustomer", 2592 Value = GetString("AptCustomer.Clean"), 2593 ErrorMessage = GetString("Ecom:Cart.ValidationError.AptCustomer.ErrorMessage"), 2594 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.AptCustomer.ErrorMessage")) ? "error-field" : "" 2595 }) 2596 </div> 2597 </div> 2598 2599 <div class="form__fields-collection form__fields-collection--3-2"> 2600 <div class="form__field-group dw-mod"> 2601 @{ 2602 var EcomOrderCustomerCountry = new SelectField 2603 { 2604 Id = "EcomOrderCustomerCountry", 2605 Name = "EcomOrderCustomerCountry", 2606 Label = Translate("Country"), 2607 OnChange = "countryChangeHandler(event)", 2608 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCountry.ErrorMessage"), 2609 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCountry.ErrorMessage")) ? "error-field" : "custom-select u-hidden", 2610 ExtraAttributes = new Dictionary<string, string> {{ "name", "EcomOrderCustomerCountry" }} 2611 }; 2612 2613 foreach (LoopItem country2 in GetLoop("Countries")) 2614 { 2615 bool selected = GetString("Ecom:Order.Customer.Country.Code") == country2.GetString("Ecom:Country.Code2"); 2616 if (selected) 2617 { 2618 EcomOrderCustomerCountry.Options.Add(new SelectFieldOption {ExtraAttributes = new Dictionary<string, string> {{ "selected", "selected" }} , Label = country2.GetString("Ecom:Country.Name"), Value = country2.GetString("Ecom:Country.Code2")}); 2619 } 2620 else 2621 { 2622 EcomOrderCustomerCountry.Options.Add(new SelectFieldOption {Label = country2.GetString("Ecom:Country.Name"), Value = country2.GetString("Ecom:Country.Code2")}); 2623 } 2624 2625 } 2626 } 2627 @Render(EcomOrderCustomerCountry) 2628 </div> 2629 2630 <div class="form__field-group dw-mod"> 2631 @Render(new TextField 2632 { 2633 Label = Translate("City"), 2634 Id = "EcomOrderCustomerCity", 2635 Name = "EcomOrderCustomerCity", 2636 Value = GetString("Ecom:Order.Customer.City"), 2637 Required = true, 2638 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCity.ErrorMessage"), 2639 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCity.ErrorMessage")) ? "error-field" : "" 2640 }) 2641 </div> 2642 2643 <div class="form__field-group dw-mod"> 2644 @{ 2645 var EcomOrderCustomerRegion = new SelectField 2646 { 2647 Id = "EcomOrderCustomerRegion", 2648 Name = "EcomOrderCustomerRegion", 2649 Label = Translate("State/Region"), 2650 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerRegion.ErrorMessage"), 2651 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderCustomerRegion.ErrorMessage")) ? "error-field" : "custom-select u-hidden", 2652 ExtraAttributes = new Dictionary<string, string> {{"name", "EcomOrderCustomerRegion"}} 2653 }; 2654 2655 foreach (LoopItem state in GetLoop("CustomerRegions")) 2656 { 2657 EcomOrderCustomerRegion.Options.Add(new SelectFieldOption {Label = state.GetString("Ecom:CustomerRegion.Name"), Value = state.GetString("Ecom:CustomerRegion.Name")}); 2658 } 2659 } 2660 2661 2662 @Render(EcomOrderCustomerRegion) 2663 </div> 2664 2665 <div class="form__field-group dw-mod"> 2666 @Render(new TextField 2667 { 2668 Label = Translate("Zip"), 2669 Id = "EcomOrderCustomerZip", 2670 Name = "EcomOrderCustomerZip", 2671 Value = GetString("Ecom:Order.Customer.Zip"), 2672 Required = true, 2673 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerZip.ErrorMessage"), 2674 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EcomOrderCustomerZip.ErrorMessage")) ? "error-field" : "" 2675 }) 2676 </div> 2677 </div> 2678 </div> 2679 </div> 2680 } 2681 2682 @helper RenderAdditionalInformationCustom() 2683 { 2684 var productIsGNR = Dynamicweb.Ecommerce.Services.Products.GetProductById(GetString("Ecom:LastAddedProduct.ID"), "", true).ProductFieldValues.GetProductFieldValue("IsGNR").Value; 2685 if (productIsGNR.ToString() == "True") 2686 { 2687 <div class="card-header u-color-light--bg dw-mod"> 2688 <h3>@Translate("Additional Information")</h3> 2689 </div> 2690 2691 2692 <div class="card u-color-light--bg dw-mod additional-info-wrapper" data-error="@Translate("One or more additional information fields are missing value")"> 2693 2694 2695 <div class="form__field-group dw-mod"> 2696 @Render(new TextField 2697 { 2698 Label = Translate("Co-Pilot Name"), 2699 Id = "CoPilotName", 2700 Name = "CoPilotName", 2701 Value = GetString("CoPilotName.Clean"), 2702 Required = true, 2703 ErrorMessage = GetString("Ecom:Cart.ValidationError.CoPilotName.ErrorMessage"), 2704 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.CoPilotName.ErrorMessage")) ? "error-field" : "" 2705 }) 2706 </div> 2707 2708 2709 <div class="form__field-group form__field--inline dw-mod" data-first-time-translate="@Translate("Please choose an option on first time attending")"> 2710 <div class="card-header u-color-light--bg dw-mod u-no-border-bottom u-padding-y-025"> 2711 <label class="required-label">@Translate("First Time Attending GNR")</label> 2712 </div> 2713 @{ 2714 var firstTimeAttendingGNRYes = new RadioButtonField 2715 { 2716 Name = "FirstTimeAttendingGNR", 2717 Label = Translate("Yes"), 2718 Value = "Yes", 2719 Id = "FirstTimeAttendingGNRYes", 2720 ErrorMessage = GetString("Ecom:Cart.ValidationError.FirstTimeAttendingGNR.ErrorMessage"), 2721 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.FirstTimeAttendingGNR.ErrorMessage")) ? "error-field" : "" 2722 }; 2723 @Render(firstTimeAttendingGNRYes) 2724 var firstTimeAttendingGNRNo = new RadioButtonField 2725 { 2726 Name = "FirstTimeAttendingGNR", 2727 Label = Translate("No"), 2728 Value = "No", 2729 Id = "FirstTimeAttendingGNRNo", 2730 ErrorMessage = GetString("Ecom:Cart.ValidationError.FirstTimeAttendingGNR.ErrorMessage"), 2731 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.FirstTimeAttendingGNR.ErrorMessage")) ? "error-field" : "" 2732 }; 2733 @Render(firstTimeAttendingGNRNo) 2734 } 2735 </div> 2736 2737 <div class="form__field-group dw-mod"> 2738 @Render(new TextField 2739 { 2740 Label = Translate("RV Model Name"), 2741 Id = "RVModelName", 2742 Name = "RVModelName", 2743 Value = GetString("RVModelName.Clean"), 2744 Required = true, 2745 ErrorMessage = GetString("Ecom:Cart.ValidationError.RVModelName.ErrorMessage"), 2746 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.RVModelName.ErrorMessage")) ? "error-field" : "" 2747 }) 2748 </div> 2749 2750 2751 <div class="form__field-group form__field--inline dw-mod" data-my-unit-is-translate="@Translate("Please choose an option on my unit is")"> 2752 <div class="card-header u-color-light--bg dw-mod u-no-border-bottom u-padding-y-025"> 2753 <label class="required-label">@Translate("My Unit Is: ")</label> 2754 </div> 2755 @{ 2756 var myUnitIs30 = new RadioButtonField 2757 { 2758 Name = "MyUnitIs", 2759 Label = Translate("30 Amp"), 2760 Value = "30Amp", 2761 Id = "MyUnitIs30Amp", 2762 ErrorMessage = GetString("Ecom:Cart.ValidationError.MyUnitIs.ErrorMessage"), 2763 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.MyUnitIs.ErrorMessage")) ? "error-field" : "" 2764 }; 2765 @Render(myUnitIs30) 2766 var myUnitIs50 = new RadioButtonField 2767 { 2768 Name = "MyUnitIs", 2769 Label = Translate("50 Amp"), 2770 Value = "50Amp", 2771 Id = "MyUnitIs50Amp", 2772 ErrorMessage = GetString("Ecom:Cart.ValidationError.MyUnitIs.ErrorMessage"), 2773 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.MyUnitIs.ErrorMessage")) ? "error-field" : "" 2774 }; 2775 @Render(myUnitIs50) 2776 } 2777 </div> 2778 2779 <div class="form__field-group dw-mod"> 2780 @Render(new TextField 2781 { 2782 Label = Translate("Length of RV, including permanent attachments (not including tow bar)"), 2783 Id = "LengthOfRV", 2784 Name = "LengthOfRV", 2785 Value = GetString("LengthOfRV.Clean"), 2786 Required = true, 2787 ErrorMessage = GetString("Ecom:Cart.ValidationError.LengthOfRV.ErrorMessage"), 2788 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.LengthOfRV.ErrorMessage")) ? "error-field" : "" 2789 }) 2790 </div> 2791 2792 2793 <div class="form__field-group dw-mod"> 2794 2795 @Render(new TextField 2796 { 2797 Label = Translate("Emergency Contact Name and Phone Number (non-attending)"), 2798 Id = "EmergencyContactNameAndPhoneNumber", 2799 Name = "EmergencyContactNameAndPhoneNumber", 2800 Value = GetString("EmergencyContactNameAndPhoneNumber.Clean"), 2801 Required = true, 2802 ErrorMessage = GetString("Ecom:Cart.ValidationError.EmergencyContactNameAndPhoneNumber.ErrorMessage"), 2803 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.EmergencyContactNameAndPhoneNumber.ErrorMessage")) ? "error-field" : "" 2804 }) 2805 </div> 2806 2807 2808 <div class="form__field-group dw-mod"> 2809 @Render(new TextareaField 2810 { 2811 Label = Translate("Please list all Guest Name(s) as you would like them to appear on name badges.<br>Guests must be staying in your RV for admittance to GNR"), 2812 Id = "AllGuestsNames", 2813 Name = "AllGuestsNames", 2814 Value = GetString("AllGuestsNames.Clean"), 2815 Required = true, 2816 ErrorMessage = GetString("Ecom:Cart.ValidationError.AllGuestsNames.ErrorMessage"), 2817 CssClass = !string.IsNullOrEmpty(GetString("Ecom:Cart.ValidationError.AllGuestsNames.ErrorMessage")) ? "error-field" : "" 2818 }) 2819 </div> 2820 </div> 2821 } 2822 @RenderNextButtonCustom() 2823 } 2824 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2825 @using Dynamicweb.Core 2826 @using System 2827 @using System.Web 2828 @using System.Collections.Generic 2829 @using Dynamicweb.Rapido.Blocks 2830 2831 @{ 2832 BlocksPage stepBarCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2833 2834 Block checkoutSteps = new Block() 2835 { 2836 Id = "StepBar", 2837 SortId = 10, 2838 Template = RenderStepBar(), 2839 Design = new Design { 2840 RenderType = RenderType.Column, 2841 Size = "12" 2842 } 2843 }; 2844 stepBarCheckoutPage.Add("CheckoutForm", checkoutSteps); 2845 } 2846 2847 @helper RenderStepBar() 2848 { 2849 string stepNumber = ""; 2850 2851 <div class="step-bar dw-mod"> 2852 @foreach (LoopItem step in GetLoop("StepButtons")) 2853 { 2854 if (step.GetString("Step.Name").ToLower() != "checkout") 2855 { 2856 string activeStep = step.GetBoolean("Step.Current") ? "step-bar__step--active" : ""; 2857 2858 if (GetLoop("StepButtons").Count > 2) 2859 { 2860 stepNumber = step.GetString("Step.Number") + "."; 2861 } 2862 2863 <div class="step-bar__step @activeStep dw-mod"> 2864 @stepNumber @Translate(step.GetString("Step.Name")) 2865 </div> 2866 } 2867 } 2868 </div> 2869 } 2870 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2871 @using Dynamicweb.Core 2872 @using System 2873 @using System.Web 2874 @using System.Collections.Generic 2875 @using System.Text.RegularExpressions 2876 @using Dynamicweb.Extensibility 2877 @using Dynamicweb.Content 2878 @using Dynamicweb.Core 2879 @using Dynamicweb.Ecommerce.Orders 2880 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 2881 @using Dynamicweb.Rapido.Blocks 2882 2883 @{ 2884 BlocksPage staticSummaryCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2885 2886 Block staticSummaryCustom = new Block() 2887 { 2888 Id = "StaticSummary", 2889 SortId = 20, 2890 Template = RenderStaticSummaryCustom(), 2891 Design = new Design 2892 { 2893 RenderType = RenderType.Column, 2894 Size = "12" 2895 } 2896 }; 2897 staticSummaryCheckoutPage.Add("SummaryContainerRow", staticSummaryCustom); 2898 } 2899 2900 2901 @helper RenderStaticSummaryCustom() 2902 { 2903 int productCatalog = GetPageIdByNavigationTag("ProductsPage"); 2904 var hideSummaryInPaymentStep = GetString("CartV2.CurrentStepButtonName") == "CartV2.GotoStep1" ? "u-hidden" : ""; 2905 <div class="card-header u-bg-color-gray dw-mod @hideSummaryInPaymentStep"> 2906 <h3>@Translate("Order Summary")</h3> 2907 </div> 2908 2909 <div class="card-header dw-mod u-no-padding u-bg-color-white @hideSummaryInPaymentStep"> 2910 <span class="registration-type">@Translate("Registration Type")</span> 2911 </div> 2912 2913 <div class="card u-color-light--bg u-no-padding--xs dw-mod @hideSummaryInPaymentStep"> 2914 <table class="table cart-table u-margin-bottom dw-mod"> 2915 <tbody> 2916 @foreach (LoopItem orderline in GetLoop("OrderLines")) 2917 { 2918 if (orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct")) 2919 { 2920 string productLink = "/" + Regex.Replace(orderline.GetString("Ecom:Product.LinkGroup.Clean"), @"\?ID=\d*\&", "?ID=" + productCatalog + "&"); 2921 productLink += !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")) ? "&VariantID=" + orderline.GetString("Ecom:Order:OrderLine.ProductVariantID") : ""; 2922 var productName = orderline.GetString("Ecom:Product:Field.ParentProductName.Value") != "" ? orderline.GetString("Ecom:Product:Field.ParentProductName.Value") + " - " + orderline.GetString("Ecom:Order:OrderLine.ProductName") : orderline.GetString("Ecom:Order:OrderLine.ProductName"); 2923 2924 2925 <tr> 2926 <td class="u-w60px u-hidden"> 2927 @orderline.GetString("Ecom:Order:OrderLine.Quantity") x 2928 </td> 2929 <td title="@productName"> 2930 <a class="u-color-inherit">@productName</a> 2931 <div>@GetString("Ecom:Order:OrderLine.ProductVariantText")</div> 2932 <div>@orderline.GetString("Ecom:Order:OrderLine.UnitName")</div> 2933 </td> 2934 <td class="u-ta-right u-w120px">@orderline.GetString("Ecom:Order:OrderLine.Price")</td> 2935 </tr> 2936 2937 if (orderline.GetLoop("BOMItems").Count > 0) 2938 { 2939 <tr> 2940 <td colspan="3" class="u-no-padding"> 2941 <table class="u-no-margin u-color-light-gray--bg"> 2942 <tbody> 2943 @foreach (LoopItem bomitem in orderline.GetLoop("BOMItems")) 2944 { 2945 string bomItemLink = "/" + Regex.Replace(bomitem.GetString("Ecom:Product.LinkGroup.Clean"), @"\?ID=\d*\&", "?ID=" + productCatalog + "&"); 2946 2947 <tr> 2948 <td class="u-w60px">@bomitem.GetString("Ecom:Order:OrderLine.Quantity") x</td> 2949 <td title="{@bomitem.GetString("Ecom:Order:OrderLine.ProductName") @bomitem.GetString("Ecom:Order:OrderLine.ProductVariantText")"> 2950 <a href="@bomItemLink">@bomitem.GetString("Ecom:Order:OrderLine.ProductName")</a> 2951 <div>@bomitem.GetString("Ecom:Order:OrderLine.ProductVariantText")</div> 2952 <div>@bomitem.GetString("Ecom:Order:OrderLine.UnitName")</div> 2953 </td> 2954 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 2955 <td>&nbsp;</td> 2956 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 2957 </tr> 2958 } 2959 </tbody> 2960 </table> 2961 </td> 2962 </tr> 2963 } 2964 } 2965 else 2966 { 2967 <tr class="table__row--no-border"> 2968 <td class="u-w60px">&nbsp;</td> 2969 <td>@orderline.GetString("Ecom:Order:OrderLine.ProductName")</td> 2970 <td class="cart-table__price u-ta-right dw-mod">@orderline.GetString("Ecom:Order:OrderLine.Price")</td> 2971 </tr> 2972 } 2973 } 2974 </tbody> 2975 </table> 2976 </div> 2977 <div class="u-padding-05-1em u-bg-color-gray @hideSummaryInPaymentStep"> 2978 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 2979 <div class="cart-summary__totals u-pull--right dw-mod">@GetString("Ecom:Order.OrderLines.Total.Price")</div> 2980 </div> 2981 } 2982 2983 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2984 @using Dynamicweb.Core 2985 @using System 2986 @using System.Web 2987 @using System.Collections.Generic 2988 @using Dynamicweb.Rapido.Blocks 2989 @using Dynamicweb.Ecommerce.Orders 2990 2991 @{ 2992 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 2993 2994 BlocksPage googleImpressionsPage = BlocksPage.GetBlockPage("CheckoutPage"); 2995 2996 Block googleImpressionsBlock = new Block() 2997 { 2998 Id = "GoogleImpressionsBlock", 2999 SortId = 10, 3000 Template = RenderScript() 3001 }; 3002 3003 if (useGoogleTagManager) 3004 { 3005 googleImpressionsPage.Add("CheckoutBottomSnippets", googleImpressionsBlock); 3006 } 3007 } 3008 3009 @helper RenderScript() 3010 { 3011 <script> 3012 /** 3013 * A function to handle a click on a checkout button. This function uses the eventCallback 3014 * data layer variable to handle navigation after the ecommerce data has been sent to Google Analytics. 3015 */ 3016 dataLayer.push({ 3017 'event': 'checkout', 3018 'ecommerce': { 3019 'checkout': { 3020 'actionField': {'step': 1}, 3021 'products': [ 3022 @foreach (LoopItem orderline in GetLoop("OrderLines").Where(o => o.GetInteger("Ecom:Order:OrderLine.Type") != (int)OrderLineType.Tax).ToList()) 3023 { 3024 var groupObject = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID")); 3025 <text> 3026 { 3027 'name': "@orderline.GetString("Ecom:Order:OrderLine.ProductName")", 3028 'id': "@orderline.GetString("Ecom:Product.ID")", 3029 'price': "@orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")", 3030 'brand': "@orderline.GetString("Ecom:Product:Field.brand.Value")", 3031 'category': "@(groupObject != null ? groupObject.Name : "")", 3032 'variant': "@orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")", 3033 'quantity': @orderline.GetInteger("Ecom:Order:OrderLine.Quantity") 3034 }, 3035 </text> 3036 } 3037 ] 3038 } 3039 } 3040 }); 3041 </script> 3042 } 3043 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3044 @using Dynamicweb.Core 3045 @using System 3046 @using System.Web 3047 @using System.Collections.Generic 3048 @using Dynamicweb.Rapido.Blocks 3049 3050 @{ 3051 BlocksPage snippetsCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3052 3053 snippetsCheckoutPage.Add("CheckoutBottomSnippets", new Block 3054 { 3055 Id = "CartAddressesJavascript", 3056 SortId = 50, 3057 Template = RenderCartAddressesJavascript() 3058 }); 3059 } 3060 3061 @helper RenderCartAddressesJavascript() 3062 { 3063 <script> 3064 function resetStateField(stateFieldId) { 3065 let stateField = document.getElementById(stateFieldId); 3066 if (stateField) { 3067 stateField.value = ""; 3068 let disabledOption = stateField.querySelector("option:checked"); 3069 if (disabledOption) { 3070 disabledOption.disabled = false; 3071 disabledOption.removeAttribute("disabled"); 3072 } 3073 } 3074 } 3075 3076 document.addEventListener("DOMContentLoaded", function () { 3077 regionLabels.InitDictionary({ 3078 "CA": "@Translate("State/Province")", 3079 "US": "@Translate("State/Province")" 3080 }); 3081 regionLabels.LocalizeRegionLabels("EcomOrderCustomerRegion", "EcomOrderCustomerCountry"); 3082 regionLabels.LocalizeRegionLabels("EcomOrderDeliveryRegion", "EcomOrderDeliveryCountry"); 3083 }); 3084 </script> 3085 } 3086 3087 3088 3089 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 3090 <div class="center-container center-container--with-background-image dw-mod"> 3091 <div class="paragraph-container u-padding"> 3092 <form novalidate name="ordersubmit" id="OrderSubmit" method="post" action="/[email protected]" autocomplete="off"> 3093 <div class="grid"> 3094 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 3095 @RenderBlockList(checkoutPage.BlocksRoot.BlocksList) 3096 </div> 3097 </form> 3098 </div> 3099 </div> 3100 </section>