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