Error executing template "Designs/Rapido/eCom/Productlist/ProductsRender.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Ecommerce.Products.GroupService.GetSubgroups(Group group, Boolean showUnTranslated)
   at Dynamicweb.Ecommerce.Products.GroupService.GetSubgroups(Group group)
   at Dynamicweb.Ecommerce.Products.GroupService.HasSubgroups(Group group)
   at CompiledRazorTemplates.Dynamic.RazorEngine_5baf2556f293447ba41f31a8bdea9e22.<RenderPageContainer>b__155_0(TextWriter __razor_helper_writer) in e:\webroot\Files\Templates\Designs\Rapido\eCom\Productlist\ProductsRender.cshtml:line 5757
   at RazorEngine.Templating.TemplateWriter.ToString()
   at Dynamicweb.Rapido.Blocks.Block.<>c__DisplayClass16_0.<set_Template>b__0()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at Dynamicweb.Rapido.Blocks.Block.get_Template()
   at CompiledRazorTemplates.Dynamic.RazorEngine_5baf2556f293447ba41f31a8bdea9e22.<>c__DisplayClass5_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in e:\webroot\Files\Templates\Designs\Rapido\eCom\Productlist\ProductsRender.cshtml:line 225
   at CompiledRazorTemplates.Dynamic.RazorEngine_5baf2556f293447ba41f31a8bdea9e22.<>c__DisplayClass4_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in e:\webroot\Files\Templates\Designs\Rapido\eCom\Productlist\ProductsRender.cshtml:line 135
   at CompiledRazorTemplates.Dynamic.RazorEngine_5baf2556f293447ba41f31a8bdea9e22.Execute() in e:\webroot\Files\Templates\Designs\Rapido\eCom\Productlist\ProductsRender.cshtml:line 5738
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Frontend.Devices 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using System 7 @using System.IO 8 @using System.Web 9 @using System.Collections.Generic; 10 @using System.Linq 11 @using System.Text.RegularExpressions 12 @using Dynamicweb.Ecommerce; 13 @using Dynamicweb.Rapido.Blocks 14 @using Dynamicweb.Rapido.Blocks.Components.General 15 16 @functions { 17 BlocksPage productListPage = BlocksPage.GetBlockPage("ProductList"); 18 Dynamicweb.Frontend.ItemViewModel productListSettings = null; 19 20 string favoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 21 bool isFavoriteList = !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("ListID")); 22 23 } 24 25 @{ 26 27 productListSettings = Pageview.AreaSettings.GetItem("ProductList"); 28 29 30 31 // productlistTemplate 32 33 Block pageContainer = new Block() 34 { 35 Id = "PageContainer", 36 Template = RenderPageContainer(), 37 SkipRenderBlocksList = true, 38 BlocksList = new List<Block> { 39 new Block 40 { 41 Id = "ProductListHeader", 42 SortId = 10, 43 Template = RenderProductListHeader(), 44 SkipRenderBlocksList = true, 45 BlocksList = new List<Block> { 46 new Block 47 { 48 Id = "ProductListTitle", 49 SortId = 10, 50 Design = new Design 51 { 52 CssClass = isFavoriteList ? "grid__col-xs-12 grid__col-md-4" : "grid__col-xs-12 grid__col-md-6" 53 }, 54 Template = RenderProductListTitle() 55 } 56 } 57 } 58 } 59 }; 60 productListPage.Add(pageContainer); 61 62 Block productListNavigation = new Block() 63 { 64 Id = "Navigation", 65 SortId = 20, 66 Design = new Design 67 { 68 RenderType = RenderType.Column, 69 Size = "3" 70 } 71 }; 72 productListPage.Add("PageContainer", productListNavigation); 73 74 Block productListContainer = new Block() 75 { 76 Id = "ProductList", 77 SortId = 30, 78 Template = RenderProductList(), 79 SkipRenderBlocksList = true 80 }; 81 productListPage.Add("PageContainer", productListContainer); 82 83 if (isFavoriteList) 84 { 85 productListPage.Add("ProductListHeader", new Block 86 { 87 Id = "FavoriteListSearch", 88 SortId = 20, 89 Template = RenderFavoriteListSearch(), 90 Design = new Design 91 { 92 CssClass = "grid__col-sm-4 u-margin-bottom u-margin-top grid--align-self-center" 93 } 94 }); 95 } 96 97 Block productListSnippets = new Block() 98 { 99 Id = "BottomSnippets", 100 SortId = 40 101 }; 102 productListPage.Add(productListSnippets); 103 } 104 105 @* This is required for the product list feed to work *@ 106 @GetValue("DoNotRenderProductListTemplate") 107 108 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 109 @using System.Text.RegularExpressions 110 @using System.Collections.Generic 111 @using System.Reflection 112 @using System.Web 113 @using System.Web.UI.HtmlControls 114 @using Dynamicweb.Rapido.Blocks.Components 115 @using Dynamicweb.Rapido.Blocks.Components.Articles 116 @using Dynamicweb.Rapido.Blocks.Components.Documentation 117 @using Dynamicweb.Rapido.Blocks 118 119 120 @*--- START: Base block renderers ---*@ 121 122 @helper RenderBlockList(List<Block> blocks) 123 { 124 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 125 blocks = blocks.OrderBy(item => item.SortId).ToList(); 126 127 foreach (Block item in blocks) 128 { 129 if (debug) { 130 <!-- Block START: @item.Id --> 131 } 132 133 if (item.Design == null) 134 { 135 @RenderBlock(item) 136 } 137 else if (item.Design.RenderType == RenderType.None) { 138 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 139 140 <div class="@cssClass dw-mod"> 141 @RenderBlock(item) 142 </div> 143 } 144 else if (item.Design.RenderType != RenderType.Hide) 145 { 146 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 147 148 if (!item.SkipRenderBlocksList) { 149 if (item.Design.RenderType == RenderType.Row) 150 { 151 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 152 @RenderBlock(item) 153 </div> 154 } 155 156 if (item.Design.RenderType == RenderType.Column) 157 { 158 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 159 string size = item.Design.Size ?? "12"; 160 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 161 162 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id"> 163 @RenderBlock(item) 164 </div> 165 } 166 167 if (item.Design.RenderType == RenderType.Table) 168 { 169 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 170 @RenderBlock(item) 171 </table> 172 } 173 174 if (item.Design.RenderType == RenderType.TableRow) 175 { 176 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 177 @RenderBlock(item) 178 </tr> 179 } 180 181 if (item.Design.RenderType == RenderType.TableColumn) 182 { 183 <td class="@cssClass dw-mod" id="Block__@item.Id"> 184 @RenderBlock(item) 185 </td> 186 } 187 188 if (item.Design.RenderType == RenderType.CardHeader) 189 { 190 <div class="card-header @cssClass dw-mod"> 191 @RenderBlock(item) 192 </div> 193 } 194 195 if (item.Design.RenderType == RenderType.CardBody) 196 { 197 <div class="card @cssClass dw-mod"> 198 @RenderBlock(item) 199 </div> 200 } 201 202 if (item.Design.RenderType == RenderType.CardFooter) 203 { 204 <div class="card-footer @cssClass dw-mod"> 205 @RenderBlock(item) 206 </div> 207 } 208 } 209 else 210 { 211 @RenderBlock(item) 212 } 213 } 214 215 if (debug) { 216 <!-- Block END: @item.Id --> 217 } 218 } 219 } 220 221 @helper RenderBlock(Block item) 222 { 223 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 224 225 if (item.Template != null) 226 { 227 @BlocksPage.RenderTemplate(item.Template) 228 } 229 230 if (item.Component != null) 231 { 232 string customSufix = "Custom"; 233 string methodName = item.Component.HelperName; 234 235 ComponentBase[] methodParameters = new ComponentBase[1]; 236 methodParameters[0] = item.Component; 237 Type methodType = this.GetType(); 238 239 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 240 MethodInfo generalMethod = methodType.GetMethod(methodName); 241 242 try { 243 if (debug) { 244 <!-- Component: @methodName.Replace("Render", "") --> 245 } 246 @customMethod.Invoke(this, methodParameters).ToString(); 247 } catch { 248 try { 249 @generalMethod.Invoke(this, methodParameters).ToString(); 250 } catch(Exception ex) { 251 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 252 } 253 } 254 } 255 256 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 257 { 258 @RenderBlockList(item.BlocksList) 259 } 260 } 261 262 @*--- END: Base block renderers ---*@ 263 264 @using Dynamicweb.Rapido.Blocks.Components 265 @using Dynamicweb.Rapido.Blocks.Components.General 266 @using Dynamicweb.Rapido.Blocks 267 @using System.IO 268 269 @* Required *@ 270 @using Dynamicweb.Rapido.Blocks.Components 271 @using Dynamicweb.Rapido.Blocks.Components.General 272 @using Dynamicweb.Rapido.Blocks 273 274 275 @helper Render(ComponentBase component) 276 { 277 if (component != null) 278 { 279 @component.Render(this) 280 } 281 } 282 283 @* Components *@ 284 @using System.Reflection 285 @using Dynamicweb.Rapido.Blocks.Components.General 286 287 288 @* Component *@ 289 290 @helper RenderIcon(Icon settings) 291 { 292 if (settings != null) 293 { 294 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 295 296 if (settings.Name != null) 297 { 298 if (string.IsNullOrEmpty(settings.Label)) 299 { 300 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 301 } 302 else 303 { 304 if (settings.LabelPosition == IconLabelPosition.Before) 305 { 306 <div class="u-flex u-flex--align-items-center @settings.CssClass">@settings.Label <i class="@settings.Prefix @settings.Name u-margin-left" @color></i></div> 307 } 308 else 309 { 310 <div class="u-flex u-flex--align-items-center @settings.CssClass"><i class="@settings.Prefix @settings.Name u-margin-right--lg u-w20px" @color></i>@settings.Label</div> 311 } 312 } 313 } 314 else if (!string.IsNullOrEmpty(settings.Label)) 315 { 316 @settings.Label 317 } 318 } 319 } 320 @using System.Reflection 321 @using Dynamicweb.Rapido.Blocks.Components.General 322 @using Dynamicweb.Rapido.Blocks.Components 323 @using Dynamicweb.Core 324 325 @* Component *@ 326 327 @helper RenderButton(Button settings) 328 { 329 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 330 { 331 Dictionary<string, string> attributes = new Dictionary<string, string>(); 332 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 333 if (settings.Disabled) { 334 attributes.Add("disabled", "true"); 335 classList.Add("disabled"); 336 } 337 338 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 339 { 340 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 341 @RenderConfirmDialog(settings); 342 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 343 } 344 345 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 346 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 347 if (!string.IsNullOrEmpty(settings.AltText)) 348 { 349 attributes.Add("title", settings.AltText); 350 } 351 else if (!string.IsNullOrEmpty(settings.Title)) 352 { 353 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 354 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 355 attributes.Add("title", cleanTitle); 356 } 357 358 var onClickEvents = new List<string>(); 359 if (!string.IsNullOrEmpty(settings.OnClick)) 360 { 361 onClickEvents.Add(settings.OnClick); 362 } 363 if (!string.IsNullOrEmpty(settings.Href)) 364 { 365 onClickEvents.Add("location.href='" + settings.Href + "'"); 366 } 367 if (onClickEvents.Count > 0) 368 { 369 attributes.Add("onClick", string.Join(";", onClickEvents)); 370 } 371 372 if (settings.ButtonLayout != ButtonLayout.None) 373 { 374 classList.Add("btn"); 375 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 376 if (btnLayout == "linkclean") 377 { 378 btnLayout = "link-clean"; //fix 379 } 380 classList.Add("btn--" + btnLayout); 381 } 382 383 if (settings.Icon == null) 384 { 385 settings.Icon = new Icon(); 386 } 387 388 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 389 settings.Icon.Label = settings.Title; 390 391 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 392 393 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 394 } 395 } 396 397 @helper RenderConfirmDialog(Button settings) 398 { 399 Modal confirmDialog = new Modal { 400 Id = settings.Id, 401 Width = ModalWidth.Sm, 402 Heading = new Heading 403 { 404 Level = 2, 405 Title = settings.ConfirmTitle 406 }, 407 BodyText = settings.ConfirmText 408 }; 409 410 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 411 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 412 413 @Render(confirmDialog) 414 } 415 @using Dynamicweb.Rapido.Blocks.Components.General 416 @using Dynamicweb.Rapido.Blocks.Components 417 @using Dynamicweb.Core 418 419 @helper RenderDashboard(Dashboard settings) 420 { 421 var widgets = settings.GetWidgets(); 422 423 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 424 { 425 //set bg color for them 426 427 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 428 int r = Convert.ToInt16(color.R); 429 int g = Convert.ToInt16(color.G); 430 int b = Convert.ToInt16(color.B); 431 432 var count = widgets.Length; 433 var max = Math.Max(r, Math.Max(g, b)); 434 double step = 255.0 / (max * count); 435 var i = 0; 436 foreach (var widget in widgets) 437 { 438 i++; 439 440 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 441 widget.BackgroundColor = shade; 442 } 443 } 444 445 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 446 @foreach (var widget in widgets) 447 { 448 <div class="dashboard__widget"> 449 @Render(widget) 450 </div> 451 } 452 </div> 453 } 454 @using Dynamicweb.Rapido.Blocks.Components.General 455 @using Dynamicweb.Rapido.Blocks.Components 456 457 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 458 { 459 if (!string.IsNullOrEmpty(settings.Link)) 460 { 461 var backgroundStyles = ""; 462 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 463 { 464 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 465 } 466 467 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 468 <div class="u-center-middle u-color-light"> 469 @if (settings.Icon != null) 470 { 471 settings.Icon.CssClass += "widget__icon"; 472 @Render(settings.Icon) 473 } 474 <div class="widget__title">@settings.Title</div> 475 </div> 476 </a> 477 } 478 } 479 @using Dynamicweb.Rapido.Blocks.Components.General 480 @using Dynamicweb.Rapido.Blocks.Components 481 482 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 483 { 484 var backgroundStyles = ""; 485 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 486 { 487 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 488 } 489 490 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 491 <div class="u-center-middle u-color-light"> 492 @if (settings.Icon != null) 493 { 494 settings.Icon.CssClass += "widget__icon"; 495 @Render(settings.Icon) 496 } 497 <div class="widget__counter">@settings.Count</div> 498 <div class="widget__title">@settings.Title</div> 499 </div> 500 </div> 501 } 502 @using System.Reflection 503 @using Dynamicweb.Rapido.Blocks.Components.General 504 @using Dynamicweb.Rapido.Blocks.Components 505 @using Dynamicweb.Core 506 507 @* Component *@ 508 509 @helper RenderLink(Link settings) 510 { 511 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 512 { 513 Dictionary<string, string> attributes = new Dictionary<string, string>(); 514 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 515 if (settings.Disabled) 516 { 517 attributes.Add("disabled", "true"); 518 classList.Add("disabled"); 519 } 520 521 if (!string.IsNullOrEmpty(settings.AltText)) 522 { 523 attributes.Add("title", settings.AltText); 524 } 525 else if (!string.IsNullOrEmpty(settings.Title)) 526 { 527 attributes.Add("title", settings.Title); 528 } 529 530 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 531 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 532 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 533 attributes.Add("href", settings.Href); 534 535 if (settings.ButtonLayout != ButtonLayout.None) 536 { 537 classList.Add("btn"); 538 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 539 if (btnLayout == "linkclean") 540 { 541 btnLayout = "link-clean"; //fix 542 } 543 classList.Add("btn--" + btnLayout); 544 } 545 546 if (settings.Icon == null) 547 { 548 settings.Icon = new Icon(); 549 } 550 settings.Icon.Label = settings.Title; 551 552 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 553 { 554 settings.Rel = LinkRelType.Noopener; 555 } 556 if (settings.Target != LinkTargetType.None) 557 { 558 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 559 } 560 if (settings.Download) 561 { 562 attributes.Add("download", "true"); 563 } 564 if (settings.Rel != LinkRelType.None) 565 { 566 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 567 } 568 569 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 570 } 571 } 572 @using System.Reflection 573 @using Dynamicweb.Rapido.Blocks.Components 574 @using Dynamicweb.Rapido.Blocks.Components.General 575 @using Dynamicweb.Rapido.Blocks 576 577 578 @* Component *@ 579 580 @helper RenderRating(Rating settings) 581 { 582 if (settings.Score > 0) 583 { 584 int rating = settings.Score; 585 string iconType = "fa-star"; 586 587 switch (settings.Type.ToString()) { 588 case "Stars": 589 iconType = "fa-star"; 590 break; 591 case "Hearts": 592 iconType = "fa-heart"; 593 break; 594 case "Lemons": 595 iconType = "fa-lemon"; 596 break; 597 case "Bombs": 598 iconType = "fa-bomb"; 599 break; 600 } 601 602 <div class="u-ta-right"> 603 @for (int i = 0; i < settings.OutOf; i++) 604 { 605 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 606 } 607 </div> 608 } 609 } 610 @using System.Reflection 611 @using Dynamicweb.Rapido.Blocks.Components.General 612 @using Dynamicweb.Rapido.Blocks.Components 613 614 615 @* Component *@ 616 617 @helper RenderSelectFieldOption(SelectFieldOption settings) 618 { 619 Dictionary<string, string> attributes = new Dictionary<string, string>(); 620 if (settings.Checked) { attributes.Add("selected", "true"); } 621 if (settings.Disabled) { attributes.Add("disabled", "true"); } 622 if (settings.Value != null) { attributes.Add("value", settings.Value); } 623 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 624 625 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 626 } 627 @using System.Reflection 628 @using Dynamicweb.Rapido.Blocks.Components.General 629 @using Dynamicweb.Rapido.Blocks.Components 630 631 632 @* Component *@ 633 634 @helper RenderNavigation(Navigation settings) { 635 @RenderNavigation(new 636 { 637 id = settings.Id, 638 cssclass = settings.CssClass, 639 startLevel = settings.StartLevel, 640 endlevel = settings.EndLevel, 641 expandmode = settings.Expandmode, 642 sitemapmode = settings.SitemapMode, 643 template = settings.Template 644 }) 645 } 646 @using Dynamicweb.Rapido.Blocks.Components.General 647 @using Dynamicweb.Rapido.Blocks.Components 648 649 650 @* Component *@ 651 652 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 653 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 654 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 655 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 656 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 657 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 658 settings.SitemapMode = false; 659 660 @RenderNavigation(settings) 661 } 662 @using Dynamicweb.Rapido.Blocks.Components.General 663 @using Dynamicweb.Rapido.Blocks.Components 664 665 666 @* Component *@ 667 668 @helper RenderLeftNavigation(LeftNavigation settings) { 669 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 670 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 671 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 672 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 673 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 674 675 <div class="grid__cell"> 676 @RenderNavigation(settings) 677 </div> 678 } 679 @using System.Reflection 680 @using Dynamicweb.Rapido.Blocks.Components.General 681 @using Dynamicweb.Core 682 683 @* Component *@ 684 685 @helper RenderHeading(Heading settings) 686 { 687 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 688 { 689 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 690 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 691 692 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 693 if (!string.IsNullOrEmpty(settings.Link)) 694 { 695 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 696 } 697 else 698 { 699 if (settings.Icon == null) 700 { 701 settings.Icon = new Icon(); 702 } 703 settings.Icon.Label = settings.Title; 704 @Render(settings.Icon) 705 } 706 @("</" + tagName + ">"); 707 } 708 } 709 @using Dynamicweb.Rapido.Blocks.Components 710 @using Dynamicweb.Rapido.Blocks.Components.General 711 @using Dynamicweb.Rapido.Blocks 712 713 714 @* Component *@ 715 716 @helper RenderImage(Image settings) 717 { 718 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 719 { 720 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 721 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 722 723 if (settings.Caption != null) 724 { 725 @:<div> 726 } 727 728 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 729 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 730 731 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 732 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 733 @if (settings.Link != null) 734 { 735 <a href="@settings.Link"> 736 @RenderTheImage(settings) 737 </a> 738 } 739 else 740 { 741 @RenderTheImage(settings) 742 } 743 </div> 744 </div> 745 746 if (settings.Caption != null) 747 { 748 <span class="image-caption dw-mod">@settings.Caption</span> 749 @:</div> 750 } 751 } 752 else 753 { 754 if (settings.Caption != null) 755 { 756 @:<div> 757 } 758 if (!string.IsNullOrEmpty(settings.Link)) 759 { 760 <a href="@settings.Link"> 761 @RenderTheImage(settings) 762 </a> 763 } 764 else 765 { 766 @RenderTheImage(settings) 767 } 768 769 if (settings.Caption != null) 770 { 771 <span class="image-caption dw-mod">@settings.Caption</span> 772 @:</div> 773 } 774 } 775 } 776 777 @helper RenderTheImage(Image settings) 778 { 779 if (settings != null) 780 { 781 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 782 string placeholderImage = "/Files/Images/placeholder.gif"; 783 string imageEngine = "/Admin/Public/GetImage.ashx?"; 784 785 string imageStyle = ""; 786 787 switch (settings.Style) 788 { 789 case ImageStyle.Ball: 790 imageStyle = "grid__cell-img--ball"; 791 break; 792 793 case ImageStyle.Triangle: 794 imageStyle = "grid__cell-img--triangle"; 795 break; 796 } 797 798 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 799 { 800 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 801 802 if (settings.ImageDefault != null) 803 { 804 settings.ImageDefault.Height = settings.ImageDefault.Width; 805 } 806 if (settings.ImageMedium != null) 807 { 808 settings.ImageMedium.Height = settings.ImageMedium.Width; 809 } 810 if (settings.ImageSmall != null) 811 { 812 settings.ImageSmall.Height = settings.ImageSmall.Width; 813 } 814 } 815 816 string defaultImage = imageEngine; 817 string imageSmall = ""; 818 string imageMedium = ""; 819 820 if (settings.DisableImageEngine) 821 { 822 defaultImage = settings.Path; 823 } 824 else 825 { 826 if (settings.ImageDefault != null) 827 { 828 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 829 830 if (settings.Path.GetType() != typeof(string)) 831 { 832 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 833 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 834 } 835 else 836 { 837 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 838 } 839 840 defaultImage += "&AlternativeImage=" + alternativeImage; 841 } 842 843 if (settings.ImageSmall != null) 844 { 845 imageSmall = "data-src-small=\"" + imageEngine; 846 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 847 848 if (settings.Path.GetType() != typeof(string)) 849 { 850 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 851 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 852 } 853 else 854 { 855 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 856 } 857 858 imageSmall += "&alternativeImage=" + alternativeImage; 859 860 imageSmall += "\""; 861 } 862 863 if (settings.ImageMedium != null) 864 { 865 imageMedium = "data-src-medium=\"" + imageEngine; 866 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 867 868 if (settings.Path.GetType() != typeof(string)) 869 { 870 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 871 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 872 } 873 else 874 { 875 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 876 } 877 878 imageMedium += "&alternativeImage=" + alternativeImage; 879 880 imageMedium += "\""; 881 } 882 } 883 884 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 885 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 886 if (!string.IsNullOrEmpty(settings.Title)) 887 { 888 optionalAttributes.Add("alt", settings.Title); 889 optionalAttributes.Add("title", settings.Title); 890 } 891 892 if (settings.DisableLazyLoad) 893 { 894 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 895 } 896 else 897 { 898 <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) /> 899 } 900 } 901 } 902 @using System.Reflection 903 @using Dynamicweb.Rapido.Blocks.Components.General 904 @using Dynamicweb.Rapido.Blocks.Components 905 906 @* Component *@ 907 908 @helper RenderFileField(FileField settings) 909 { 910 var attributes = new Dictionary<string, string>(); 911 if (string.IsNullOrEmpty(settings.Id)) 912 { 913 settings.Id = Guid.NewGuid().ToString("N"); 914 } 915 916 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 917 if (settings.Disabled) { attributes.Add("disabled", "true"); } 918 if (settings.Required) { attributes.Add("required", "true"); } 919 if (settings.Multiple) { attributes.Add("multiple", "true"); } 920 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 921 if (string.IsNullOrEmpty(settings.ChooseFileText)) 922 { 923 settings.ChooseFileText = Translate("Choose file"); 924 } 925 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 926 { 927 settings.NoFilesChosenText = Translate("No files chosen..."); 928 } 929 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 930 931 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 932 933 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 934 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 935 936 attributes.Add("type", "file"); 937 if (settings.Value != null) { attributes.Add("value", settings.Value); } 938 settings.CssClass = "u-full-width " + settings.CssClass; 939 940 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 941 942 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 943 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 944 { 945 <div class="u-full-width"> 946 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 947 @if (settings.Link != null) { 948 <div class="u-pull--right"> 949 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 950 @Render(settings.Link) 951 </div> 952 } 953 </div> 954 955 } 956 957 @if (!string.IsNullOrEmpty(settings.HelpText)) 958 { 959 <small class="form__help-text">@settings.HelpText</small> 960 } 961 962 <div class="form__field-combi file-input u-no-margin dw-mod"> 963 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 964 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 965 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 966 @if (settings.UploadButton != null) 967 { 968 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 969 @Render(settings.UploadButton) 970 } 971 </div> 972 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 973 </div> 974 } 975 @using System.Reflection 976 @using Dynamicweb.Rapido.Blocks.Components.General 977 @using Dynamicweb.Rapido.Blocks.Components 978 @using Dynamicweb.Core 979 @using System.Linq 980 981 @* Component *@ 982 983 @helper RenderDateTimeField(DateTimeField settings) 984 { 985 if (string.IsNullOrEmpty(settings.Id)) 986 { 987 settings.Id = Guid.NewGuid().ToString("N"); 988 } 989 990 var textField = new TextField { 991 Name = settings.Name, 992 Id = settings.Id, 993 Label = settings.Label, 994 HelpText = settings.HelpText, 995 Value = settings.Value, 996 Disabled = settings.Disabled, 997 Required = settings.Required, 998 ErrorMessage = settings.ErrorMessage, 999 CssClass = settings.CssClass, 1000 WrapperCssClass = settings.WrapperCssClass, 1001 OnChange = settings.OnChange, 1002 OnClick = settings.OnClick, 1003 Link = settings.Link, 1004 ExtraAttributes = settings.ExtraAttributes, 1005 // 1006 Placeholder = settings.Placeholder 1007 }; 1008 1009 @Render(textField) 1010 1011 List<string> jsAttributes = new List<string>(); 1012 1013 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1014 1015 if (!string.IsNullOrEmpty(settings.DateFormat)) 1016 { 1017 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1018 } 1019 if (!string.IsNullOrEmpty(settings.MinDate)) 1020 { 1021 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1022 } 1023 if (!string.IsNullOrEmpty(settings.MaxDate)) 1024 { 1025 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1026 } 1027 if (settings.IsInline) 1028 { 1029 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1030 } 1031 if (settings.EnableTime) 1032 { 1033 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1034 } 1035 if (settings.EnableWeekNumbers) 1036 { 1037 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1038 } 1039 1040 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1041 1042 <script> 1043 document.addEventListener("DOMContentLoaded", function () { 1044 flatpickr("#@textField.Id", { 1045 @string.Join(",", jsAttributes) 1046 }); 1047 }); 1048 </script> 1049 } 1050 @using System.Reflection 1051 @using Dynamicweb.Rapido.Blocks.Components.General 1052 @using Dynamicweb.Rapido.Blocks.Components 1053 1054 @* Component *@ 1055 1056 @helper RenderTextField(TextField settings) 1057 { 1058 var attributes = new Dictionary<string, string>(); 1059 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1060 { 1061 settings.Id = Guid.NewGuid().ToString("N"); 1062 } 1063 1064 /*base settings*/ 1065 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1066 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1067 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1068 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1069 if (settings.Required) { attributes.Add("required", "true"); } 1070 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1071 /*end*/ 1072 1073 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1074 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1075 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1076 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1077 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1078 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1079 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1080 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1081 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1082 1083 settings.CssClass = "u-full-width " + settings.CssClass; 1084 1085 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1086 1087 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1088 1089 string noMargin = "u-no-margin"; 1090 if (!settings.ReadOnly) { 1091 noMargin = ""; 1092 } 1093 1094 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1095 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1096 { 1097 <div class="u-full-width"> 1098 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1099 @if (settings.Link != null) { 1100 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1101 1102 <div class="u-pull--right"> 1103 @Render(settings.Link) 1104 </div> 1105 } 1106 </div> 1107 1108 } 1109 1110 @if (!string.IsNullOrEmpty(settings.HelpText)) 1111 { 1112 <small class="form__help-text">@settings.HelpText</small> 1113 } 1114 1115 @if (settings.ActionButton != null) 1116 { 1117 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 @Render(settings.ActionButton) 1121 </div> 1122 } 1123 else 1124 { 1125 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1126 } 1127 1128 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1129 </div> 1130 } 1131 @using System.Reflection 1132 @using Dynamicweb.Rapido.Blocks.Components.General 1133 @using Dynamicweb.Rapido.Blocks.Components 1134 1135 @* Component *@ 1136 1137 @helper RenderNumberField(NumberField settings) 1138 { 1139 var attributes = new Dictionary<string, string>(); 1140 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1141 { 1142 settings.Id = Guid.NewGuid().ToString("N"); 1143 } 1144 1145 /*base settings*/ 1146 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1147 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1148 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1149 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1150 if (settings.Required) { attributes.Add("required", "true"); } 1151 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1152 /*end*/ 1153 1154 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1155 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1156 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1157 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1158 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1159 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1160 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1161 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1162 attributes.Add("type", "number"); 1163 1164 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1165 1166 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1167 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1168 { 1169 <div class="u-full-width"> 1170 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1171 @if (settings.Link != null) { 1172 <div class="u-pull--right"> 1173 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1174 @Render(settings.Link) 1175 </div> 1176 } 1177 </div> 1178 1179 } 1180 1181 @if (!string.IsNullOrEmpty(settings.HelpText)) 1182 { 1183 <small class="form__help-text">@settings.HelpText</small> 1184 } 1185 1186 @if (settings.ActionButton != null) 1187 { 1188 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1189 <div class="form__field-combi u-no-margin dw-mod"> 1190 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1191 @Render(settings.ActionButton) 1192 </div> 1193 } 1194 else 1195 { 1196 <div class="form__field-combi u-no-margin dw-mod"> 1197 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1198 </div> 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 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1235 1236 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1237 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1238 { 1239 <div class="u-full-width"> 1240 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1241 @if (settings.Link != null) { 1242 <div class="u-pull--right"> 1243 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1244 @Render(settings.Link) 1245 </div> 1246 } 1247 </div> 1248 } 1249 1250 @if (!string.IsNullOrEmpty(settings.HelpText)) 1251 { 1252 <small class="form__help-text">@settings.HelpText</small> 1253 } 1254 1255 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1256 1257 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1258 </div> 1259 } 1260 @using System.Reflection 1261 @using Dynamicweb.Rapido.Blocks.Components.General 1262 @using Dynamicweb.Rapido.Blocks.Components 1263 1264 1265 @* Component *@ 1266 1267 @helper RenderHiddenField(HiddenField settings) { 1268 var attributes = new Dictionary<string, string>(); 1269 attributes.Add("type", "hidden"); 1270 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1271 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1272 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1273 1274 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1275 } 1276 @using System.Reflection 1277 @using Dynamicweb.Rapido.Blocks.Components.General 1278 @using Dynamicweb.Rapido.Blocks.Components 1279 1280 @* Component *@ 1281 1282 @helper RenderCheckboxField(CheckboxField settings) 1283 { 1284 var attributes = new Dictionary<string, string>(); 1285 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1286 { 1287 settings.Id = Guid.NewGuid().ToString("N"); 1288 } 1289 1290 /*base settings*/ 1291 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1292 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1293 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1294 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1295 if (settings.Required) { attributes.Add("required", "true"); } 1296 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1297 /*end*/ 1298 1299 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1300 1301 attributes.Add("type", "checkbox"); 1302 if (settings.Checked) { attributes.Add("checked", "true"); } 1303 settings.CssClass = "form__control " + settings.CssClass; 1304 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1305 1306 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1307 1308 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1309 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1310 @if (!string.IsNullOrEmpty(settings.Label)) 1311 { 1312 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1313 } 1314 1315 @if (settings.Link != null) { 1316 <span> 1317 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1318 @Render(settings.Link) 1319 </span> 1320 } 1321 1322 @if (!string.IsNullOrEmpty(settings.HelpText)) 1323 { 1324 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1325 } 1326 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1327 </div> 1328 } 1329 @using System.Reflection 1330 @using Dynamicweb.Rapido.Blocks.Components.General 1331 @using Dynamicweb.Rapido.Blocks.Components 1332 1333 1334 @* Component *@ 1335 1336 @helper RenderCheckboxListField(CheckboxListField settings) 1337 { 1338 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1339 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1340 { 1341 <div class="u-full-width"> 1342 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1343 @if (settings.Link != null) { 1344 <div class="u-pull--right"> 1345 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1346 @Render(settings.Link) 1347 </div> 1348 } 1349 </div> 1350 1351 } 1352 1353 <div class="u-pull--left"> 1354 @if (!string.IsNullOrEmpty(settings.HelpText)) 1355 { 1356 <small class="form__help-text">@settings.HelpText</small> 1357 } 1358 1359 @foreach (var item in settings.Options) 1360 { 1361 if (settings.Required) 1362 { 1363 item.Required = true; 1364 } 1365 if (settings.Disabled) 1366 { 1367 item.Disabled = true; 1368 } 1369 if (!string.IsNullOrEmpty(settings.Name)) 1370 { 1371 item.Name = settings.Name; 1372 } 1373 if (!string.IsNullOrEmpty(settings.CssClass)) 1374 { 1375 item.CssClass += settings.CssClass; 1376 } 1377 1378 /* value is not supported */ 1379 1380 if (!string.IsNullOrEmpty(settings.OnClick)) 1381 { 1382 item.OnClick += settings.OnClick; 1383 } 1384 if (!string.IsNullOrEmpty(settings.OnChange)) 1385 { 1386 item.OnChange += settings.OnChange; 1387 } 1388 @Render(item) 1389 } 1390 1391 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1392 </div> 1393 1394 </div> 1395 } 1396 @using Dynamicweb.Rapido.Blocks.Components.General 1397 1398 @* Component *@ 1399 1400 @helper RenderSearch(Search settings) 1401 { 1402 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1403 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1404 1405 if (string.IsNullOrEmpty(settings.Id)) 1406 { 1407 settings.Id = Guid.NewGuid().ToString("N"); 1408 } 1409 1410 var resultAttributes = new Dictionary<string, string>(); 1411 1412 if (settings.PageSize != 0) 1413 { 1414 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1415 } 1416 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1417 { 1418 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1419 if (!string.IsNullOrEmpty(groupValue)) 1420 { 1421 resultAttributes.Add("data-selected-group", groupValue); 1422 } 1423 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1424 { 1425 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1426 } 1427 } 1428 resultAttributes.Add("data-force-init", "true"); 1429 if (settings.GoToFirstSearchResultOnEnter) 1430 { 1431 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1432 } 1433 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1434 { 1435 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1436 } 1437 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1438 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1439 1440 if (settings.SecondSearchData != null) 1441 { 1442 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1443 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1444 } 1445 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1446 { 1447 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1448 } 1449 1450 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1451 1452 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1453 1454 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1455 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1456 { 1457 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1458 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1459 } 1460 1461 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1462 1463 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1464 @if (settings.SecondSearchData != null) 1465 { 1466 <div class="search__column search__column--products dw-mod"> 1467 <div class="search__column-header dw-mod">@Translate("Products")</div> 1468 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1469 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1470 { 1471 @Render(new Link { 1472 Title = Translate("View all"), 1473 CssClass = "js-view-all-button u-margin", 1474 Href = settings.SearchData.ResultsPageUrl 1475 }); 1476 } 1477 </div> 1478 <div class="search__column search__column--pages dw-mod"> 1479 <div class="search__column-header">@Translate("Pages")</div> 1480 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1481 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1482 { 1483 @Render(new Link 1484 { 1485 Title = Translate("View all"), 1486 CssClass = "js-view-all-button u-margin", 1487 Href = settings.SecondSearchData.ResultsPageUrl 1488 }); 1489 } 1490 </div> 1491 } 1492 else 1493 { 1494 <div class="search__column search__column--only dw-mod"> 1495 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1496 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1497 { 1498 @Render(new Link { 1499 Title = Translate("View all"), 1500 CssClass = "js-view-all-button u-margin", 1501 Href = settings.SearchData.ResultsPageUrl 1502 }); 1503 } 1504 </div> 1505 } 1506 </div> 1507 1508 @if (settings.SearchButton != null) 1509 { 1510 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1511 if (settings.RenderDefaultSearchIcon) 1512 { 1513 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1514 } 1515 @Render(settings.SearchButton); 1516 } 1517 </div> 1518 } 1519 @using System.Reflection 1520 @using Dynamicweb.Rapido.Blocks.Components.General 1521 @using Dynamicweb.Rapido.Blocks.Components 1522 1523 1524 @* Component *@ 1525 1526 @helper RenderSelectField(SelectField settings) 1527 { 1528 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1529 { 1530 settings.Id = Guid.NewGuid().ToString("N"); 1531 } 1532 1533 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1534 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1535 { 1536 <div class="u-full-width"> 1537 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1538 @if (settings.Link != null) { 1539 <div class="u-pull--right"> 1540 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1541 @Render(settings.Link) 1542 </div> 1543 } 1544 </div> 1545 } 1546 1547 @if (!string.IsNullOrEmpty(settings.HelpText)) 1548 { 1549 <small class="form__help-text">@settings.HelpText</small> 1550 } 1551 1552 @if (settings.ActionButton != null) 1553 { 1554 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1555 <div class="form__field-combi u-no-margin dw-mod"> 1556 @RenderSelectBase(settings) 1557 @Render(settings.ActionButton) 1558 </div> 1559 } 1560 else 1561 { 1562 @RenderSelectBase(settings) 1563 } 1564 1565 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1566 </div> 1567 } 1568 1569 @helper RenderSelectBase(SelectField settings) 1570 { 1571 var attributes = new Dictionary<string, string>(); 1572 1573 /*base settings*/ 1574 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1575 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1576 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1577 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1578 if (settings.Required) { attributes.Add("required", "true"); } 1579 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1580 /*end*/ 1581 1582 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1583 1584 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1585 @if (settings.Default != null) 1586 { 1587 @Render(settings.Default) 1588 } 1589 1590 @foreach (var item in settings.Options) 1591 { 1592 if (settings.Value != null) { 1593 item.Checked = item.Value == settings.Value; 1594 } 1595 @Render(item) 1596 } 1597 </select> 1598 } 1599 @using System.Reflection 1600 @using Dynamicweb.Rapido.Blocks.Components.General 1601 @using Dynamicweb.Rapido.Blocks.Components 1602 1603 @* Component *@ 1604 1605 @helper RenderRadioButtonField(RadioButtonField settings) 1606 { 1607 var attributes = new Dictionary<string, string>(); 1608 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1609 { 1610 settings.Id = Guid.NewGuid().ToString("N"); 1611 } 1612 1613 /*base settings*/ 1614 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1615 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1616 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1617 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1618 if (settings.Required) { attributes.Add("required", "true"); } 1619 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1620 /*end*/ 1621 1622 attributes.Add("type", "radio"); 1623 if (settings.Checked) { attributes.Add("checked", "true"); } 1624 settings.CssClass = "form__control " + settings.CssClass; 1625 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1626 1627 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1628 1629 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1630 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1631 @if (!string.IsNullOrEmpty(settings.Label)) 1632 { 1633 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1634 } 1635 @if (!string.IsNullOrEmpty(settings.HelpText)) 1636 { 1637 <small class="form__help-text">@settings.HelpText</small> 1638 } 1639 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1640 </div> 1641 } 1642 @using System.Reflection 1643 @using Dynamicweb.Rapido.Blocks.Components.General 1644 @using Dynamicweb.Rapido.Blocks.Components 1645 1646 1647 @* Component *@ 1648 1649 @helper RenderRadioButtonListField(RadioButtonListField settings) 1650 { 1651 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1652 1653 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1654 @if (!string.IsNullOrEmpty(settings.Label)) 1655 { 1656 <label>@settings.Label</label> 1657 } 1658 @if (!string.IsNullOrEmpty(settings.HelpText)) 1659 { 1660 <small class="form__help-text">@settings.HelpText</small> 1661 } 1662 1663 @foreach (var item in settings.Options) 1664 { 1665 if (settings.Required) 1666 { 1667 item.Required = true; 1668 } 1669 if (settings.Disabled) 1670 { 1671 item.Disabled = true; 1672 } 1673 if (!string.IsNullOrEmpty(settings.Name)) 1674 { 1675 item.Name = settings.Name; 1676 } 1677 if (settings.Value != null && settings.Value == item.Value) 1678 { 1679 item.Checked = true; 1680 } 1681 if (!string.IsNullOrEmpty(settings.OnClick)) 1682 { 1683 item.OnClick += settings.OnClick; 1684 } 1685 if (!string.IsNullOrEmpty(settings.OnChange)) 1686 { 1687 item.OnChange += settings.OnChange; 1688 } 1689 if (!string.IsNullOrEmpty(settings.CssClass)) 1690 { 1691 item.CssClass += settings.CssClass; 1692 } 1693 @Render(item) 1694 } 1695 1696 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1697 </div> 1698 } 1699 @using System.Reflection 1700 @using Dynamicweb.Rapido.Blocks.Components.General 1701 @using Dynamicweb.Rapido.Blocks.Components 1702 1703 1704 @* Component *@ 1705 1706 @helper RenderNotificationMessage(NotificationMessage settings) 1707 { 1708 if (!string.IsNullOrEmpty(settings.Message)) 1709 { 1710 var attributes = new Dictionary<string, string>(); 1711 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1712 1713 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1714 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1715 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1716 1717 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1718 @if (settings.Icon != null) { 1719 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1720 @Render(settings.Icon) 1721 } else { 1722 @settings.Message 1723 } 1724 </div> 1725 } 1726 } 1727 @using Dynamicweb.Rapido.Blocks.Components.General 1728 1729 1730 @* Component *@ 1731 1732 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1733 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1734 1735 <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> 1736 @if (settings.SubBlocks != null) { 1737 @RenderBlockList(settings.SubBlocks) 1738 } 1739 </div> 1740 } 1741 @using System.Reflection 1742 @using Dynamicweb.Rapido.Blocks.Components.General 1743 @using Dynamicweb.Rapido.Blocks.Components 1744 @using System.Text.RegularExpressions 1745 1746 1747 @* Component *@ 1748 1749 @helper RenderSticker(Sticker settings) { 1750 if (!String.IsNullOrEmpty(settings.Title)) { 1751 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1752 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1753 1754 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1755 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1756 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1757 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1758 optionalAttributes.Add("style", styleTag); 1759 } 1760 1761 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1762 } 1763 } 1764 1765 @using System.Reflection 1766 @using Dynamicweb.Rapido.Blocks.Components.General 1767 @using Dynamicweb.Rapido.Blocks.Components 1768 1769 1770 @* Component *@ 1771 1772 @helper RenderStickersCollection(StickersCollection settings) 1773 { 1774 if (settings.Stickers.Count > 0) 1775 { 1776 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1777 1778 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1779 @foreach (Sticker sticker in settings.Stickers) 1780 { 1781 @Render(sticker) 1782 } 1783 </div> 1784 } 1785 } 1786 1787 @using Dynamicweb.Rapido.Blocks.Components.General 1788 1789 1790 @* Component *@ 1791 1792 @helper RenderForm(Form settings) { 1793 if (settings != null) 1794 { 1795 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1796 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1797 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1798 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1799 var enctypes = new Dictionary<string, string> 1800 { 1801 { "multipart", "multipart/form-data" }, 1802 { "text", "text/plain" }, 1803 { "application", "application/x-www-form-urlencoded" } 1804 }; 1805 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1806 optionalAttributes.Add("method", settings.Method.ToString()); 1807 1808 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1809 { 1810 @settings.FormStartMarkup 1811 } 1812 else 1813 { 1814 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1815 } 1816 1817 foreach (var field in settings.GetFields()) 1818 { 1819 @Render(field) 1820 } 1821 1822 @:</form> 1823 } 1824 } 1825 @using System.Reflection 1826 @using Dynamicweb.Rapido.Blocks.Components.General 1827 @using Dynamicweb.Rapido.Blocks.Components 1828 1829 1830 @* Component *@ 1831 1832 @helper RenderText(Text settings) 1833 { 1834 @settings.Content 1835 } 1836 @using System.Reflection 1837 @using Dynamicweb.Rapido.Blocks.Components.General 1838 @using Dynamicweb.Rapido.Blocks.Components 1839 1840 1841 @* Component *@ 1842 1843 @helper RenderContentModule(ContentModule settings) { 1844 if (!string.IsNullOrEmpty(settings.Content)) 1845 { 1846 @settings.Content 1847 } 1848 } 1849 @using System 1850 @using System.Reflection 1851 @using Dynamicweb.Rapido.Blocks.Components.General 1852 @using Dynamicweb.Rapido.Blocks.Components 1853 1854 1855 @* Component *@ 1856 1857 @helper RenderModal(Modal settings) { 1858 if (settings != null) 1859 { 1860 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1861 1862 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1863 1864 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1865 1866 <div class="modal-container"> 1867 @if (!settings.DisableDarkOverlay) 1868 { 1869 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1870 } 1871 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1872 @if (settings.Heading != null) 1873 { 1874 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1875 { 1876 <div class="modal__header"> 1877 @Render(settings.Heading) 1878 </div> 1879 } 1880 } 1881 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1882 @if (!string.IsNullOrEmpty(settings.BodyText)) 1883 { 1884 <div class="modal__body_text">@settings.BodyText</div> 1885 1886 } 1887 @if (settings.BodyTemplate != null) 1888 { 1889 @settings.BodyTemplate 1890 } 1891 @{ 1892 var actions = settings.GetActions(); 1893 } 1894 </div> 1895 @if (actions.Length > 0) 1896 { 1897 <div class="modal__footer"> 1898 @foreach (var action in actions) 1899 { 1900 if (Pageview.Device.ToString() != "Mobile") { 1901 action.CssClass += " u-no-margin"; 1902 } else { 1903 action.CssClass += " u-full-width u-margin-bottom"; 1904 } 1905 1906 @Render(action) 1907 } 1908 </div> 1909 } 1910 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1911 </div> 1912 </div> 1913 } 1914 } 1915 @using Dynamicweb.Rapido.Blocks.Components.General 1916 1917 @* Component *@ 1918 1919 @helper RenderMediaListItem(MediaListItem settings) 1920 { 1921 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1922 @if (!string.IsNullOrEmpty(settings.Label)) 1923 { 1924 if (!string.IsNullOrEmpty(settings.Link)) 1925 { 1926 @Render(new Link 1927 { 1928 Href = settings.Link, 1929 CssClass = "media-list-item__sticker dw-mod", 1930 ButtonLayout = ButtonLayout.None, 1931 Title = settings.Label, 1932 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1933 }) 1934 } 1935 else if (!string.IsNullOrEmpty(settings.OnClick)) 1936 { 1937 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1938 <span class="u-uppercase">@settings.Label</span> 1939 </span> 1940 } 1941 else 1942 { 1943 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1944 <span class="u-uppercase">@settings.Label</span> 1945 </span> 1946 } 1947 } 1948 <div class="media-list-item__wrap"> 1949 <div class="media-list-item__info dw-mod"> 1950 <div class="media-list-item__header dw-mod"> 1951 @if (!string.IsNullOrEmpty(settings.Title)) 1952 { 1953 if (!string.IsNullOrEmpty(settings.Link)) 1954 { 1955 @Render(new Link 1956 { 1957 Href = settings.Link, 1958 CssClass = "media-list-item__name dw-mod", 1959 ButtonLayout = ButtonLayout.None, 1960 Title = settings.Title, 1961 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1962 }) 1963 } 1964 else if (!string.IsNullOrEmpty(settings.OnClick)) 1965 { 1966 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1967 } 1968 else 1969 { 1970 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1971 } 1972 } 1973 1974 @if (!string.IsNullOrEmpty(settings.Status)) 1975 { 1976 <div class="media-list-item__state dw-mod">@settings.Status</div> 1977 } 1978 </div> 1979 @{ 1980 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1981 } 1982 1983 @Render(settings.InfoTable) 1984 </div> 1985 <div class="media-list-item__actions dw-mod"> 1986 <div class="media-list-item__actions-list dw-mod"> 1987 @{ 1988 var actions = settings.GetActions(); 1989 1990 foreach (ButtonBase action in actions) 1991 { 1992 action.ButtonLayout = ButtonLayout.None; 1993 action.CssClass += " media-list-item__action link"; 1994 1995 @Render(action) 1996 } 1997 } 1998 </div> 1999 2000 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2001 { 2002 settings.SelectButton.CssClass += " u-no-margin"; 2003 2004 <div class="media-list-item__action-button"> 2005 @Render(settings.SelectButton) 2006 </div> 2007 } 2008 </div> 2009 </div> 2010 </div> 2011 } 2012 @using Dynamicweb.Rapido.Blocks.Components.General 2013 @using Dynamicweb.Rapido.Blocks.Components 2014 2015 @helper RenderTable(Table settings) 2016 { 2017 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2018 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2019 2020 var enumToClasses = new Dictionary<TableDesign, string> 2021 { 2022 { TableDesign.Clean, "table--clean" }, 2023 { TableDesign.Bordered, "table--bordered" }, 2024 { TableDesign.Striped, "table--striped" }, 2025 { TableDesign.Hover, "table--hover" }, 2026 { TableDesign.Compact, "table--compact" }, 2027 { TableDesign.Condensed, "table--condensed" }, 2028 { TableDesign.NoTopBorder, "table--no-top-border" } 2029 }; 2030 string tableDesignClass = ""; 2031 if (settings.Design != TableDesign.None) 2032 { 2033 tableDesignClass = enumToClasses[settings.Design]; 2034 } 2035 2036 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2037 2038 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2039 2040 <table @ComponentMethods.AddAttributes(resultAttributes)> 2041 @if (settings.Header != null) 2042 { 2043 <thead> 2044 @Render(settings.Header) 2045 </thead> 2046 } 2047 <tbody> 2048 @foreach (var row in settings.Rows) 2049 { 2050 @Render(row) 2051 } 2052 </tbody> 2053 @if (settings.Footer != null) 2054 { 2055 <tfoot> 2056 @Render(settings.Footer) 2057 </tfoot> 2058 } 2059 </table> 2060 } 2061 @using Dynamicweb.Rapido.Blocks.Components.General 2062 @using Dynamicweb.Rapido.Blocks.Components 2063 2064 @helper RenderTableRow(TableRow settings) 2065 { 2066 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2067 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2068 2069 var enumToClasses = new Dictionary<TableRowDesign, string> 2070 { 2071 { TableRowDesign.NoBorder, "table__row--no-border" }, 2072 { TableRowDesign.Border, "table__row--border" }, 2073 { TableRowDesign.TopBorder, "table__row--top-line" }, 2074 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2075 { TableRowDesign.Solid, "table__row--solid" } 2076 }; 2077 2078 string tableRowDesignClass = ""; 2079 if (settings.Design != TableRowDesign.None) 2080 { 2081 tableRowDesignClass = enumToClasses[settings.Design]; 2082 } 2083 2084 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2085 2086 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2087 2088 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2089 @foreach (var cell in settings.Cells) 2090 { 2091 if (settings.IsHeaderRow) 2092 { 2093 cell.IsHeader = true; 2094 } 2095 @Render(cell) 2096 } 2097 </tr> 2098 } 2099 @using Dynamicweb.Rapido.Blocks.Components.General 2100 @using Dynamicweb.Rapido.Blocks.Components 2101 @using Dynamicweb.Core 2102 2103 @helper RenderTableCell(TableCell settings) 2104 { 2105 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2106 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2107 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2108 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2109 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2110 2111 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2112 2113 string tagName = settings.IsHeader ? "th" : "td"; 2114 2115 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2116 @settings.Content 2117 @("</" + tagName + ">"); 2118 } 2119 @using System.Linq 2120 @using Dynamicweb.Rapido.Blocks.Components.General 2121 2122 @* Component *@ 2123 2124 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2125 { 2126 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2127 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2128 2129 if (settings.NumberOfPages > 1) 2130 { 2131 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2132 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2133 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2134 2135 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2136 @if (settings.ShowPagingInfo) 2137 { 2138 <div class="pager__info dw-mod"> 2139 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2140 </div> 2141 } 2142 <ul class="pager__list dw-mod"> 2143 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2144 { 2145 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2146 } 2147 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2148 { 2149 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2150 } 2151 @if (settings.GetPages().Any()) 2152 { 2153 foreach (var page in settings.GetPages()) 2154 { 2155 @Render(page) 2156 } 2157 } 2158 else 2159 { 2160 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2161 { 2162 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2163 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2164 } 2165 } 2166 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2167 { 2168 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2169 } 2170 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2171 { 2172 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2173 } 2174 </ul> 2175 </div> 2176 } 2177 } 2178 2179 @helper RenderPaginationItem(PaginationItem settings) 2180 { 2181 if (settings.Icon == null) 2182 { 2183 settings.Icon = new Icon(); 2184 } 2185 2186 settings.Icon.Label = settings.Label; 2187 <li class="pager__btn dw-mod"> 2188 @if (settings.IsActive) 2189 { 2190 <span class="pager__num pager__num--current dw-mod"> 2191 @Render(settings.Icon) 2192 </span> 2193 } 2194 else 2195 { 2196 <a href="@settings.Link" class="pager__num dw-mod"> 2197 @Render(settings.Icon) 2198 </a> 2199 } 2200 </li> 2201 } 2202 2203 2204 @using Dynamicweb.Rapido.Blocks.Components.General 2205 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2206 2207 2208 @using Dynamicweb.Rapido.Blocks.Components 2209 @using Dynamicweb.Rapido.Blocks.Components.General 2210 @using Dynamicweb.Rapido.Blocks 2211 @using System.IO 2212 2213 2214 @using Dynamicweb.Rapido.Blocks.Components.General 2215 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2216 2217 2218 @* Component *@ 2219 2220 @helper RenderVariantMatrix(VariantMatrix settings) { 2221 if (settings != null) 2222 { 2223 int productLoopCounter = 0; 2224 int groupCount = 0; 2225 List<VariantOption> firstDimension = new List<VariantOption>(); 2226 List<VariantOption> secondDimension = new List<VariantOption>(); 2227 List<VariantOption> thirdDimension = new List<VariantOption>(); 2228 2229 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 2230 { 2231 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 2232 { 2233 if (groupCount == 0) { 2234 firstDimension.Add(variantOptions); 2235 } 2236 if (groupCount == 1) 2237 { 2238 secondDimension.Add(variantOptions); 2239 } 2240 if (groupCount == 2) 2241 { 2242 thirdDimension.Add(variantOptions); 2243 } 2244 } 2245 groupCount++; 2246 } 2247 2248 int rowCount = 0; 2249 int columnCount = 0; 2250 2251 <script> 2252 var variantsCollection = []; 2253 </script> 2254 2255 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 2256 @if (groupCount == 1) 2257 { 2258 <tbody> 2259 @foreach (VariantOption firstVariantOption in firstDimension) 2260 { 2261 var variantId = firstVariantOption.Id; 2262 <tr> 2263 <td class="u-bold"> 2264 @firstVariantOption.Name 2265 </td> 2266 <td> 2267 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2268 </td> 2269 </tr> 2270 productLoopCounter++; 2271 } 2272 2273 <tr> 2274 <td>&nbsp;</td> 2275 <td> 2276 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2277 </td> 2278 </tr> 2279 </tbody> 2280 } 2281 @if (groupCount == 2) 2282 { 2283 <thead> 2284 <tr> 2285 <td>&nbsp;</td> 2286 @foreach (VariantOption variant in secondDimension) 2287 { 2288 <td>@variant.Name</td> 2289 } 2290 </tr> 2291 </thead> 2292 <tbody> 2293 @foreach (VariantOption firstVariantOption in firstDimension) 2294 { 2295 string variantId = ""; 2296 columnCount = 0; 2297 2298 <tr> 2299 <td class="u-min-w120px">@firstVariantOption.Name</td> 2300 2301 @foreach (VariantOption secondVariantOption in secondDimension) 2302 { 2303 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 2304 <td> 2305 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2306 </td> 2307 2308 columnCount++; 2309 2310 productLoopCounter++; 2311 } 2312 2313 <td> 2314 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2315 </td> 2316 </tr> 2317 2318 rowCount++; 2319 } 2320 2321 @{ 2322 columnCount = 0; 2323 } 2324 2325 <tr> 2326 <td>&nbsp;</td> 2327 @foreach (VariantOption secondVariantOption in secondDimension) 2328 { 2329 <td> 2330 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2331 </td> 2332 2333 columnCount++; 2334 } 2335 <td>&nbsp;</td> 2336 </tr> 2337 </tbody> 2338 } 2339 @if (groupCount == 3) 2340 { 2341 <thead> 2342 <tr> 2343 <td>&nbsp;</td> 2344 @foreach (VariantOption thirdVariantOption in thirdDimension) 2345 { 2346 <td>@thirdVariantOption.Name</td> 2347 } 2348 </tr> 2349 </thead> 2350 <tbody> 2351 @foreach (VariantOption firstVariantOption in firstDimension) 2352 { 2353 int colspan = (thirdDimension.Count + 1); 2354 2355 <tr> 2356 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 2357 </tr> 2358 2359 foreach (VariantOption secondVariantOption in secondDimension) 2360 { 2361 string variantId = ""; 2362 columnCount = 0; 2363 2364 <tr> 2365 <td class="u-min-w120px">@secondVariantOption.Name</td> 2366 2367 @foreach (VariantOption thirdVariantOption in thirdDimension) 2368 { 2369 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 2370 2371 <td> 2372 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2373 </td> 2374 2375 columnCount++; 2376 productLoopCounter++; 2377 } 2378 2379 <td> 2380 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2381 </td> 2382 </tr> 2383 rowCount++; 2384 } 2385 } 2386 2387 @{ 2388 columnCount = 0; 2389 } 2390 2391 <tr> 2392 <td>&nbsp;</td> 2393 @foreach (VariantOption thirdVariantOption in thirdDimension) 2394 { 2395 <td> 2396 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2397 </td> 2398 2399 columnCount++; 2400 } 2401 <td>&nbsp;</td> 2402 </tr> 2403 </tbody> 2404 } 2405 </table> 2406 2407 <script> 2408 document.addEventListener("DOMContentLoaded", function (event) { 2409 MatrixUpdateQuantity("@settings.ProductId"); 2410 }); 2411 2412 MatrixUpdateQuantity = function (productId) { 2413 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 2414 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 2415 2416 var qtyRowArr = []; 2417 var qtyColumnArr = []; 2418 2419 var totalQty = 0; 2420 2421 for (var i = 0; i < allQtyFields.length; i++) { 2422 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 2423 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 2424 } 2425 2426 for (var i = 0; i < allQtyFields.length; i++) { 2427 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 2428 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 2429 totalQty += parseFloat(allQtyFields[i].value); 2430 } 2431 2432 //Update row counters 2433 for (var i = 0; i < qtyRowArr.length; i++) { 2434 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2435 2436 if (qtyRowArr[i] != undefined && qtyCounter != null) { 2437 var currentCount = qtyCounter.innerHTML; 2438 qtyCounter.innerHTML = qtyRowArr[i]; 2439 2440 if (currentCount != qtyCounter.innerHTML) { 2441 qtyCounter.classList.add("qty-field--active"); 2442 } 2443 } 2444 2445 } 2446 2447 //Update column counters 2448 for (var i = 0; i < qtyColumnArr.length; i++) { 2449 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2450 2451 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 2452 var currentCount = qtyCounter.innerHTML; 2453 qtyCounter.innerHTML = qtyColumnArr[i]; 2454 2455 if (currentCount != qtyCounter.innerHTML) { 2456 qtyCounter.classList.add("qty-field--active"); 2457 } 2458 } 2459 } 2460 2461 if (document.getElementById("TotalQtyCount_" + productId)) { 2462 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 2463 } 2464 2465 //Clean up animations 2466 setTimeout(function () { 2467 for (var i = 0; i < qtyRowArr.length; i++) { 2468 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2469 if (qtyCounter != null) { 2470 qtyCounter.classList.remove("qty-field--active"); 2471 } 2472 } 2473 for (var i = 0; i < qtyColumnArr.length; i++) { 2474 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2475 if (qtyCounter != null) { 2476 qtyCounter.classList.remove("qty-field--active"); 2477 } 2478 } 2479 }, 1000); 2480 } 2481 </script> 2482 } 2483 } 2484 2485 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 2486 { 2487 string loopCount = productLoopCounter.ToString(); 2488 2489 bool combinationFound = false; 2490 double stock = 0; 2491 double quantityValue = 0; 2492 string note = ""; 2493 2494 VariantProduct variantProduct = null; 2495 2496 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 2497 { 2498 stock = variantProduct.Stock; 2499 quantityValue = variantProduct.Quantity; 2500 combinationFound = true; 2501 } 2502 2503 if (combinationFound) 2504 { 2505 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 2506 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 2507 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 2508 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 2509 <input type="number" name="Quantity@(loopCount)" id="Quantity_@(settings.ProductId)_@variantId" value="@quantityValue" min="0" class="js-qty u-no-margin u-full-max-width" style="width: 100%; max-width: 100%" onkeyup="MatrixUpdateQuantity('@settings.ProductId')" onmouseup="MatrixUpdateQuantity('@settings.ProductId')" data-qty-row-group="@rowCount" data-qty-column-group="@columnCount"> 2510 2511 if (stock != 0) 2512 { 2513 <small>@Translate("Stock") @stock</small> 2514 } 2515 2516 <script> 2517 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 2518 variantsCollection.push(variants); 2519 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 2520 </script> 2521 } 2522 else 2523 { 2524 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 2525 } 2526 } 2527 @using System 2528 @using Dynamicweb.Rapido.Blocks.Components 2529 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2530 @using Nevotex.Data.Entities 2531 @* Component *@ 2532 2533 @helper RenderAddToCart(CustomAddToCart settings) 2534 { 2535 //set Id for quantity selector to get it's value from button 2536 if (settings.QuantitySelector != null) 2537 { 2538 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 2539 { 2540 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 2541 } 2542 2543 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 2544 2545 if (settings.Disabled) 2546 { 2547 settings.QuantitySelector.Disabled = true; 2548 } 2549 2550 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 2551 { 2552 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 2553 } 2554 } 2555 2556 if (settings.Disabled) 2557 { 2558 settings.AddButton.Disabled = true; 2559 } 2560 2561 settings.AddButton.CssClass += " btn--condensed"; 2562 2563 //unitsSelector 2564 if (settings.UnitSelector != null) 2565 { 2566 if (settings.Disabled) 2567 { 2568 settings.QuantitySelector.Disabled = true; 2569 } 2570 } 2571 2572 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2573 @if (settings.UnitSelector != null) 2574 { 2575 @Render(settings.UnitSelector) 2576 } 2577 @if (settings.QuantitySelector != null) 2578 { 2579 @Render(settings.QuantitySelector) 2580 } 2581 @Render(settings.AddButton) 2582 </div> 2583 } 2584 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2585 @using Dynamicweb.Rapido.Blocks.Components.General 2586 @using Nevotex.Data.Entities 2587 2588 @* Component *@ 2589 2590 @helper RenderAddToCartButton(CustomAddToCartBtn settings) 2591 { 2592 if (!settings.HideTitle) 2593 { 2594 if (string.IsNullOrEmpty(settings.Title)) 2595 { 2596 if (settings.BuyForPoints) 2597 { 2598 settings.Title = Translate("Buy with points"); 2599 } 2600 else 2601 { 2602 settings.Title = Translate("Add to cart"); 2603 } 2604 } 2605 } 2606 else 2607 { 2608 settings.Title = ""; 2609 } 2610 2611 if (settings.Icon == null) 2612 { 2613 settings.Icon = new Icon(); 2614 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 2615 } 2616 2617 if (string.IsNullOrEmpty(settings.Icon.Name)) 2618 { 2619 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 2620 } 2621 2622 var errorMessage = Translate("Felaktigt antal, köp kan endast göras i jämt antal av"); 2623 2624 settings.OnClick = "if(CheckMultiple('Quantity_" + settings.ProductId + "', '{{multiple}}'))Cart.AddToCart(event, { " + 2625 "id: '" + settings.ProductId + "'," + 2626 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 2627 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 2628 (settings.BuyForPoints ? "buyForPoints: true," : "") + 2629 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 2630 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 2631 "});" + settings.OnClick; 2632 2633 @RenderButton(settings) 2634 } 2635 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2636 2637 @* Component *@ 2638 2639 @helper RenderUnitSelector(UnitSelector settings) 2640 { 2641 if (string.IsNullOrEmpty(settings.Id)) 2642 { 2643 settings.Id = Guid.NewGuid().ToString("N"); 2644 } 2645 var disabledClass = settings.Disabled ? "disabled" : ""; 2646 2647 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 2648 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2649 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 2650 <div class="dropdown__content dw-mod"> 2651 @settings.OptionsContent 2652 </div> 2653 <label class="dropdown-trigger-off" for="@settings.Id"></label> 2654 </div> 2655 } 2656 @using System.Reflection 2657 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2658 2659 @* Component *@ 2660 2661 @helper RenderQuantitySelector(QuantitySelector settings) 2662 { 2663 var attributes = new Dictionary<string, string>(); 2664 2665 /*base settings*/ 2666 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2667 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2668 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2669 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2670 if (settings.Required) { attributes.Add("required", "true"); } 2671 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2672 /*end*/ 2673 2674 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 2675 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 2676 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 2677 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 2678 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 2679 if (settings.Min == null) { settings.Min = 1; } 2680 attributes.Add("min", settings.Min.ToString()); 2681 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 2682 if (settings.Value == null) { settings.Value = 1; } 2683 attributes.Add("value", settings.Value.ToString()); 2684 attributes.Add("type", "number"); 2685 2686 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2687 2688 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2689 } 2690 @using Dynamicweb.Rapido.Blocks.Components 2691 2692 @using Dynamicweb.Frontend 2693 @using Dynamicweb.Frontend.Devices 2694 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2695 @using Dynamicweb.Rapido.Blocks.Components.General 2696 @using System.Collections.Generic; 2697 2698 @* Component *@ 2699 2700 @helper RenderCustomerCenterList(CustomerCenterList settings) 2701 { 2702 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 2703 string hideActions = isTouchDevice ? "u-block" : ""; 2704 2705 <table class="table data-list dw-mod"> 2706 @if (settings.GetHeaders().Length > 0) { 2707 <thead> 2708 <tr class="u-bold"> 2709 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 2710 { 2711 var attributes = new Dictionary<string, string>(); 2712 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 2713 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 2714 attributes.Add("align", header.Align.ToString()); 2715 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2716 2717 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 2718 } 2719 </tr> 2720 </thead> 2721 } 2722 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 2723 { 2724 int columnCount = 0; 2725 int totalColumns = listItem.GetInfoItems().Length; 2726 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : ""; 2727 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 2728 2729 var attributes = new Dictionary<string, string>(); 2730 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 2731 2732 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2733 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 2734 <tr> 2735 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 2736 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 2737 2738 <td rowspan="2" @onClick class="data-list__main-item dw-mod"> 2739 @if (!string.IsNullOrEmpty(listItem.Title)) { 2740 <div class="u-bold">@listItem.Title</div> 2741 } 2742 @if (!string.IsNullOrEmpty(listItem.Description)) { 2743 <div>@listItem.Description</div> 2744 } 2745 </td> 2746 } 2747 2748 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 2749 { 2750 var infoAttributes = new Dictionary<string, string>(); 2751 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 2752 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 2753 infoAttributes.Add("align", infoItem.Align.ToString()); 2754 2755 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2756 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 2757 2758 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 2759 @if (!string.IsNullOrEmpty(infoItem.Title)) { 2760 <div>@infoItem.Title</div> 2761 } 2762 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 2763 <div><small>@infoItem.Subtitle</small></div> 2764 } 2765 </td> 2766 2767 columnCount++; 2768 } 2769 </tr> 2770 <tr> 2771 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 2772 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 2773 @foreach (ButtonBase action in listItem.GetActions()) 2774 { 2775 action.ButtonLayout = ButtonLayout.LinkClean; 2776 action.Icon.CssClass += " u-full-height"; 2777 action.CssClass += " data-list__action-button link"; 2778 2779 @Render(action) 2780 } 2781 </div> 2782 </td> 2783 </tr> 2784 </tbody> 2785 } 2786 </table> 2787 } 2788 2789 @* Include the Blocks for the page *@ 2790 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2791 @using Dynamicweb.Core 2792 @using System 2793 @using System.Web 2794 @using System.Collections.Generic 2795 @using Dynamicweb.Rapido.Blocks 2796 2797 @{ 2798 BlocksPage productListProductsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 2799 2800 Block productsBlock = new Block 2801 { 2802 Id = "Views", 2803 SortId = 30, 2804 Template = RenderProducts() 2805 }; 2806 2807 productListProductsBlocksPage.Add("ProductList", productsBlock); 2808 } 2809 2810 @helper RenderProducts() 2811 { 2812 @*This is part of a script template *@ 2813 2814 <div id="ProductsContainer" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod grid--align-content-start" data-save-cookie="true"> 2815 {{#ProductsContainer}} 2816 {{> (lookup . 'template') }} 2817 {{/ProductsContainer}} 2818 </div> 2819 } 2820 2821 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2822 @using Dynamicweb.Core 2823 @using System 2824 @using System.Web 2825 @using System.Collections.Generic 2826 @using Dynamicweb.Rapido.Blocks 2827 @using Dynamicweb.Rapido.Services 2828 2829 @functions { 2830 BlocksPage listViewPage = BlocksPage.GetBlockPage("ProductList"); 2831 Dynamicweb.Frontend.ItemViewModel listViewSettings = null; 2832 } 2833 2834 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableListView")) 2835 { 2836 listViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("ListView"); 2837 2838 listViewPage.Add("Views", new Block 2839 { 2840 Id = "ProductItemContainer", 2841 Name = "th-list", 2842 SortId = 10 2843 }); 2844 2845 Block listViewScripts = new Block 2846 { 2847 Id = "ListViewScripts", 2848 SortId = 20, 2849 Template = ListView(), 2850 BlocksList = new List<Block> { 2851 new Block 2852 { 2853 Id = "ListViewItem", 2854 SortId = 10, 2855 Template = RenderListViewItem(), 2856 SkipRenderBlocksList = true, 2857 BlocksList = new List<Block> { 2858 new Block 2859 { 2860 Id = "ListViewItemHiddenProperties", 2861 SortId = 10, 2862 Template = RenderListViewItemHiddenProperties() 2863 }, 2864 new Block 2865 { 2866 Id = "ListViewItemLeft", 2867 SortId = 10, 2868 SkipRenderBlocksList = true, 2869 Template = RenderListViewItemLeft(), 2870 BlocksList = new List<Block> { 2871 new Block 2872 { 2873 Id = "ListViewItemImage", 2874 SortId = 10, 2875 Template = RenderListViewItemImage() 2876 }, 2877 new Block 2878 { 2879 Id = "ListViewItemStickers", 2880 SortId = 20, 2881 Template = RenderListViewItemStickers() 2882 } 2883 } 2884 }, 2885 new Block 2886 { 2887 Id = "ListViewItemRight", 2888 SortId = 20, 2889 Design = new Design 2890 { 2891 RenderType = RenderType.Column, 2892 Size = "auto", 2893 CssClass = "product-list__list-item__right" 2894 }, 2895 BlocksList = new List<Block> { 2896 new Block 2897 { 2898 Id = "ListViewItemInfoContainer", 2899 SortId = 10, 2900 Design = new Design 2901 { 2902 RenderType = RenderType.None 2903 }, 2904 BlocksList = new List<Block> { 2905 new Block { 2906 Id = "ListViewItemInfoContainerLeft", 2907 SortId = 10, 2908 Design = new Design 2909 { 2910 CssClass = "u-pull--left" 2911 }, 2912 BlocksList = new List<Block> { 2913 new Block 2914 { 2915 Id = "ListViewItemTitle", 2916 SortId = 10, 2917 Template = RenderListViewItemTitle() 2918 } 2919 } 2920 }, 2921 new Block { 2922 Id = "ListViewItemInfoContainerRight", 2923 SortId = 20, 2924 Design = new Design 2925 { 2926 CssClass = "u-pull--right" 2927 } 2928 } 2929 } 2930 }, 2931 new Block 2932 { 2933 Id = "ListViewItemDescription", 2934 SortId = 20, 2935 Template = RenderListViewItemDescription() 2936 }, 2937 new Block 2938 { 2939 Id = "ListViewItemFooter", 2940 SortId = 50, 2941 SkipRenderBlocksList = true, 2942 Template = RenderListViewItemFooter(), 2943 BlocksList = new List<Block> { 2944 new Block 2945 { 2946 Id = "ListViewItemActions", 2947 SortId = 20, 2948 Template = RenderListViewItemActions() 2949 } 2950 } 2951 } 2952 } 2953 } 2954 } 2955 } 2956 } 2957 }; 2958 listViewPage.Add("BottomSnippets", listViewScripts); 2959 2960 //number 2961 bool listViewShowNumber = listViewSettings.GetBoolean("ShowProductNumber"); 2962 2963 if (listViewShowNumber) 2964 { 2965 listViewPage.Add("ListViewItemInfoContainerLeft", new Block 2966 { 2967 Id = "ListViewItemNumber", 2968 SortId = 20, 2969 Template = RenderListViewItemNumber() 2970 }); 2971 } 2972 2973 //stock 2974 bool listViewShowStock = listViewSettings.GetBoolean("ShowStockAndShipping"); 2975 if (User.IsStockInfoAllowed() && listViewShowStock) 2976 { 2977 listViewPage.Add("ListViewItemInfoContainerLeft", new Block 2978 { 2979 Id = "ListViewItemStock", 2980 SortId = 30, 2981 Template = RenderListViewItemStock() 2982 }); 2983 } 2984 2985 //favorites 2986 bool listViewShowFavoriteButton = !listViewSettings.GetBoolean("HideFavoriteButton"); 2987 2988 if (listViewShowFavoriteButton) 2989 { 2990 listViewPage.Add("ListViewItemInfoContainerRight", new Block 2991 { 2992 Id = "ListViewItemFavorites", 2993 SortId = 10, 2994 Template = RenderListViewItemFavorites() 2995 }); 2996 } 2997 2998 //variant selector 2999 bool listViewShowCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 3000 bool listViewShowVariantSelector = listViewSettings.GetList("Variants").SelectedValue == "selector"; 3001 if (listViewShowCartButton && listViewShowVariantSelector) 3002 { 3003 listViewPage.Add("ListViewItemRight", new Block 3004 { 3005 Id = "ListViewItemVariantSelector", 3006 SortId = 30, 3007 Template = RenderListViewItemVariantSelector() 3008 }); 3009 } 3010 3011 //static variants 3012 bool listViewShowStaticVariants = listViewSettings.GetList("Variants").SelectedValue == "static"; 3013 3014 if (listViewShowStaticVariants) 3015 { 3016 listViewPage.Add("ListViewItemRight", new Block 3017 { 3018 Id = "ListViewItemStaticVariants", 3019 SortId = 40, 3020 Template = RenderListViewItemStaticVariants() 3021 }); 3022 } 3023 3024 //download button 3025 bool listViewShowAddToDownloadButton = listViewSettings.GetBoolean("ShowAddToDownloadButton"); 3026 if (listViewShowAddToDownloadButton && Pageview.User != null) 3027 { 3028 listViewPage.Add("ListViewItemRight", new Block 3029 { 3030 Id = "ListViewItemDownloadButton", 3031 SortId = 60, 3032 Template = RenderListViewItemDownloadButton() 3033 }); 3034 } 3035 3036 //price 3037 bool listViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 3038 if (listViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 3039 { 3040 listViewPage.Add("ListViewItemFooter", new Block 3041 { 3042 Id = "ListViewItemPrice", 3043 SortId = 10, 3044 Template = RenderListViewItemPrice() 3045 }); 3046 } 3047 } 3048 3049 @helper ListView() 3050 { 3051 <script id="ProductItemContainer" type="text/x-template"> 3052 {{#.}} 3053 <div id="Product{{id}}" class="grid__col-12 js-product dw-mod" data-template="ListViewItem" data-preloader="overlay"> 3054 {{#Product}} 3055 {{>ListViewItem}} 3056 {{/Product}} 3057 </div> 3058 {{/.}} 3059 </script> 3060 } 3061 3062 @helper RenderListViewItem() 3063 { 3064 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItem"); 3065 3066 <script id="ListViewItem" type="text/x-template"> 3067 {{#.}} 3068 <div class="grid product-list__list-item dw-mod js-product-scroll-trigger" data-params="{{googleImpression}}"> 3069 @RenderBlockList(subBlocks) 3070 </div> 3071 {{/.}} 3072 </script> 3073 } 3074 3075 @helper RenderListViewItemHiddenProperties() 3076 { 3077 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 3078 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 3079 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 3080 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 3081 <input type="hidden" name="Quantity{{id}}" value="1" id="Quantity_{{id}}" /> 3082 } 3083 3084 @helper RenderListViewItemLeft() 3085 { 3086 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItemLeft"); 3087 3088 string imageZoomOnHover = listViewSettings.GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 3089 3090 <div class="grid__col-md-4 {{noImage}} product-list__list-item__left u-no-padding u-color-light--bg dw-mod @imageZoomOnHover"> 3091 <div class="grid__cell"> 3092 @RenderBlockList(subBlocks) 3093 </div> 3094 </div> 3095 } 3096 3097 @helper RenderListViewItemImage() 3098 { 3099 bool secondaryImage = listViewSettings.GetString("HoverAlternatineImage") != null ? listViewSettings.GetBoolean("HoverAlternatineImage") : false; 3100 3101 <a href="{{link}}" 3102 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 3103 title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" 3104 class="u-position-relative u-block image-hover__wrapper dw-mod"> 3105 <img class="grid__cell-img grid__cell-img--centered b-lazy" src="/Files/Images/placeholder.gif" 3106 data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;DoNotUpscale=true&amp;FillCanvas=true&amp;image={{image}}" 3107 @if (secondaryImage) { 3108 <text> 3109 {{#if secondaryImage}} 3110 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 3111 {{/if}} 3112 </text> 3113 } 3114 alt="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" /> 3115 </a> 3116 } 3117 3118 @helper RenderListViewItemStickers() 3119 { 3120 <text> 3121 {{#StickersContainers}} 3122 {{>StickersContainer}} 3123 {{/StickersContainers}} 3124 </text> 3125 } 3126 3127 @helper RenderListViewItemTitle() 3128 { 3129 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}"> 3130 <h2 class="u-no-margin">{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}</h2> 3131 </a> 3132 } 3133 3134 @helper RenderListViewItemNumber() 3135 { 3136 <div class="item-number dw-mod">{{number}}</div> 3137 } 3138 3139 @helper RenderListViewItemStock() 3140 { 3141 <text>{{#if stockText}}</text> 3142 <div> 3143 <span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> 3144 <span class="u-margin-right--lg"> {{stockText}}</span> 3145 {{deliveryText}} 3146 </div> 3147 <text>{{/if}}</text> 3148 } 3149 3150 @helper RenderListViewItemFavorites() 3151 { 3152 <div class="favorites u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 3153 {{#Favorite}} 3154 {{>FavoriteTemplate}} 3155 {{/Favorite}} 3156 </div> 3157 } 3158 3159 @helper RenderListViewItemDescription() 3160 { 3161 <div class="u-margin-top u-margin-bottom"> 3162 {{{description}}} 3163 </div> 3164 } 3165 3166 @helper RenderListViewItemVariantSelector() 3167 { 3168 string pageId = GetGlobalValue("Global:Page.ID"); 3169 var ecommerceSettings = Pageview.AreaSettings.GetItem("Ecommerce"); 3170 string variantsLayout = ecommerceSettings.GetString("VariantsLayout") != null ? ecommerceSettings.GetList("VariantsLayout").SelectedValue : "buttons"; 3171 3172 <div data-template="VariantsTemplate" class="js-variants grid__cell" data-combinations="{{combinationsStringArray}}" data-variants="{{variantsStringArray}}" data-variant-selections="{{variantSelections}}" data-total-variant-groups="{{variantGroupsCount}}" data-selection-complete="UpdateData" data-page-id="@pageId" data-product-id="{{productId}}"> 3173 {{#Variants}} 3174 @if (variantsLayout == "buttons") { 3175 <text>{{>VariantsTemplate}}</text> 3176 } else { 3177 <text>{{>DropdownVariantsTemplate}}</text> 3178 } 3179 {{/Variants}} 3180 </div> 3181 <small class="js-help-text help-text {{hideViewMore}} {{hideHelpText}}">@Translate("Please select variant!")</small> 3182 } 3183 3184 @helper RenderListViewItemStaticVariants() 3185 { 3186 string variantsSize = listViewSettings.GetList("StaticVariantsDisplay") != null ? listViewSettings.GetList("StaticVariantsDisplay").SelectedValue : "sm"; 3187 3188 <text> 3189 {{#Variants}} 3190 @if ( variantsSize == "lg" ) { 3191 <text> 3192 {{>StaticVariantsLgTemplate}} 3193 </text> 3194 } else { 3195 <text> 3196 {{>StaticVariantsTemplate}} 3197 </text> 3198 } 3199 {{/Variants}} 3200 3201 {{#ifCond variantGroupsCount '>' 1}} 3202 <div class="static-variant"> 3203 @Translate("More options available") 3204 </div> 3205 {{/ifCond}} 3206 </text> 3207 } 3208 3209 @helper RenderListViewItemFooter() 3210 { 3211 List<Block> subBlocks = listViewPage.GetBlockListById("ListViewItemFooter"); 3212 3213 if (Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 3214 { 3215 <div class="grid__cell-footer"> 3216 <div class="grid__cell"> 3217 <div class="product-list__list-item__price-actions dw-mod"> 3218 @RenderBlockList(subBlocks) 3219 </div> 3220 </div> 3221 </div> 3222 } 3223 else 3224 { 3225 <button type="button" id="CartButton_{{id}}" class="u-hidden"></button> 3226 } 3227 } 3228 3229 @helper RenderListViewItemPrice() 3230 { 3231 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3232 bool showCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 3233 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 3234 bool isPricesWithVATEnabled = Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat; 3235 3236 <div class="u-margin-bottom"> 3237 @if (pointShopOnly) 3238 { 3239 <text> 3240 {{#if havePointPrice}} 3241 <div class="price price--product-list dw-mod">{{points}} @Translate("points")</div> 3242 @if (showCartButton) 3243 { 3244 <text> 3245 {{#unless canBePurchasedWithPoints}} 3246 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 3247 {{/unless}} 3248 </text> 3249 } 3250 {{else}} 3251 @Translate("Not available") 3252 {{/if}} 3253 </text> 3254 3255 } 3256 else 3257 { 3258 <div class="price price--product-list dw-mod">{{price}}</div> 3259 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 3260 if (showVATPrice) 3261 { 3262 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 3263 @if (isPricesWithVATEnabled) 3264 { 3265 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 3266 } 3267 else 3268 { 3269 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 3270 } 3271 </div> 3272 } 3273 <text> 3274 {{#if priceRRP}} 3275 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 3276 {{/if}} 3277 </text> 3278 } 3279 </div> 3280 } 3281 3282 @helper RenderListViewItemViewButton() 3283 { 3284 string viewMoreText = listViewSettings.GetString("ViewMoreText"); 3285 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 3286 3287 @Render(new Link 3288 { 3289 Href = "{{link}}", 3290 Id = "CartButton_{{id}}", 3291 Title = Translate(viewMoreText), 3292 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 3293 ButtonLayout = ButtonLayout.Secondary, 3294 CssClass = "u-no-margin" 3295 }); 3296 } 3297 3298 @helper RenderListViewItemAddToCart() 3299 { 3300 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3301 3302 var addToCartBtn = new AddToCart 3303 { 3304 WrapperCssClass = "buttons-collection--right", 3305 AddButton = new AddToCartButton 3306 { 3307 HideTitle = false, 3308 ProductId = "{{productId}}", 3309 VariantId = "{{variantid}}", 3310 UnitId = "{{unitId}}", 3311 ProductInfo = "{{productInfo}}", 3312 BuyForPoints = pointShopOnly, 3313 OnClick = "{{facebookPixelAction}}", 3314 ExtraAttributes = new Dictionary<string, string> 3315 { 3316 { "{{disabledBuyButton}}", "" } 3317 } 3318 } 3319 }; 3320 3321 if (!pointShopOnly) 3322 { 3323 addToCartBtn.QuantitySelector = new QuantitySelector 3324 { 3325 Id = "Quantity{{id}}" 3326 }; 3327 } 3328 3329 addToCartBtn.UnitSelector = new UnitSelector 3330 { 3331 OptionsContent = "{{#unitOptions}}{{>UnitOption}}{{/unitOptions}}", 3332 Id = "UnitOptions_{{id}}", 3333 SelectedOption = "{{unitName}}", 3334 CssClass = "{{#if hasOnlyOneUnit}}unit-selector--readonly{{/if}} {{hasUnits}}" 3335 }; 3336 3337 @Render(addToCartBtn) 3338 } 3339 3340 @helper RenderListViewItemActions() 3341 { 3342 bool showCartButton = listViewSettings.GetBoolean("ShowAddToCartButton"); 3343 bool showViewButton = listViewSettings.GetBoolean("ShowViewButton"); 3344 bool hasVariantSelector = listViewSettings.GetList("Variants") != null && listViewSettings.GetList("Variants").SelectedValue == "selector"; 3345 3346 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3347 { 3348 if (showCartButton) 3349 { 3350 if (!showViewButton || hasVariantSelector) 3351 { 3352 <text>{{#if hideAddToCartButton}}</text> 3353 <div>@RenderListViewItemViewButton()</div> 3354 <text>{{else}}</text> 3355 @RenderListViewItemAddToCart() 3356 <text>{{/if}}</text> 3357 } 3358 else 3359 { 3360 <div>@RenderListViewItemViewButton()</div> 3361 } 3362 } 3363 else if (showViewButton) 3364 { 3365 <div>@RenderListViewItemViewButton()</div> 3366 } 3367 } 3368 else if (showViewButton) 3369 { 3370 <div>@RenderListViewItemViewButton()</div> 3371 } 3372 } 3373 3374 @helper RenderListViewItemDownloadButton() 3375 { 3376 <div class="grid__cell-footer u-margin-top"> 3377 <div class="grid__cell"> 3378 <button type="button" class="btn btn--primary btn--condensed u-no-margin u-pull--right dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 3379 <i class="fas fa-plus js-button-icon"></i> 3380 <span class="js-button-text">@Translate("Add")</span> 3381 </button> 3382 </div> 3383 </div> 3384 } 3385 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3386 @using Dynamicweb.Core 3387 @using System 3388 @using System.Web 3389 @using System.Collections.Generic 3390 @using Dynamicweb.Rapido.Blocks 3391 @using Dynamicweb.Rapido.Blocks.Components 3392 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3393 @using Dynamicweb.Rapido.Blocks.Components.General 3394 @using Dynamicweb.Rapido.Services 3395 3396 @functions { 3397 BlocksPage gridViewPage = BlocksPage.GetBlockPage("ProductList"); 3398 Dynamicweb.Frontend.ItemViewModel gridViewSettings = null; 3399 } 3400 3401 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableGridView")) 3402 { 3403 gridViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView"); 3404 3405 BlocksPage gridViewPage = BlocksPage.GetBlockPage("ProductList"); 3406 3407 gridViewPage.Add("Views", new Block 3408 { 3409 Id = "ProductGridItemContainer", 3410 Name = "th", 3411 SortId = 20 3412 }); 3413 3414 Block gridViewScripts = new Block 3415 { 3416 Id = "GridViewScripts", 3417 SortId = 20, 3418 Template = GridView(), 3419 BlocksList = new List<Block> { 3420 new Block 3421 { 3422 Id = "GridViewItem", 3423 SortId = 10, 3424 Template = RenderGridViewItem(), 3425 SkipRenderBlocksList = true, 3426 BlocksList = new List<Block> { 3427 new Block 3428 { 3429 Id = "GridViewItemHiddenProperties", 3430 SortId = 10, 3431 Template = RenderGridViewItemHiddenProperties() 3432 }, 3433 new Block 3434 { 3435 Id = "GridViewItemImageContainer", 3436 SortId = 20, 3437 SkipRenderBlocksList = true, 3438 Template = RenderGridViewItemImageContainer(), 3439 BlocksList = new List<Block> { 3440 new Block 3441 { 3442 Id = "GridViewItemImage", 3443 SortId = 10, 3444 Template = RenderGridViewItemImage() 3445 }, 3446 new Block 3447 { 3448 Id = "GridViewItemStickers", 3449 SortId = 20, 3450 Template = RenderGridViewItemStickers() 3451 } 3452 } 3453 }, 3454 new Block 3455 { 3456 Id = "GridViewItemInfoContainer", 3457 SortId = 30, 3458 SkipRenderBlocksList = true, 3459 Template = RenderGridViewItemInfoContainer(), 3460 BlocksList = new List<Block> { 3461 new Block 3462 { 3463 Id = "GridViewItemTitle", 3464 SortId = 10, 3465 Template = RenderGridViewItemTitle() 3466 } 3467 } 3468 }, 3469 new Block 3470 { 3471 Id = "GridViewItemFooter", 3472 SortId = 40, 3473 SkipRenderBlocksList = true, 3474 Template = RenderGridViewItemFooter(), 3475 BlocksList = new List<Block> { 3476 new Block 3477 { 3478 Id = "GridViewItemActions", 3479 SortId = 10, 3480 Template = RenderGridViewItemActions() 3481 } 3482 } 3483 } 3484 } 3485 } 3486 } 3487 }; 3488 3489 3490 3491 3492 3493 gridViewPage.Add("BottomSnippets", gridViewScripts); 3494 3495 //favorites 3496 bool gridViewShowFavoriteButton = !gridViewSettings.GetBoolean("HideFavoriteButton"); 3497 3498 if (gridViewShowFavoriteButton) 3499 { 3500 gridViewPage.Add("GridViewItemImageContainer", new Block 3501 { 3502 Id = "GridViewItemFavorites", 3503 SortId = 30, 3504 Template = RenderGridViewItemFavorites() 3505 }); 3506 } 3507 3508 //number 3509 bool gridViewShowNumber = gridViewSettings.GetBoolean("ShowProductNumber"); 3510 3511 if (gridViewShowNumber) 3512 { 3513 gridViewPage.Add("GridViewItemInfoContainer", new Block 3514 { 3515 Id = "GridViewItemNumber", 3516 SortId = 20, 3517 Template = RenderGridViewItemNumber() 3518 }); 3519 } 3520 3521 3522 3523 3524 //price 3525 bool gridViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 3526 if (gridViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 3527 { 3528 gridViewPage.Add("GridViewItemInfoContainer", new Block 3529 { 3530 Id = "GridViewItemPrice", 3531 SortId = 30, 3532 Template = RenderGridViewItemPrice() 3533 }); 3534 } 3535 3536 //stock 3537 bool gridViewShowStock = gridViewSettings.GetBoolean("ShowStockAndShipping"); 3538 3539 if (User.IsStockInfoAllowed() && gridViewShowStock) 3540 { 3541 gridViewPage.Add("GridViewItemFooter", new Block 3542 { 3543 Id = "GridViewItemStockAndDelivery", 3544 SortId = 20, 3545 Template = RenderGridViewItemStockAndDelivery() 3546 }); 3547 } 3548 3549 //static variants 3550 bool gridViewShowStaticVariants = gridViewSettings.GetBoolean("ShowStaticVariants"); 3551 3552 if (gridViewShowStaticVariants) 3553 { 3554 gridViewPage.Add("GridViewItemFooter", new Block 3555 { 3556 Id = "GridViewItemStaticVariants", 3557 SortId = 30, 3558 Template = RenderGridViewItemStaticVariants() 3559 }); 3560 } 3561 3562 //download button 3563 bool gridViewShowAddToDownloadButton = gridViewSettings.GetBoolean("ShowAddToDownloadButton"); 3564 3565 if (gridViewShowAddToDownloadButton && Pageview.User != null) 3566 { 3567 gridViewPage.Add("GridViewItemFooter", new Block 3568 { 3569 Id = "GridViewItemDownloadButton", 3570 SortId = 40, 3571 Template = RenderGridViewItemDownloadButton() 3572 }); 3573 } 3574 } 3575 3576 @helper GridView() 3577 { 3578 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 3; 3579 string imageZoomOnHover = gridViewSettings.GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 3580 3581 <script id="ProductGridItemContainer" type="text/x-template"> 3582 {{#.}} 3583 <div id="Product{{id}}" data-template="GridViewItem" data-preloader="overlay" class="grid__col-lg-{{columnCss}} grid__col-md-{{columnCss}} grid__col-sm-{{columnCss}} grid__col-xs-6 product-list__grid-item @imageZoomOnHover dw-mod"> 3584 {{#Product}} 3585 {{>GridViewItem}} 3586 {{/Product}} 3587 </div> 3588 {{/.}} 3589 </script> 3590 } 3591 3592 @helper RenderGridViewItem() 3593 { 3594 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItem"); 3595 3596 <script id="GridViewItem" type="text/x-template"> 3597 {{#.}} 3598 <div class="grid__col--auto js-product-scroll-trigger u-no-padding u-full-height" data-params="{{googleImpression}}"> 3599 @RenderBlockList(subBlocks) 3600 </div> 3601 {{/.}} 3602 </script> 3603 } 3604 3605 @helper RenderGridViewItemHiddenProperties() 3606 { 3607 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 3608 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 3609 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 3610 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 3611 <input type="hidden" name="Quantity{{id}}" value="1" id="Quantity_{{id}}" /> 3612 } 3613 3614 @helper RenderGridViewItemImageContainer() 3615 { 3616 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemImageContainer"); 3617 3618 <div class="grid__cell product-list__grid-item__image dw-mod {{imageBorder}} {{noImage}}"> 3619 @RenderBlockList(subBlocks) 3620 </div> 3621 } 3622 3623 @helper RenderGridViewItemImage() 3624 { 3625 bool secondaryImage = gridViewSettings.GetString("HoverAlternatineImage") != null ? gridViewSettings.GetBoolean("HoverAlternatineImage") : false; 3626 3627 <a href="{{link}}" 3628 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 3629 title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" 3630 class="u-block u-position-relative image-hover__wrapper dw-mod"> 3631 <img class="grid__cell-img grid__cell-img--centered u-padding b-lazy" src="/Files/Images/placeholder.gif" 3632 data-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop={{cropMode}}&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{image}}" 3633 @if (secondaryImage) { <text> 3634 {{#if secondaryImage}} 3635 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=300&amp;height=300&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 3636 {{/if}} 3637 </text> } 3638 alt="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" /> 3639 </a> 3640 } 3641 3642 @helper RenderGridViewItemStickers() 3643 { 3644 <text> 3645 {{#StickersContainers}} 3646 {{>StickersContainer}} 3647 {{/StickersContainers}} 3648 </text> 3649 } 3650 3651 @helper RenderGridViewItemFavorites() 3652 { 3653 <div class="favorites favorites--for-grid-view u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 3654 {{#Favorite}} 3655 {{>FavoriteTemplate}} 3656 {{/Favorite}} 3657 </div> 3658 } 3659 3660 @helper RenderGridViewItemInfoContainer() 3661 { 3662 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemInfoContainer"); 3663 3664 <div class="grid__cell product-list__grid-item__price-info dw-mod {{paddingFix}} "> 3665 @RenderBlockList(subBlocks) 3666 </div> 3667 } 3668 3669 @helper RenderGridViewItemTitle() 3670 { 3671 <a href="{{link}}" class="u-color-inherit" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}"> 3672 <h6 class="u-condensed-text u-bold">{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}</h6> 3673 </a> 3674 } 3675 3676 @helper RenderGridViewItemNumber() 3677 { 3678 3679 3680 <div class="item-number dw-mod {{displayCss}} {{hideArticleNumberCss}} ">@Translate("ArtNr", "Art. nr"): {{number}} </div> 3681 3682 3683 3684 // login to see price 3685 bool userLoggedIn = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); 3686 3687 if (!userLoggedIn && (Pageview.AreaID == 21 || Pageview.AreaID == 24 || Pageview.AreaID == 25) ) 3688 { 3689 <div class="u-ta-left dw-mod {{displayCss}}"> 3690 <label for="SignInModalTrigger" class="item-number sign-in-modal-trigger-button" onclick="setTimeout(function () { document.getElementById('LoginUsername').focus() }, 10)"> 3691 @Translate("Logga_in_for_pris_och_kop") 3692 </label> 3693 </div> 3694 } 3695 3696 } 3697 3698 3699 @helper RenderGridViewItemPrice() 3700 { 3701 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 4; 3702 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3703 bool showCartButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("GridView").GetBoolean("ShowAddToCartButton"); 3704 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 3705 bool isPricesWithVATEnabled = Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat; 3706 3707 if (pointShopOnly) 3708 { 3709 <text> 3710 {{#if havePointPrice}} 3711 <div class="price price--product-list dw-mod">{{points}} @Translate("points")</div> 3712 @if (showCartButton) 3713 { 3714 <text> 3715 {{#unless canBePurchasedWithPoints}} 3716 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 3717 {{/unless}} 3718 </text> 3719 } 3720 {{else}} 3721 @Translate("Not available") 3722 {{/if}} 3723 </text> 3724 3725 } 3726 else 3727 { 3728 <div class="price price--product-list dw-mod">{{price}}</div> 3729 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 3730 if (showVATPrice) 3731 { 3732 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 3733 @if (columnsCount <= 4) 3734 { 3735 if (isPricesWithVATEnabled) 3736 { 3737 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 3738 } 3739 else 3740 { 3741 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 3742 } 3743 } 3744 else 3745 { 3746 if (isPricesWithVATEnabled) 3747 { 3748 <div>@Translate("excl. VAT")</div><div>({{priceWithoutVAT}})</div> 3749 } 3750 else 3751 { 3752 <div>@Translate("incl. VAT")</div><div>({{priceWithVAT}})</div> 3753 } 3754 } 3755 </div> 3756 } 3757 <text> 3758 {{#if priceRRP}} 3759 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 3760 {{/if}} 3761 </text> 3762 } 3763 } 3764 3765 @helper RenderGridViewItemFooter() 3766 { 3767 List<Block> subBlocks = gridViewPage.GetBlockListById("GridViewItemFooter"); 3768 bool showStaticVariants = gridViewSettings.GetBoolean("ShowStaticVariants"); 3769 3770 <div class="product-list__grid-item__footer dw-mod {{displayCss}}"> 3771 @RenderBlockList(subBlocks) 3772 </div> 3773 } 3774 3775 @helper RenderGridViewItemViewButton() 3776 { 3777 string viewMoreText = gridViewSettings.GetString("ViewMoreText"); 3778 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 3779 3780 @Render(new Link 3781 { 3782 Href = "{{link}}", 3783 Id = "CartButton_{{id}}", 3784 Title = Translate(viewMoreText), 3785 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 3786 ButtonLayout = ButtonLayout.Secondary, 3787 CssClass = "u-no-margin" 3788 }); 3789 } 3790 3791 @helper RenderGridViewItemAddToCart() 3792 { 3793 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3794 string wrapperClass = "buttons-collection--center"; 3795 int columnsCount = gridViewSettings.GetList("Columns") != null ? Converter.ToInt32(gridViewSettings.GetList("Columns").SelectedValue) : 4; 3796 bool hideButtonText = columnsCount >= 4 || Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet"; 3797 3798 if (pointShopOnly && columnsCount <= 4) 3799 { 3800 hideButtonText = false; 3801 } 3802 3803 var addToCartBtn = new AddToCart 3804 { 3805 WrapperCssClass = wrapperClass, 3806 AddButton = new AddToCartButton 3807 { 3808 HideTitle = hideButtonText, 3809 ProductId = "{{productId}}", 3810 VariantId = "{{variantid}}", 3811 UnitId = "{{unitId}}", 3812 ProductInfo = "{{productInfo}}", 3813 BuyForPoints = pointShopOnly, 3814 OnClick = "{{facebookPixelAction}}", 3815 ExtraAttributes = new Dictionary<string, string> 3816 { 3817 { "{{disabledBuyButton}}", "" } 3818 } 3819 } 3820 }; 3821 3822 if (!pointShopOnly) 3823 { 3824 addToCartBtn.QuantitySelector = new QuantitySelector 3825 { 3826 Id = "Quantity{{id}}" 3827 }; 3828 } 3829 3830 @Render(addToCartBtn) 3831 } 3832 3833 @helper RenderGridViewItemActions() 3834 { 3835 bool showCartButton = gridViewSettings.GetBoolean("ShowAddToCartButton"); 3836 bool showViewButton = gridViewSettings.GetBoolean("ShowViewButton"); 3837 3838 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 3839 { 3840 if (showCartButton) 3841 { 3842 if (!showViewButton) 3843 { 3844 <text>{{#if hideAddToCartButton}}</text> 3845 <div>@RenderGridViewItemViewButton()</div> 3846 <text>{{else}}</text> 3847 @RenderGridViewItemAddToCart() 3848 <text>{{/if}}</text> 3849 } 3850 else 3851 { 3852 @RenderGridViewItemAddToCart() 3853 } 3854 } 3855 else if (showViewButton) 3856 { 3857 <div>@RenderGridViewItemViewButton()</div> 3858 } 3859 } 3860 else if (showViewButton) 3861 { 3862 <div>@RenderGridViewItemViewButton()</div> 3863 } 3864 } 3865 3866 @helper RenderGridViewItemStockAndDelivery() 3867 { 3868 <text>{{#if stockText}}</text> 3869 <div class="u-margin-top"> 3870 <div><span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> {{stockText}}</div> 3871 <div> 3872 {{#if deliveryText}} 3873 {{deliveryText}} 3874 {{else}} 3875 - 3876 {{/if}} 3877 </div> 3878 </div> 3879 <text>{{/if}}</text> 3880 } 3881 3882 @helper RenderGridViewItemStaticVariants() 3883 { 3884 string variantsSize = gridViewSettings.GetList("StaticVariantsDisplay") != null ? gridViewSettings.GetList("StaticVariantsDisplay").SelectedValue : "sm"; 3885 3886 <text> 3887 {{#Variants}} 3888 @if (variantsSize == "lg") 3889 { 3890 <text> 3891 {{>StaticVariantsLgTemplate}} 3892 </text> 3893 } 3894 else 3895 { 3896 <text> 3897 {{>StaticVariantsTemplate}} 3898 </text> 3899 } 3900 {{/Variants}} 3901 3902 {{#ifCond variantGroupsCount '>' 1}} 3903 <div class="static-variant"> 3904 @Translate("More options available") 3905 </div> 3906 {{/ifCond}} 3907 3908 {{#ifCond variantGroupsCount '==' 0}} 3909 <div class="static-variant"></div> 3910 {{/ifCond}} 3911 </text> 3912 } 3913 3914 @helper RenderGridViewItemDownloadButton() 3915 { 3916 <button type="button" class="btn btn--primary u-no-margin u-margin-top btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 3917 @Render(new Icon { Prefix = "fas", Name = "fa-plus", CssClass = "js-button-icon" }) 3918 <span class="js-button-text">@Translate("Add")</span> 3919 </button> 3920 } 3921 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3922 @using Dynamicweb.Core 3923 @using System 3924 @using System.Web 3925 @using System.Collections.Generic 3926 @using Dynamicweb.Rapido.Blocks 3927 @using Dynamicweb.Rapido.Blocks.Components 3928 @using Dynamicweb.Rapido.Blocks.Components.General 3929 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3930 @using Dynamicweb.Rapido.Services 3931 3932 @functions { 3933 BlocksPage detailsViewPage = BlocksPage.GetBlockPage("ProductList"); 3934 Dynamicweb.Frontend.ItemViewModel detailsViewSettings = null; 3935 3936 /* this function need because in details view we have specipfic situation 3937 * when price need to be placed between unit selector and quantity selector 3938 */ 3939 3940 UnitSelector getUnitsSelector() 3941 { 3942 return new UnitSelector 3943 { 3944 OptionsContent = "{{#unitOptions}}{{>UnitOption}}{{/unitOptions}}", 3945 Id = "UnitOptions_{{id}}", 3946 SelectedOption = "{{unitName}}", 3947 CssClass = "product-list__details-units-selector {{#if hasOnlyOneUnit}}unit-selector--readonly{{/if}} {{hasUnits}}" 3948 }; 3949 } 3950 } 3951 3952 @if (Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableDetailsView")) 3953 { 3954 detailsViewSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("DetailsView"); 3955 3956 detailsViewPage.Add("Views", new Block 3957 { 3958 Id = "ProductDetailsItemContainer", 3959 Name = "list", 3960 SortId = 30 3961 }); 3962 3963 Block detailsViewScripts = new Block 3964 { 3965 Id = "DetailsViewScripts", 3966 SortId = 30, 3967 Template = DetailsView(), 3968 BlocksList = new List<Block> 3969 { 3970 new Block 3971 { 3972 Id = "DetailsViewItem", 3973 SortId = 10, 3974 Template = RenderDetailsViewItem(), 3975 SkipRenderBlocksList = true, 3976 BlocksList = new List<Block> { 3977 new Block 3978 { 3979 Id = "DetailsViewItemHiddenProperties", 3980 SortId = 10, 3981 Template = RenderDetailsViewItemHiddenProperties() 3982 }, 3983 new Block 3984 { 3985 Id = "DetailsViewItemLeft", 3986 SortId = 10, 3987 Design = new Design 3988 { 3989 CssClass = "product-list__details-item__left grid__cell dw-mod" 3990 }, 3991 BlocksList = new List<Block> { 3992 new Block 3993 { 3994 Id = "DetailsViewItemInfoContainer", 3995 SortId = 20, 3996 Design = new Design 3997 { 3998 CssClass = "product-list__details-info dw-mod" 3999 }, 4000 BlocksList = new List<Block> { 4001 new Block 4002 { 4003 Id = "DetailsViewItemTitle", 4004 SortId = 10, 4005 Template = RenderDetailsViewItemTitle() 4006 }, 4007 new Block 4008 { 4009 Id = "DetailsViewItemStickers", 4010 SortId = 50, 4011 Template = RenderDetailsViewItemStickers() 4012 } 4013 } 4014 } 4015 } 4016 }, 4017 new Block 4018 { 4019 Id = "DetailsViewItemRight", 4020 SortId = 20, 4021 Design = new Design 4022 { 4023 CssClass = "product-list__details-item__right grid__cell dw-mod" 4024 }, 4025 BlocksList = new List<Block> { 4026 new Block { 4027 Id = "DetailsViewItemRightBottom", 4028 SortId = 20, 4029 Design = new Design 4030 { 4031 CssClass = "u-flex product-list__details-right-bottom-section dw-mod" 4032 }, 4033 BlocksList = new List<Block> { 4034 new Block 4035 { 4036 Id = "DetailsViewItemActions", 4037 SortId = 30, 4038 Template = RenderDetailsViewItemActions() 4039 } 4040 } 4041 } 4042 } 4043 } 4044 } 4045 } 4046 } 4047 }; 4048 detailsViewPage.Add("BottomSnippets", detailsViewScripts); 4049 4050 //image 4051 bool detailsViewShowImage = detailsViewSettings.GetBoolean("ShowImage"); 4052 4053 if (detailsViewShowImage) 4054 { 4055 detailsViewPage.Add("DetailsViewItemLeft", new Block 4056 { 4057 Id = "DetailsViewItemImage", 4058 SortId = 10, 4059 Template = RenderDetailsViewItemImage() 4060 }); 4061 } 4062 4063 //number 4064 bool detailsViewShowNumber = detailsViewSettings.GetBoolean("ShowProductNumber"); 4065 4066 if (detailsViewShowNumber) 4067 { 4068 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 4069 { 4070 Id = "ProductDetailsItemNumber", 4071 SortId = 30, 4072 Template = RenderDetailsViewItemNumber() 4073 }); 4074 } 4075 4076 //static variants 4077 bool detailsViewShowStaticVariants = detailsViewSettings.GetBoolean("ShowStaticVariants"); 4078 4079 if (detailsViewShowStaticVariants) 4080 { 4081 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 4082 { 4083 Id = "DetailsViewItemStaticVariants", 4084 SortId = 30, 4085 Template = RenderDetailsViewItemStaticVariants() 4086 }); 4087 } 4088 4089 //stock 4090 bool detailsViewShowStock = detailsViewSettings.GetBoolean("ShowStockAndShipping"); 4091 4092 if (User.IsStockInfoAllowed() && detailsViewShowStock) 4093 { 4094 detailsViewPage.Add("DetailsViewItemInfoContainer", new Block 4095 { 4096 Id = "DetailsViewItemStock", 4097 SortId = 40, 4098 Template = RenderDetailsViewItemStock() 4099 }); 4100 } 4101 4102 //price 4103 bool detailsViewShowPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 4104 if (detailsViewShowPrice && Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 4105 { 4106 var separatedUnitSelector = getUnitsSelector(); 4107 separatedUnitSelector.CssClass += " product-list__details-units-selector--separated"; 4108 4109 detailsViewPage.Add("DetailsViewItemRightBottom", new Block { 4110 Id = "DetailsViewUnitSelector", 4111 SortId = 10, 4112 Component = separatedUnitSelector 4113 }); 4114 4115 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 4116 { 4117 Id = "ProductDetailsItemPrice", 4118 SortId = 20, 4119 Template = RenderDetailsViewItemPrice() 4120 }); 4121 } 4122 4123 //favorites 4124 bool detailsViewShowFavoriteButton = !detailsViewSettings.GetBoolean("HideFavoriteButton"); 4125 4126 if (detailsViewShowFavoriteButton && Pageview.User != null) 4127 { 4128 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 4129 { 4130 Id = "DetailsViewItemFavorites", 4131 SortId = 40, 4132 Template = RenderDetailsViewItemFavorites() 4133 }); 4134 } 4135 4136 //download button 4137 bool detailsViewShowAddToDownloadButton = detailsViewSettings.GetBoolean("ShowAddToDownloadButton"); 4138 4139 if (detailsViewShowAddToDownloadButton && Pageview.User != null) 4140 { 4141 detailsViewPage.Add("DetailsViewItemRightBottom", new Block 4142 { 4143 Id = "DetailsViewItemDownloadButton", 4144 SortId = 20, 4145 Template = RenderDetailsViewItemDownloadButton() 4146 }); 4147 } 4148 } 4149 4150 @helper DetailsView() 4151 { 4152 <script id="ProductDetailsItemContainer" type="text/x-template"> 4153 {{#.}} 4154 <div id="Product{{id}}" data-template="DetailsViewItem" data-preloader="overlay" class="grid__col-12 u-no-padding-y js-product dw-mod" style="z-index: {{zIndex}}"> 4155 {{#Product}} 4156 {{>DetailsViewItem}} 4157 {{/Product}} 4158 </div> 4159 {{/.}} 4160 </script> 4161 } 4162 4163 @helper RenderDetailsViewItem() 4164 { 4165 List<Block> subBlocks = detailsViewPage.GetBlockListById("DetailsViewItem"); 4166 4167 <script id="DetailsViewItem" type="text/x-template"> 4168 {{#.}} 4169 <div class="product-list__details-item grid__col-12 dw-mod js-product-scroll-trigger" data-params="{{googleImpression}}"> 4170 @RenderBlockList(subBlocks) 4171 </div> 4172 {{/.}} 4173 </script> 4174 } 4175 4176 @helper RenderDetailsViewItemHiddenProperties() 4177 { 4178 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 4179 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 4180 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 4181 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 4182 <input type="hidden" name="Quantity{{id}}" value="1" id="Quantity_{{id}}" /> 4183 } 4184 4185 @helper RenderDetailsViewItemImage() 4186 { 4187 <div class="lightbox"> 4188 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}"> 4189 <img class="lightbox__image {{noImage}}" src="/Admin/Public/GetImage.ashx?width=220&amp;height=220&amp;crop=5&amp;Compression=75&amp;image={{image}}" alt="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" /> 4190 <div class="u-margin-right {{noImage}}"> 4191 <img class="b-lazy product-list__details-image" src="/Files/Images/placeholder.gif" 4192 data-src="/Admin/Public/GetImage.ashx?width=75&amp;height=55&amp;crop=5&FillCanvas=true&amp;Compression=75&amp;image={{image}}" 4193 alt="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" /> 4194 </div> 4195 </a> 4196 </div> 4197 } 4198 4199 @helper RenderDetailsViewItemTitle() 4200 { 4201 <a href="{{link}}" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" class="product-list__details-title u-color-inherit dw-mod"> 4202 <h6 class="u-no-margin u-bold">{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}</h6> 4203 </a> 4204 } 4205 4206 @helper RenderDetailsViewItemNumber() 4207 { 4208 <div class="item-number item-number--compressed dw-mod"> 4209 <div class="item-number dw-mod">{{number}}</div> 4210 </div> 4211 } 4212 4213 @helper RenderDetailsViewItemStaticVariants() 4214 { 4215 string variantsSize = detailsViewSettings.GetList("StaticVariantsDisplay") != null ? detailsViewSettings.GetList("StaticVariantsDisplay").SelectedValue : "sm"; 4216 4217 <text> 4218 <span> 4219 {{#Variants}} 4220 @if ( variantsSize == "lg" ) { 4221 <text> 4222 {{>StaticVariantsLgTemplate}} 4223 </text> 4224 } else { 4225 <text> 4226 {{>StaticVariantsTemplate}} 4227 </text> 4228 } 4229 {{/Variants}} 4230 </span> 4231 4232 {{#ifCond variantGroupsCount '>' 1}} 4233 <div class="static-variant"> 4234 @Translate("More options available") 4235 </div> 4236 {{/ifCond}} 4237 </text> 4238 } 4239 4240 @helper RenderDetailsViewItemStock() 4241 { 4242 <text>{{#if stockText}}</text> 4243 <div class="item-number item-number--compressed dw-mod"> 4244 <span> 4245 <span class="stock-icon {{stockState}} u-no-margin dw-mod" title="{{stockText}}"></span> 4246 <span class="u-margin-right--lg"> {{stockText}}</span> 4247 {{deliveryText}} 4248 </span> 4249 </div> 4250 <text>{{/if}}</text> 4251 } 4252 4253 @helper RenderDetailsViewItemStickers() 4254 { 4255 <div class="grid__cell-footer stickers-container stickers-container--row u-margin-top dw-mod"> 4256 {{#StickersContainers}} 4257 {{#Stickers}} 4258 {{>MiniSticker}} 4259 {{/Stickers}} 4260 {{/StickersContainers}} 4261 </div> 4262 } 4263 4264 @helper RenderDetailsViewItemPrice() 4265 { 4266 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4267 bool showCartButton = Pageview.AreaSettings.GetItem("ProductList").GetItem("DetailsView").GetBoolean("ShowAddToCartButton"); 4268 bool showVATPrice = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("ShowBothPricesWithWithoutVAT"); 4269 bool isPricesWithVATEnabled = Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat; 4270 4271 <div class="product-list__details-price"> 4272 @if (pointShopOnly) 4273 { 4274 <text> 4275 {{#if havePointPrice}} 4276 <div class="price price--product-list price--micro dw-mod">{{points}} @Translate("points")</div> 4277 @if (showCartButton) 4278 { 4279 <text> 4280 {{#unless canBePurchasedWithPoints}} 4281 <small class="help-text u-no-margin">@Translate("Not enough points to buy this")</small> 4282 {{/unless}} 4283 </text> 4284 } 4285 {{else}} 4286 @Translate("Not available") 4287 {{/if}} 4288 </text> 4289 4290 } 4291 else 4292 { 4293 <div class="price price--product-list price--micro dw-mod">{{price}}</div> 4294 <div class="before-price {{onSale}} before-price--micro dw-mod">{{discount}}</div> 4295 if (showVATPrice) 4296 { 4297 <div class="vat-price vat-price--product-list u-margin-top dw-mod"> 4298 @if (isPricesWithVATEnabled) 4299 { 4300 <span>@Translate("excl. VAT")</span><span> ({{priceWithoutVAT}})</span> 4301 } 4302 else 4303 { 4304 <span>@Translate("incl. VAT")</span><span> ({{priceWithVAT}})</span> 4305 } 4306 </div> 4307 } 4308 <text> 4309 {{#if priceRRP}} 4310 <div><small>@Translate("RRP") {{priceRRP}}</small></div> 4311 {{/if}} 4312 </text> 4313 } 4314 </div> 4315 } 4316 4317 @helper RenderDetailsViewItemFavorites() 4318 { 4319 <div class="favorites product-list__details-favorites {{hasVariants}} dw-mod" {{hasVariants}}> 4320 {{#Favorite}} 4321 {{>FavoriteTemplate}} 4322 {{/Favorite}} 4323 </div> 4324 } 4325 4326 @helper RenderDetailsViewItemViewButton() 4327 { 4328 string viewMoreText = detailsViewSettings.GetString("ViewMoreText"); 4329 viewMoreText = !string.IsNullOrEmpty(viewMoreText) ? viewMoreText : "View"; 4330 4331 <div class="product-list__details-actions"> 4332 @Render(new Link 4333 { 4334 Href = "{{link}}", 4335 Id = "CartButton_{{id}}", 4336 Title = Translate(viewMoreText), 4337 OnClick = "{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}", 4338 ButtonLayout = ButtonLayout.Secondary, 4339 CssClass = "u-no-margin" 4340 }) 4341 </div> 4342 } 4343 4344 @helper RenderDetailsViewItemAddToCart() 4345 { 4346 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4347 bool showPrice = !Pageview.AreaSettings.GetItem("ProductList").GetBoolean("HidePrice"); 4348 4349 var addToCartBtn = new AddToCart 4350 { 4351 AddButton = new AddToCartButton 4352 { 4353 HideTitle = true, 4354 ProductId = "{{productId}}", 4355 VariantId = "{{variantid}}", 4356 UnitId = "{{unitId}}", 4357 ProductInfo = "{{productInfo}}", 4358 BuyForPoints = pointShopOnly, 4359 OnClick = "{{facebookPixelAction}}", 4360 ExtraAttributes = new Dictionary<string, string> 4361 { 4362 { "{{disabledBuyButton}}", "" } 4363 } 4364 } 4365 }; 4366 4367 if (!pointShopOnly) 4368 { 4369 addToCartBtn.QuantitySelector = new QuantitySelector 4370 { 4371 Id = "Quantity{{id}}" 4372 }; 4373 } 4374 4375 if (!showPrice) 4376 { 4377 addToCartBtn.UnitSelector = getUnitsSelector(); 4378 } 4379 4380 <div class="product-list__details-actions"> 4381 @Render(addToCartBtn) 4382 </div> 4383 } 4384 4385 @helper RenderDetailsViewItemActions() 4386 { 4387 bool showCartButton = detailsViewSettings.GetBoolean("ShowAddToCartButton"); 4388 bool showViewButton = detailsViewSettings.GetBoolean("ShowViewButton"); 4389 4390 if (Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 4391 { 4392 if (showCartButton) 4393 { 4394 if (!showViewButton) 4395 { 4396 @RenderDetailsViewItemAddToCart() 4397 } 4398 else 4399 { 4400 <text>{{#if hideAddToCartButton}}</text> 4401 @RenderDetailsViewItemViewButton() 4402 <text>{{else}}</text> 4403 @RenderDetailsViewItemAddToCart() 4404 <text>{{/if}}</text> 4405 } 4406 } 4407 else if (showViewButton) 4408 { 4409 @RenderDetailsViewItemViewButton() 4410 } 4411 } 4412 else if (showViewButton) 4413 { 4414 @RenderDetailsViewItemViewButton() 4415 } 4416 } 4417 4418 @helper RenderDetailsViewItemDownloadButton() 4419 { 4420 <button type="button" class="btn btn--primary u-no-margin u-margin-left btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 4421 @Render(new Icon { Prefix = "fas", Name = "fa-plus", CssClass = "js-button-icon" }) 4422 </button> 4423 } 4424 4425 4426 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4427 @using Dynamicweb.Core 4428 @using System 4429 @using System.Web 4430 @using System.Collections.Generic 4431 @using Dynamicweb.Rapido.Blocks 4432 @using Dynamicweb.Rapido.Blocks.Components 4433 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 4434 @using Dynamicweb.Rapido.Blocks.Components.General 4435 @using Dynamicweb.Rapido.Services 4436 @using System.Web.Helpers 4437 4438 @functions { 4439 BlocksPage tilesView = BlocksPage.GetBlockPage("ProductList"); 4440 Dynamicweb.Frontend.ItemViewModel tilesViewSettings = null; 4441 } 4442 4443 @{ 4444 var settings = Pageview.AreaSettings.GetItem("ProductList"); 4445 var enableTiles = settings.GetBoolean("EnableTilesView"); 4446 4447 if ( enableTiles ) { 4448 tilesViewSettings = settings.GetItem("TilesView"); 4449 BlocksPage tilesView = BlocksPage.GetBlockPage("ProductList"); 4450 4451 Block tiles = new Block { 4452 Id = "ProductTilesViewContainer", 4453 Name ="grip-horizontal", 4454 SortId = 50, 4455 }; 4456 4457 tilesView.Add("Views", tiles); 4458 4459 4460 Block tilesViewScripts = new Block { 4461 Id = "TilesViewScripts", 4462 SortId = 20, 4463 Template = TilesView(), 4464 BlocksList = new List<Block> { 4465 new Block { 4466 Id = "TilesViewItem", 4467 SortId = 10, 4468 Template = RenderTilesViewItem(), 4469 SkipRenderBlocksList = true, 4470 BlocksList = new List<Block> { 4471 new Block { 4472 Id = "TilesViewItemHiddenProperties", 4473 SortId = 10, 4474 Template = RenderTilesViewItemHiddenProperties() 4475 }, 4476 new Block { 4477 Id = "TilesViewItemImageContainer", 4478 SortId = 20, 4479 Template = RenderTilesViewItemImageContainer(), 4480 SkipRenderBlocksList = true, 4481 BlocksList = new List<Block> { 4482 new Block { 4483 Id = "TilesViewItemImage", 4484 SortId = 10, 4485 Template = RenderTilesViewItemImage(), 4486 }, 4487 new Block 4488 { 4489 Id = "TilesViewItemStickers", 4490 SortId = 20, 4491 Template = RenderTilesViewItemStickers() 4492 }, 4493 new Block { 4494 Id = "TilesViewItemFavorites", 4495 SortId = 20, 4496 Template = RenderTilesViewItemFavorites() 4497 }, 4498 }, 4499 }, 4500 new Block { 4501 Id = "TilesViewItemContentContainer", 4502 SortId = 30, 4503 Template = RenderTilesViewItemContentContainer(), 4504 SkipRenderBlocksList = true, 4505 BlocksList = new List<Block> { 4506 new Block { 4507 Id = "TilesViewItemContent", 4508 SortId = 30, 4509 Template = RenderTilesViewItemContent(), 4510 SkipRenderBlocksList = true, 4511 BlocksList = new List<Block> { 4512 new Block { 4513 Id = "TilesViewItemHeader", 4514 SortId = 10, 4515 Template = RenderTilesViewItemHeader(), 4516 SkipRenderBlocksList = true, 4517 BlocksList = new List<Block> { 4518 new Block { 4519 Id = "TilesViewItemTitle", 4520 SortId = 10, 4521 Template = RenderTilesViewItemTitle(), 4522 }, 4523 new Block { 4524 Id = "TilesViewItemNumber", 4525 SortId = 20, 4526 Template = RenderTilesViewItemNumber(), 4527 }, 4528 } 4529 }, 4530 new Block { 4531 Id = "TilesViewItemPrice", 4532 SortId = 30, 4533 Template = RenderTilesViewItemPrice(), 4534 }, 4535 } 4536 }, 4537 new Block { 4538 Id = "TilesViewItemFooter", 4539 SortId = 40, 4540 Template = RenderTilesViewItemFooter(), 4541 SkipRenderBlocksList = true 4542 } 4543 } 4544 } 4545 } 4546 } 4547 } 4548 }; 4549 tilesView.Add("BottomSnippets", tilesViewScripts); 4550 4551 if (tilesViewSettings.GetBoolean("ShowStaticVariants")) { 4552 Block staticVariants = new Block { 4553 Id = "TilesViewItemVariants", 4554 SortId = 10, 4555 Template = RenderTilesViewItemVariants(), 4556 }; 4557 tilesView.Add("TilesViewItemContentContainer", staticVariants); 4558 } 4559 4560 //download button 4561 bool tilesViewShowAddToDownloadButton = tilesViewSettings.GetBoolean("ShowAddToDownloadButton"); 4562 4563 if (tilesViewShowAddToDownloadButton && Pageview.User != null) 4564 { 4565 tilesView.Add("TilesViewItemFooter", new Block 4566 { 4567 Id = "TilesViewItemDownloadButton", 4568 SortId = 20, 4569 Template = RenderTilesViewItemDownloadButton() 4570 }); 4571 } 4572 } 4573 } 4574 4575 @helper TilesView() { 4576 int columnsCount = tilesViewSettings.GetList("Columns") != null ? Converter.ToInt32(tilesViewSettings.GetList("Columns").SelectedValue) : 3; 4577 4578 <script id="ProductTilesViewContainer" type="text/x-template"> 4579 {{#.}} 4580 <div id="Product{{id}}" data-template="TilesViewItem" data-preloader="overlay" class="grid__col-lg-@(12 / columnsCount) grid__col-md-@(12 / columnsCount) grid__col-sm-@(12 / columnsCount) grid__col-xs-6 product-list__tiles-item js-product dw-mod"> 4581 {{#Product}} 4582 {{>TilesViewItem}} 4583 {{/Product}} 4584 </div> 4585 {{/.}} 4586 </script> 4587 } 4588 4589 4590 @helper RenderTilesViewItem() { 4591 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItem"); 4592 bool showShadow = tilesViewSettings.GetBoolean("HoverShowShadow"); 4593 string addShadow = ( showShadow != null && showShadow ) ? "product-list--shadow" : ""; 4594 4595 <script id="TilesViewItem" type="text/x-template"> 4596 {{#.}} 4597 <div class="grid__col--auto js-product-scroll-trigger u-no-padding u-full-height @addShadow" data-params="{{googleImpression}}"> 4598 @RenderBlockList(subBlocks) 4599 </div> 4600 {{/.}} 4601 </script> 4602 } 4603 4604 4605 @helper RenderTilesViewItemContentContainer() { 4606 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItemContentContainer"); 4607 4608 <text> 4609 {{#.}} 4610 <div class="grid__cell product-list__tiles-item__price-info u-padding--lg u-flex u-flex--column dw-mod"> 4611 @RenderBlockList(subBlocks) 4612 </div> 4613 {{/.}} 4614 </text> 4615 } 4616 4617 4618 4619 @helper RenderTilesViewItemVariants() { 4620 string variantsSize = tilesViewSettings.GetList("StaticVariantsDisplay") != null ? tilesViewSettings.GetList("StaticVariantsDisplay").SelectedValue : "sm"; 4621 4622 <text> 4623 {{#Variants}} 4624 @if ( variantsSize == "lg" ) { 4625 <text> 4626 {{>StaticVariantsLgTemplate}} 4627 </text> 4628 } else { 4629 <text> 4630 {{>StaticVariantsTemplate}} 4631 </text> 4632 } 4633 {{/Variants}} 4634 4635 {{#ifCond variantGroupsCount '==' 0}} 4636 <div class="static-variant"></div> 4637 {{/ifCond}} 4638 </text> 4639 } 4640 4641 @helper RenderTilesViewItemFavorites() { 4642 bool showFavoriteButton = !tilesViewSettings.GetBoolean("HideFavoriteButton"); 4643 4644 if ( !showFavoriteButton ) { 4645 return; 4646 } 4647 4648 <div class="favorites favorites--for-tiles-view u-pull--right {{hasVariants}} dw-mod" {{hasVariants}}> 4649 {{#Favorite}} 4650 {{>FavoriteTemplate}} 4651 {{/Favorite}} 4652 </div> 4653 } 4654 4655 @helper RenderTilesViewItemImageContainer() { 4656 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItemImageContainer"); 4657 4658 <div class="grid__cell dw-mod {{noImage}}"> 4659 @RenderBlockList(subBlocks) 4660 </div> 4661 } 4662 4663 @helper RenderTilesViewItemStickers() 4664 { 4665 <text> 4666 {{#StickersContainers}} 4667 {{>StickersContainer}} 4668 {{/StickersContainers}} 4669 </text> 4670 } 4671 4672 @helper RenderTilesViewItemImage() { 4673 string imageZoomOnHover = tilesViewSettings.GetBoolean("HoverImageZoom") ? "image-hover--zoom" : ""; 4674 bool secondaryImage = tilesViewSettings.GetString("HoverAlternativeImage") != null ? tilesViewSettings.GetBoolean("HoverAlternativeImage") : false; 4675 4676 <a href="{{link}}" 4677 onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" 4678 title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" 4679 class="product-list__tiles-item__image u-block u-position-relative image-hover__wrapper @imageZoomOnHover dw-mod"> 4680 <img class="grid__cell-img u-middle-horizontal b-lazy" src="/Files/Images/placeholder.gif" 4681 data-src="/Admin/Public/GetImage.ashx?width=450&amp;height=450&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{image}}" 4682 @if (secondaryImage) { 4683 <text> 4684 {{#if secondaryImage}} 4685 data-secondary-image-src="/Admin/Public/GetImage.ashx?width=450&amp;height=450&amp;crop=5&amp;Compression=75&amp;FillCanvas=true&amp;DoNotUpscale=true&amp;image={{secondaryImage}}" 4686 {{/if}} 4687 </text> 4688 } 4689 alt="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}" /> 4690 </a> 4691 } 4692 4693 4694 @helper RenderTilesViewItemHiddenProperties() { 4695 <input type="hidden" name="ProductLoopCounter{{id}}" value="{{id}}" /> 4696 <input type="hidden" name="ProductID{{id}}" value="{{productId}}" /> 4697 <input type="hidden" name="VariantID{{id}}" value="{{variantid}}" id="Variant_{{id}}" /> 4698 <input type="hidden" name="UnitID{{id}}" value="{{unitId}}" id="Unit_{{id}}" /> 4699 <input type="hidden" name="Quantity{{id}}" value="1" id="Quantity_{{id}}" /> 4700 } 4701 4702 4703 @helper RenderTilesViewItemContent() { 4704 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItemContent"); 4705 4706 <div class="grid__cell dw-mod"> 4707 @RenderBlockList(subBlocks) 4708 </div> 4709 } 4710 4711 4712 @helper RenderTilesViewItemHeader() { 4713 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItemHeader"); 4714 4715 <div class="u-flex u-justify-content--between u-margin-bottom dw-mod"> 4716 @RenderBlockList(subBlocks) 4717 </div> 4718 } 4719 4720 4721 @helper RenderTilesViewItemTitle() { 4722 <a href="{{link}}" class="u-color-inherit u-flex-basis--50 u-flex-grow--1" onclick="{{#if googleImpression}}googleEnchantImpressionClick({{googleImpression}}, event){{/if}}" title="{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}"> 4723 <h6 class="u-bold u-capitalize">{{{name}}}{{#if variantName}}, {{variantName}}{{/if}}</h6> 4724 </a> 4725 } 4726 4727 4728 @helper RenderTilesViewItemNumber() { 4729 bool showNumber = tilesViewSettings.GetBoolean("ShowProductNumber"); 4730 4731 if ( !showNumber ) { 4732 return; 4733 } 4734 4735 <div class="item-number u-margin-left--lg dw-mod">{{number}}</div> 4736 } 4737 4738 4739 @helper RenderTilesViewItemPrice() { 4740 <div class="price__wrapper u-flex u-flex--wrap u-justify-content--between"> 4741 <div class="price__inner u-margin-right"> 4742 <div class="price price--product-list u-bold dw-mod">{{price}}</div> 4743 <div class="before-price {{onSale}} dw-mod">{{discount}}</div> 4744 </div> 4745 4746 {{#if priceRRP}} 4747 <div class="price--rrp dw-mod">{{priceRRP}}</div> 4748 {{/if}} 4749 </div> 4750 } 4751 4752 4753 @helper RenderTilesViewItemFooter() { 4754 List<Block> subBlocks = tilesView.GetBlockListById("TilesViewItemFooter"); 4755 4756 <div class="product-list__tiles-item__footer u-margin-top--auto dw-mod"> 4757 @RenderBlockList(subBlocks) 4758 </div> 4759 } 4760 4761 @helper RenderTilesViewItemDownloadButton() { 4762 <button type="button" class="btn btn--primary u-no-margin u-margin-top btn--condensed dw-mod js-add-to-downloads" title="@Translate("Add")" data-product-id="{{productId}}"> 4763 @Render(new Icon { Prefix = "fas", Name = "fa-plus", CssClass = "js-button-icon" }) 4764 <span class="js-button-text">@Translate("Add")</span> 4765 </button> 4766 } 4767 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4768 @using Dynamicweb.Core 4769 @using System 4770 @using System.Web 4771 @using System.Collections.Generic 4772 @using Dynamicweb.Rapido.Blocks 4773 4774 @{ 4775 BlocksPage productListPromotionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4776 4777 Block productListPromotions = new Block 4778 { 4779 Id = "Promotions", 4780 SortId = 10, 4781 Template = RenderProductListPromotions() 4782 }; 4783 productListPromotionsBlocksPage.Add("PageContainer", productListPromotions); 4784 } 4785 4786 @helper RenderProductListPromotions() 4787 { 4788 @*This is part of a script template *@ 4789 4790 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 4791 bool isFavoriteList = !string.IsNullOrEmpty(listId); 4792 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 4793 4794 if (!isFavoriteList) 4795 { 4796 switch (Pageview.AreaSettings.GetItem("ProductList").GetList("PromotionBlockDesign").SelectedValue) 4797 { 4798 case "OnlyText": 4799 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4800 <h1>{{groupName}}</h1> 4801 {{{groupDescription}}} 4802 {{#ifCond groupPromotionLink "!==" ""}} 4803 <div> 4804 <a href="{{groupPromotionLink}}" class="btn btn--primary">{{groupPromotionLinkText}}</a> 4805 </div> 4806 {{/ifCond}} 4807 </article> 4808 break; 4809 case "TextAndImage": 4810 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4811 <div class="grid grid--bleed"> 4812 <div class="grid__col-md-6"> 4813 <h1>{{groupName}}</h1> 4814 {{{groupDescription}}} 4815 {{#ifCond groupPromotionLink "!==" ""}} 4816 <div> 4817 <a href="{{groupPromotionLink}}" class="btn btn--primary">{{groupPromotionLinkText}}</a> 4818 </div> 4819 {{/ifCond}} 4820 </div> 4821 {{#ifCond groupPromotionImage "!==" ""}} 4822 <div class="grid__col-md-6"> 4823 <img src="/Admin/Public/GetImage.ashx?width=600&crop=5&Compression=75&DoNotUpscale=true&image={{groupPromotionImage}}" alt="{{groupName}}" class="background-image__cover" /> 4824 </div> 4825 {{/ifCond}} 4826 </div> 4827 </article> 4828 break; 4829 case "Banner": 4830 <text> 4831 {{#ifCond groupPromotionImage "!==" ""}} 4832 <article class="grid__col-12 u-margin-bottom @smallDeviceCss"> 4833 <div class="u-color-light grid center-container center-container--with-background-image grid__col--bg" style="background-image:url('{{groupPromotionImage}}');"> 4834 <div class="grid__col-12 u-middle"> 4835 <div class="grid__cell"> 4836 {{{groupDescription}}} 4837 {{#ifCond groupPromotionLink "!==" ""}} 4838 <div> 4839 <a href="{{groupPromotionLink}}" class="btn btn--primary">{{groupPromotionLinkText}}</a> 4840 </div> 4841 {{/ifCond}} 4842 </div> 4843 </div> 4844 </div> 4845 </article> 4846 {{/ifCond}} 4847 </text> 4848 break; 4849 } 4850 } 4851 } 4852 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4853 @using Dynamicweb.Core 4854 @using System 4855 @using System.Web 4856 @using System.Collections.Generic 4857 @using Dynamicweb.Rapido.Blocks 4858 4859 @{ 4860 BlocksPage productListMenuBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4861 4862 if (Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet" && 4863 Converter.ToString(Pageview.Page.PropertyItem["LeftMenu"]) == "True" && 4864 Pageview.Page.NavigationSettings != null && 4865 Pageview.Page.NavigationSettings.UseEcomGroups) { 4866 4867 Block productListMenuBlock = new Block 4868 { 4869 Id = "Menu", 4870 SortId = 20, 4871 Template = RenderProductListMenu() 4872 }; 4873 4874 productListMenuBlocksPage.Add("Navigation", productListMenuBlock); 4875 } 4876 } 4877 4878 @helper RenderProductListMenu() 4879 { 4880 var navigationMarkup = RenderNavigation(new 4881 { 4882 id = "leftnav", 4883 cssclass = "dwnavigation", 4884 startLevel = 1, 4885 endlevel = 5, 4886 template = "LeftNavigation.xslt", 4887 mode = "ecom" 4888 }); 4889 4890 <h2 class="u-margin-bottom">@Translate("Product categories")</h2> 4891 4892 <div class="u-padding-bottom--lg"> 4893 @navigationMarkup 4894 </div> 4895 } 4896 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4897 @using Dynamicweb.Core 4898 @using System 4899 @using System.Web 4900 @using System.Collections.Generic 4901 @using Dynamicweb.Rapido.Blocks 4902 @using Dynamicweb.Rapido.Blocks.Components.General 4903 4904 @{ 4905 BlocksPage productListFacetsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 4906 string facetsBlockViewMode = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 4907 4908 if (facetsBlockViewMode == "left" && Pageview.Device.ToString() != "Mobile" && Pageview.Device.ToString() != "Tablet") 4909 { 4910 Block facetsBlock = new Block 4911 { 4912 Id = "Facets", 4913 SortId = 30, 4914 Template = RenderProductListFacets() 4915 }; 4916 productListFacetsBlocksPage.Add("Navigation", facetsBlock); 4917 } 4918 4919 if (facetsBlockViewMode == "top" || Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet") 4920 { 4921 Block facetsBlock = new Block 4922 { 4923 Id = "Facets", 4924 SortId = 10, 4925 Template = RenderProductListTopFacets() 4926 }; 4927 productListFacetsBlocksPage.Add("ProductList", facetsBlock); 4928 } 4929 4930 Block facetSelections = new Block 4931 { 4932 Id = "FacetSelections", 4933 SortId = 20, 4934 Template = RenderFacetSelections() 4935 }; 4936 productListFacetsBlocksPage.Add("ProductList", facetSelections); 4937 4938 Block checkboxFacetTemplate = new Block 4939 { 4940 Id = "CheckboxFacet", 4941 SortId = 30, 4942 Template = RenderCheckboxFacets() 4943 }; 4944 productListFacetsBlocksPage.Add("BottomSnippets", checkboxFacetTemplate); 4945 4946 Block tagsFacetTemplate = new Block 4947 { 4948 Id = "TagsFacet", 4949 SortId = 40, 4950 Template = RenderTagsFacets() 4951 }; 4952 productListFacetsBlocksPage.Add("BottomSnippets", tagsFacetTemplate); 4953 4954 Block colorsFacetTemplate = new Block 4955 { 4956 Id = "ColorFacet", 4957 SortId = 50, 4958 Template = RenderColorFacets() 4959 }; 4960 productListFacetsBlocksPage.Add("BottomSnippets", colorsFacetTemplate); 4961 4962 Block selectedFilter = new Block 4963 { 4964 Id = "SelectedFilter", 4965 SortId = 60, 4966 Template = RenderSelectedFilter() 4967 }; 4968 productListFacetsBlocksPage.Add("BottomSnippets", selectedFilter); 4969 4970 Block selectedColorFilter = new Block 4971 { 4972 Id = "SelectedColorFilter", 4973 SortId = 70, 4974 Template = RenderSelectedColorFilter() 4975 }; 4976 productListFacetsBlocksPage.Add("BottomSnippets", selectedColorFilter); 4977 4978 Block resetFilters = new Block 4979 { 4980 Id = "ResetFilters", 4981 SortId = 80, 4982 Template = RenderResetFilters() 4983 }; 4984 productListFacetsBlocksPage.Add("BottomSnippets", resetFilters); 4985 } 4986 4987 @helper RenderFacetSelections() 4988 { 4989 @*This is part of a script template *@ 4990 <text> 4991 {{#if FacetSelections}} 4992 <div class="buttons-collection u-margin-bottom" id="selectedFacets"> 4993 {{#FacetSelections}} 4994 {{>(lookup . 'template')}} 4995 {{/FacetSelections}} 4996 </div> 4997 {{/if}} 4998 </text> 4999 } 5000 5001 @helper RenderProductListFacets() { 5002 var facetSettings = Pageview.AreaSettings.GetItem("ProductList").GetItem("Facets"); 5003 string boxDisplay = facetSettings.GetList("BoxDisplay") != null ? facetSettings.GetList("BoxDisplay").SelectedValue : "scroll"; 5004 5005 string facetMoreClass = ( boxDisplay == "view-more" ? "facets-container__list--more" : ""); 5006 5007 @*This is part of a script template *@ 5008 5009 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 5010 <div class="facets-container facets-container--left expandable--collapsed dw-mod" data-trigger="CheckFacetGroups"> 5011 {{#FacetGroups}} 5012 <input type="checkbox" id="OptionsGroup_{{name}}" class="expand-trigger js-remember-state" {{defaultState}} /> 5013 5014 <div class="expand-container facets-container__box dw-mod js-filter"> 5015 <label class="expand-container__btn facets-container__header dw-mod" for="OptionsGroup_{{name}}">{{name}}</label> 5016 <div class="expand-container__content js-facet-container dw-mod" data-input="OptionsGroup_{{name}}"> 5017 <div class="facets-container__search {{showFilter}} dw-mod"> 5018 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 5019 </div> 5020 <div id="facetList{{name}}" class="facets-container__list @facetMoreClass dw-mod"> 5021 {{#FacetOptions}} 5022 {{#ifCond template "===" "Checkboxes"}} 5023 {{>Checkboxes}} 5024 {{/ifCond}} 5025 {{#ifCond template "===" "Range"}} 5026 {{>Checkboxes}} 5027 {{/ifCond}} 5028 {{#ifCond template "===" "Weight"}} 5029 {{>Checkboxes}} 5030 {{/ifCond}} 5031 {{#ifCond template "===" "Tags"}} 5032 {{>Tags}} 5033 {{/ifCond}} 5034 {{#ifCond template "===" "Colors"}} 5035 {{>Colors}} 5036 {{/ifCond}} 5037 {{/FacetOptions}} 5038 <div class="u-hidden js-filter-not-found"> 5039 @Translate("Your search gave 0 results") 5040 </div> 5041 </div> 5042 5043 @if ( boxDisplay == "view-more" ) { 5044 <div class="facets-container__more js-facet-expand"> 5045 @Render(new Button { 5046 Title = "<span class=js-facet-trigger-text>" + Translate("View more") + "</span>", 5047 ButtonType = ButtonType.Button, 5048 ButtonLayout = ButtonLayout.Clean, 5049 CssClass = "facets-container__more-button js-facet-trigger u-flex u-no-margin u-full-width", 5050 OnClick = "Facets.ExpandToggle(this)", 5051 ExtraAttributes = new Dictionary<string, string>{ 5052 {"data-target", "facetList{{name}}"}, 5053 {"data-toggle-text", Translate("Show less")}, 5054 }, 5055 Icon = new Icon { 5056 Prefix = "fal", 5057 Name = "fa-angle-down", 5058 } 5059 }) 5060 </div> 5061 } 5062 </div> 5063 </div> 5064 {{/FacetGroups}} 5065 </div> 5066 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-no-margin dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 5067 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-no-margin dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 5068 } 5069 5070 @helper RenderProductListTopFacets() 5071 { 5072 @*This is part of a script template *@ 5073 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 5074 <div class="grid grid--external-bleed dw-mod expandable--collapsed facets-container facets-container--top u-margin-bottom" data-trigger="CheckFacetGroups"> 5075 @if (Pageview.Device.ToString() == "Mobile"){ 5076 string dropdownCssClass = Pageview.Device.ToString() == "Mobile" ? "u-flex-grow--1" : ""; 5077 5078 <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-4 grid__col-xs-12"> 5079 <input type="checkbox" id="ProductSort" class="dropdown-trigger" /> 5080 <div class="dropdown u-inline-block @dropdownCssClass dw-mod"> 5081 <label class="dropdown__header dropdown__btn dropdown__btn--small dw-mod" for="ProductSort">{{selectedSort}}</label> 5082 <div class="dropdown__content dw-mod"> 5083 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: '', SortOrder: '' }, true);">@Translate("Default")</div> 5084 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Created', SortOrder: 'DESC'}, true);">@Translate("Newest")</div> 5085 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'NameForSort', SortOrder: 'ASC'}, true);">@Translate("Name A - Z")</div> 5086 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'NameForSort', SortOrder: 'DESC'}, true);">@Translate("Name Z - A")</div> 5087 @if (Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 5088 { 5089 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'ASC' }, true);">@Translate("Price low - high")</div> 5090 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'DESC' }, true);">@Translate("Price high - low")</div> 5091 } 5092 </div> 5093 <label class="dropdown-trigger-off" for="ProductSort"></label> 5094 </div> 5095 </div> 5096 } 5097 5098 {{#FacetGroups}} 5099 <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-4 grid__col-xs-12"> 5100 <input type="checkbox" id="OptionsGroup_{{counter}}" class="dropdown-trigger" /> 5101 <div class="dropdown dw-mod js-filter"> 5102 <label class="dropdown__header dropdown__btn dw-mod" for="OptionsGroup_{{counter}}">{{name}}</label> 5103 <div class="dropdown__content dropdown__content--padding dw-mod"> 5104 <div class="u-margin-bottom {{showFilter}}"> 5105 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 5106 </div> 5107 {{#FacetOptions}} 5108 {{#ifCond template "===" "Checkboxes"}} 5109 {{>Checkboxes}} 5110 {{/ifCond}} 5111 {{#ifCond template "===" "Range"}} 5112 {{>Checkboxes}} 5113 {{/ifCond}} 5114 {{#ifCond template "===" "Weight"}} 5115 {{>Checkboxes}} 5116 {{/ifCond}} 5117 {{#ifCond template "===" "Tags"}} 5118 {{>Tags}} 5119 {{/ifCond}} 5120 {{#ifCond template "===" "Colors"}} 5121 {{>Colors}} 5122 {{/ifCond}} 5123 {{/FacetOptions}} 5124 <div class="u-hidden js-filter-not-found"> 5125 @Translate("Your search gave 0 results") 5126 </div> 5127 </div> 5128 <label class="dropdown-trigger-off" for="OptionsGroup_{{counter}}"></label> 5129 </div> 5130 </div> 5131 {{/FacetGroups}} 5132 </div> 5133 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-margin-bottom--lg dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 5134 <label for="CheckFacetGroups" class="btn btn--primary btn--full u-margin-bottom--lg dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 5135 } 5136 5137 @helper RenderCheckboxFacets() 5138 { 5139 <script id="Checkboxes" type="text/x-template"> 5140 <div class="form__field-group u-no-margin dw-mod"> 5141 <input type="checkbox" class="{{selected}} checkbox-facet__checkbox form__control dw-mod" onclick="Facets.UpdateFacets(this);" id="{{queryParameter}}{{value}}" name="{{queryParameter}}" value="[{{value}}]" {{selected}} {{disabled}}> 5142 <label class="{{disabled}} checkbox-facet dw-mod" data-filter-value="{{label}}" for="{{queryParameter}}{{value}}"> 5143 <span class="checkbox-facet__label dw-mod">{{label}}</span> 5144 <span class="checkbox-facet__count dw-mod">({{count}})</span> 5145 </label> 5146 </div> 5147 </script> 5148 } 5149 5150 @helper RenderTagsFacets() 5151 { 5152 <script id="Tags" type="text/x-template"> 5153 <button type="button" class="btn btn--tag {{selected}} {{disabled}} dw-mod" data-filter-value="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}> 5154 {{label}} <span class="facets-group__counter dw-mod">({{count}})</span> 5155 </button> 5156 </script> 5157 } 5158 5159 @helper RenderColorFacets() 5160 { 5161 <script id="Colors" type="text/x-template"> 5162 <button type="button" class="btn btn--colorbox u-margin-right {{selected}} {{disabled}} dw-mod" data-filter-value="{{label}}" style="background-color: {{value}}" title="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}></button> 5163 </script> 5164 } 5165 5166 @helper RenderSelectedFilter() 5167 { 5168 <script id="SelectedFilter" type="text/x-template"> 5169 <button type="button" class="btn btn--tag dw-mod" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 5170 {{group}}: {{label}} &nbsp;<i class="fal fa-times"></i> 5171 </button> 5172 </script> 5173 } 5174 5175 @helper RenderSelectedColorFilter() 5176 { 5177 <script id="SelectedColorFilter" type="text/x-template"> 5178 <button type="button" class="btn btn--tag dw-mod" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 5179 {{group}}: <div class="btn__colorbox dw-mod" style="background-color: {{value}}"></div> <i class="fas fa-times"></i> 5180 </button> 5181 </script> 5182 } 5183 5184 @helper RenderResetFilters() 5185 { 5186 <script id="ResetFilters" type="text/x-template"> 5187 <button type="button" class="btn btn--tag" onclick="Facets.ResetFacets();"> 5188 @Translate("Reset all filters") &nbsp;<i class="fal fa-redo"></i> 5189 </button> 5190 </script> 5191 } 5192 5193 5194 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5195 @using Dynamicweb.Core 5196 @using System 5197 @using System.Web 5198 @using System.Collections.Generic 5199 @using Dynamicweb.Rapido.Blocks 5200 5201 @{ 5202 BlocksPage productListMoreBlocksPage = BlocksPage.GetBlockPage("ProductList"); 5203 5204 Block moreBlock = new Block 5205 { 5206 Id = "More", 5207 SortId = 40, 5208 Template = RenderListMore() 5209 }; 5210 5211 productListMoreBlocksPage.Add("ProductList", moreBlock); 5212 } 5213 5214 @helper RenderListMore() 5215 { 5216 @*This is part of a script template *@ 5217 string groupID = HttpContext.Current.Request.QueryString.Get("groupid"); 5218 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 5219 bool isFavoriteList = !string.IsNullOrEmpty(listId); 5220 string moreFeedFullUrl = GetGlobalValue("Global:Pageview.Url.Raw") + "&feed=true"; 5221 moreFeedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 5222 string columnCss = Pageview.Device.ToString() == "Mobile" ? "grid__col--bleed" : "u-no-padding"; 5223 <text> 5224 {{#if ProductsContainer}} 5225 <div class="grid"> 5226 <div class="grid__col-12 @columnCss"> 5227 <button type="button" id="LoadMoreButton" class="btn btn--primary btn--full {{nextdisabled}} dw-mod" data-current="{{currentPage}}" data-page-size="{{pageSize}}" data-total="{{totalPages}}" data-container="ProductsContainer" data-feed-url="@moreFeedFullUrl&groupid=@groupID{{loadMoreFeedParams}}" onclick="LoadMore.Next(this)" {{nextdisabled}}>@Translate("Load") {{pageSizeText}} @Translate("more")</button> 5228 <button type="button" class="btn btn--clean" onclick="window.scroll(0, 0)">@Translate("Return to top")</button> 5229 </div> 5230 </div> 5231 {{/if}} 5232 </text> 5233 } 5234 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5235 @using Dynamicweb.Core 5236 @using System 5237 @using System.Web 5238 @using System.Collections.Generic 5239 @using Dynamicweb.Rapido.Blocks 5240 @using Dynamicweb.Rapido.Blocks.Components 5241 @using Dynamicweb.Rapido.Blocks.Components.General 5242 5243 @{ 5244 BlocksPage productListBottomSnippetsPage = BlocksPage.GetBlockPage("ProductList"); 5245 5246 Block productListStickers = new Block 5247 { 5248 Id = "Stickers", 5249 SortId = 10, 5250 Template = RenderStickersTemplates() 5251 }; 5252 productListBottomSnippetsPage.Add("BottomSnippets", productListStickers); 5253 5254 Block productListUnits = new Block 5255 { 5256 Id = "Units", 5257 SortId = 20, 5258 Template = RenderUnitTemplates() 5259 }; 5260 productListBottomSnippetsPage.Add("BottomSnippets", productListUnits); 5261 5262 Block productListVariants = new Block 5263 { 5264 Id = "Variants", 5265 SortId = 30, 5266 Template = RenderVariantTemplates() 5267 }; 5268 productListBottomSnippetsPage.Add("BottomSnippets", productListVariants); 5269 5270 Block productListFavorites = new Block 5271 { 5272 Id = "Favorites", 5273 SortId = 40, 5274 Template = RenderFavoritesTemplates() 5275 }; 5276 productListBottomSnippetsPage.Add("BottomSnippets", productListFavorites); 5277 5278 Block productListPreRender = new Block 5279 { 5280 Id = "PreRenders", 5281 SortId = 50, 5282 Template = RenderPreRenderTemplates() 5283 }; 5284 productListBottomSnippetsPage.Add("BottomSnippets", productListPreRender); 5285 5286 Block productListInitializers = new Block 5287 { 5288 Id = "Initializers", 5289 SortId = 60, 5290 Template = RenderInitializers() 5291 }; 5292 productListBottomSnippetsPage.Add("BottomSnippets", productListInitializers); 5293 } 5294 5295 5296 @helper RenderFavoritesTemplates() 5297 { 5298 var selectedFavoriteIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "star"; 5299 string favoriteIcon = "fas fa-" + selectedFavoriteIcon; 5300 string favoriteOutlineIcon = "fal fa-" + selectedFavoriteIcon; 5301 bool useFacebookPixel = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID")); 5302 string currentFavoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 5303 5304 <script id="FavoriteTemplate" type="text/x-template"> 5305 <div class="favorites-list u-ta-left js-favorites-list"> 5306 @Render(new Button { 5307 CssClass = "u-no-margin js-favorite-btn", 5308 Icon = new Icon 5309 { 5310 Name = "{{#if isInAnyFavoriteList}}" + favoriteIcon + "{{else}}" + favoriteOutlineIcon + "{{/if}}", 5311 CssClass = "fa-1_5x", 5312 LabelPosition = IconLabelPosition.After 5313 }, 5314 ButtonLayout = ButtonLayout.LinkClean, 5315 ButtonType = ButtonType.Button, 5316 OnClick = "document.getElementById('FavoriteTrigger_{{id}}').checked = true" 5317 }) 5318 <input type="checkbox" id="FavoriteTrigger_{{id}}" class="dropdown-trigger" /> 5319 <div class="dropdown dropdown--position-32px"> 5320 <div class="dropdown__content dropdown__content--show-left dropdown__content--padding u-w220px dw-mod"> 5321 <ul class="list list--clean dw-mod"> 5322 {{#FavoriteLists}} 5323 {{>FavoriteListItem}} 5324 {{/FavoriteLists}} 5325 </ul> 5326 </div> 5327 <label class="dropdown-trigger-off" for="FavoriteTrigger_{{id}}"></label> 5328 </div> 5329 </div> 5330 </script> 5331 5332 <script id="FavoriteListItem" type="text/x-template"> 5333 <li> 5334 @{ 5335 var button = new Button { 5336 CssClass = "list__link u-no-underline", 5337 OnClick = "toggleFavAction(this, event)", 5338 Icon = new Icon { Name = "{{#if isInFavoriteList}}" + favoriteIcon + "{{else}}" + favoriteOutlineIcon + "{{/if}}", LabelPosition = IconLabelPosition.After }, 5339 AltText = "{{#if isInFavoriteList}}" + Translate("Remove from") + " {{name}}{{else}}" + Translate("Add to") + " {{name}}{{/if}}", 5340 Title = "{{name}}", 5341 ButtonType = ButtonType.Button, 5342 ButtonLayout = ButtonLayout.LinkClean, 5343 ExtraAttributes = new Dictionary<string, string> 5344 { 5345 { "data-list-id", "{{listId}}" }, 5346 { "data-list-name", "{{name}}" }, 5347 { "data-remove-link", "{{removeLink}}" }, 5348 { "data-add-link", "{{addLink}}" }, 5349 { "data-is-in-list", "{{isInFavoriteList}}" }, 5350 5351 } 5352 }; 5353 if (useFacebookPixel) 5354 { 5355 button.ExtraAttributes.Add("data-facebook-object", "{{facebookPixelAddAction}}"); 5356 } 5357 } 5358 @Render(button) 5359 </li> 5360 </script> 5361 5362 <script> 5363 @if (!string.IsNullOrEmpty(currentFavoriteListId)) 5364 { 5365 <text> 5366 window.currentFavoriteListId = "@currentFavoriteListId"; 5367 </text> 5368 } 5369 function toggleFavAction(button, event) { 5370 if (button.getAttribute('data-add-link').indexOf('CCCreateNewList') > -1) { 5371 Scroll.SavePosition(event); 5372 @if (useFacebookPixel) 5373 { 5374 <text> 5375 fbq('track', 'AddToWishlist', JSON.parse(button.getAttribute('data-facebook-object'))); 5376 </text> 5377 } 5378 location.href = button.getAttribute('data-add-link'); 5379 return; 5380 } 5381 let isAdd = button.getAttribute('data-is-in-list') == "false"; 5382 Request.Fetch().get( 5383 isAdd ? button.getAttribute('data-add-link') : button.getAttribute('data-remove-link'), 5384 function (result) { 5385 button.querySelector('i').className = isAdd ? '@favoriteIcon u-margin-right--lg' : '@favoriteOutlineIcon u-margin-right--lg'; 5386 button.setAttribute('data-is-in-list', isAdd); 5387 button.setAttribute('title', (!isAdd ? '@Translate("Add to") ' : '@Translate("Remove from") ') + button.getAttribute('data-list-name')) 5388 let favList = button.closest('.js-favorites-list'); 5389 let favBtn = favList.querySelector('.js-favorite-btn i'); 5390 let isInAnyFavoriteList = favList.querySelector('[data-is-in-list=true]') != null; 5391 if (isInAnyFavoriteList) { 5392 favBtn.className = '@favoriteIcon' + ' fa-1_5x'; 5393 } else { 5394 favBtn.className = '@favoriteOutlineIcon' + ' fa-1_5x'; 5395 } 5396 @if (useFacebookPixel) 5397 { 5398 <text> 5399 if (isAdd) { 5400 fbq('track', 'AddToWishlist', JSON.parse(button.getAttribute('data-facebook-object'))); 5401 } 5402 </text> 5403 } 5404 if (window.currentFavoriteListId != null) { //if this page is favorite list 5405 let listId = button.getAttribute("data-list-id"); 5406 if (listId == window.currentFavoriteListId && !isAdd) { 5407 location.reload(); 5408 } 5409 } 5410 }, 5411 function () { 5412 console.error("FavoriteLists: Error in ToggleFavAction request"); 5413 }, 5414 false 5415 ); 5416 } 5417 </script> 5418 } 5419 5420 @helper RenderStickersTemplates() 5421 { 5422 <script id="StickersContainer" type="text/x-template"> 5423 <div class="stickers-container stickers-container--{{{convertStickerPositionToClassName Position}}} dw-mod"> 5424 {{#Stickers}} 5425 {{>Sticker}} 5426 {{/Stickers}} 5427 </div> 5428 </script> 5429 5430 <script id="Sticker" type="text/x-template"> 5431 <div class="stickers-container__tag {{CssClass}} dw-mod">{{Title}}</div> 5432 </script> 5433 5434 <script id="MiniSticker" type="text/x-template"> 5435 <div class="stickers-container__tag stickers-container__tag--micro {{CssClass}} dw-mod">{{Title}}</div> 5436 </script> 5437 } 5438 5439 @helper RenderUnitTemplates() 5440 { 5441 <script id="UnitOption" type="text/x-template"> 5442 <div class="dropdown__item dw-mod" onclick="HandlebarsBolt.UpdateContent(this.closest('.js-product').id, '{{link}}&feed=true&UnitID={{value}}')">{{name}}</div> 5443 </script> 5444 } 5445 5446 @helper RenderVariantTemplates() { 5447 <script id="VariantsTemplate" type="text/x-template"> 5448 {{#.}} 5449 <div> 5450 <div> 5451 {{#VariantOptions}} 5452 {{>VariantOption}} 5453 {{/VariantOptions}} 5454 </div> 5455 </div> 5456 {{/.}} 5457 </script> 5458 5459 <script id="VariantOption" type="text/x-template"> 5460 {{#if color}} 5461 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--colorbox u-margin-right {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} style="background-color: {{color}}"></button> 5462 {{else}} 5463 {{#if image}} 5464 <img data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" src="{{image}}" onclick="MatchVariants.SelectThis(event)" alt="{{name}}" title="{{name}}" class="btn btn--tag {{selected}} js-variant-option" data-check="{{selected}}" /> 5465 {{else}} 5466 <button type="button" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}}>{{name}}</button> 5467 {{/if}} 5468 {{/if}} 5469 </script> 5470 5471 <script id="DropdownVariantsTemplate" type="text/x-template"> 5472 {{#.}} 5473 <div> 5474 <div class="u-bold">{{name}}</div> 5475 <select id="VariantSelector_{{id}}" class="u-full-width dw-mod" name="VariantSelector_{{id}}" onchange="MatchVariants.SelectOnChange(event)" > 5476 <option>@Translate("Choose")</option> 5477 {{#VariantOptions}} 5478 {{>DropdownVariantOption}} 5479 {{/VariantOptions}} 5480 </select> 5481 </div> 5482 {{/.}} 5483 </script> 5484 5485 <script id="DropdownVariantOption" type="text/x-template"> 5486 <option class="js-variant-option {{selected}}" id="{{groupId}}_{{variantId}}" value="{{groupId}}_{{variantId}}" data-variant-id="{{variantId}}" data-variant-group="{{groupId}}" {{#if selected}}selected{{/if}} data-check="{{selected}}">{{name}}</option> 5487 </script> 5488 5489 <script id="StaticVariantsTemplate" type="text/x-template"> 5490 {{#.}} 5491 {{#if isFirstGroup}} 5492 <div> 5493 {{#VariantOptions}} 5494 {{>StaticVariantOption}} 5495 {{/VariantOptions}} 5496 </div> 5497 {{/if}} 5498 {{/.}} 5499 </script> 5500 5501 <script id="StaticVariantOption" type="text/x-template"> 5502 {{#if color}} 5503 <div class="static-variant static-variant--color dw-mod" style="background-color: {{color}}" title="{{name}}"></div> 5504 {{else}} 5505 <div class="static-variant dw-mod">{{name}} </div> 5506 {{/if}} 5507 </script> 5508 5509 5510 <script id="StaticVariantsLgTemplate" type="text/x-template"> 5511 {{#.}} 5512 {{#if isFirstGroup}} 5513 <div class="padding-size-xs"> 5514 {{#VariantOptions}} 5515 {{>StaticVariantLgOption}} 5516 {{/VariantOptions}} 5517 </div> 5518 {{/if}} 5519 {{/.}} 5520 </script> 5521 5522 <script id="StaticVariantLgOption" type="text/x-template"> 5523 {{#if color}} 5524 <div class="static-variant static-variant--color static-variant--color--lg dw-mod" style="background-color: {{color}}" title="{{name}}"></div> 5525 {{else}} 5526 <div class="static-variant dw-mod">{{name}} </div> 5527 {{/if}} 5528 </script> 5529 5530 <script id="VariantOptionImage" type="text/x-template"> 5531 <img data-variant-id="{{variantId}}" data-friends="{{friendsList}}" data-variant-group="{{groupId}}" onclick="MatchVariants.SelectThis(event)" src="/Admin/Public/GetImage.ashx?width=100&amp;height=50&amp;crop=5&amp;Compression=75&amp;image=/Images/{{image}}" alt="{{name}}" title="{{name}}" class="btn btn--tag {{disabled}} {{selected}} js-variant-option" data-check="{{selected}}" {{disabled}} /> 5532 </script> 5533 } 5534 5535 @helper RenderPreRenderTemplates() { 5536 string facetsViewMode = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 5537 5538 <script id="ProductPreRenderContainer" type="text/x-template"> 5539 @if (facetsViewMode == "left" && Pageview.Device.ToString() != "Mobile") 5540 { 5541 <div class="grid__col-3"> 5542 <div class="pre-render-element pre-render-element--xs"></div> 5543 <div class="pre-render-element pre-render-element--md"></div> 5544 <div class="pre-render-element pre-render-element--md"></div> 5545 <div class="pre-render-element pre-render-element--md"></div> 5546 </div> 5547 } 5548 <div class="grid__col-auto"> 5549 <div class="pre-render-element pre-render-element--xs"></div> 5550 <div class="pre-render-element pre-render-element--lg"></div> 5551 <div class="pre-render-element pre-render-element--lg"></div> 5552 <div class="pre-render-element pre-render-element--lg"></div> 5553 <div class="pre-render-element pre-render-element--lg"></div> 5554 </div> 5555 </script> 5556 } 5557 5558 @helper RenderInitializers() { 5559 <script> 5560 document.addEventListener("DOMContentLoaded", function (event) { 5561 document.getElementById("productList").addEventListener('contentLoaded', function (e) { 5562 if (getTarget(e).id === "productList") { 5563 Search.Init(); 5564 Facets.Init("selectedFacets", "productList"); 5565 } 5566 }, false); 5567 5568 @{ 5569 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 5570 5571 if (useGoogleTagManager) 5572 { 5573 <text> 5574 Scroll.AddIsInViewportListener(".js-product-scroll-trigger", function (elem) { 5575 let googleImpression = JSON.parse(elem.getAttribute("data-params")); 5576 googleEnchantImpression(googleImpression); 5577 elem.classList.remove("js-product-scroll-trigger"); 5578 }); 5579 </text> 5580 } 5581 } 5582 5583 }); 5584 </script> 5585 } 5586 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5587 @using Dynamicweb.Core 5588 @using System 5589 @using System.Web 5590 @using System.Linq 5591 @using System.Collections.Generic 5592 @using Dynamicweb.Rapido.Blocks 5593 @using Dynamicweb.Rapido.Services 5594 5595 @functions { 5596 BlocksPage productListActionsBlocksPage = BlocksPage.GetBlockPage("ProductList"); 5597 } 5598 5599 @{ 5600 string actionsFavoriteListId = HttpContext.Current.Request.QueryString.Get("ListID"); 5601 bool actionsIsFavoriteList = !string.IsNullOrEmpty(actionsFavoriteListId); 5602 string actionsColumnSize = actionsIsFavoriteList ? "4" : "6"; 5603 5604 productListActionsBlocksPage.Add("ProductListHeader", new Block 5605 { 5606 Id = "Actions", 5607 SortId = 30, 5608 Template = RenderListActions(), 5609 Design = new Design 5610 { 5611 CssClass = "grid__col-" + actionsColumnSize + " grid--align-self-center" 5612 } 5613 }); 5614 5615 productListActionsBlocksPage.Add("BottomSnippets", new Block() { 5616 Id = "ListViewSelectListener", 5617 Template = RenderListViewSelectListener() 5618 }); 5619 5620 } 5621 5622 @helper RenderListActions() 5623 { 5624 @*This is part of a script template *@ 5625 5626 bool showSorting = Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableSorting"); 5627 string listId = HttpContext.Current.Request.QueryString.Get("ListID"); 5628 bool isFavoriteList = !string.IsNullOrEmpty(listId); 5629 string cartIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue : "fas fa-shopping-cart"; 5630 5631 List<Block> subBlocks = this.productListActionsBlocksPage.GetBlockListById("Views").OrderBy(item => item.SortId).ToList(); 5632 5633 <div class="buttons-collection buttons-collection--right"> 5634 @if (showSorting && Pageview.Device.ToString() != "Mobile") 5635 { 5636 string dropdownCssClass = Pageview.Device.ToString() == "Mobile" ? "u-flex-grow--1" : ""; 5637 5638 <input type="checkbox" id="ProductSort" class="dropdown-trigger" /> 5639 <div class="dropdown u-w150px u-inline-block @dropdownCssClass dw-mod"> 5640 <label class="dropdown__header dropdown__btn dropdown__btn--small dw-mod" for="ProductSort">{{selectedSort}}</label> 5641 <div class="dropdown__content dw-mod"> 5642 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: '', SortOrder: '' }, true);">@Translate("Default")</div> 5643 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Created', SortOrder: 'DESC'}, true);">@Translate("Newest")</div> 5644 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'NameForSort', SortOrder: 'ASC'}, true);">@Translate("Name A - Z")</div> 5645 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'NameForSort', SortOrder: 'DESC'}, true);">@Translate("Name Z - A")</div> 5646 @if (Dynamicweb.Rapido.Services.User.IsPricesAllowed()) 5647 { 5648 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'ASC' }, true);">@Translate("Price low - high")</div> 5649 <div class="dropdown__item" onclick="HandlebarsBolt.UpdateQueryParameters('productList', { SortBy: 'Price', SortOrder: 'DESC' }, true);">@Translate("Price high - low")</div> 5650 } 5651 </div> 5652 <label class="dropdown-trigger-off" for="ProductSort"></label> 5653 </div> 5654 } 5655 5656 @if (subBlocks.Count > 1 && Pageview.Device.ToString() != "Mobile") 5657 { 5658 <div> 5659 @foreach (Block item in subBlocks) 5660 { 5661 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_@item.Id" name="ViewBtnGroup"> 5662 <label for="ListViewBtn_@item.Id" class="btn btn--tag u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('ProductsContainer', '@item.Id')"><i class="fas fa-@item.Name"></i></label> 5663 } 5664 </div> 5665 } 5666 5667 @if (isFavoriteList && Dynamicweb.Rapido.Services.User.IsBuyingAllowed()) 5668 { 5669 if (Pageview.Device.ToString() != "Mobile") 5670 { 5671 <button type="submit" class="btn btn--secondary btn--sm dw-mod">@Translate("Buy all") <i class="@cartIcon"></i></button> 5672 } 5673 else 5674 { 5675 <button type="submit" class="btn btn--secondary btn--full btn--sm dw-mod">@Translate("Buy all") <i class="@cartIcon"></i></button> 5676 } 5677 } 5678 </div> 5679 } 5680 5681 @helper RenderListViewSelectListener() 5682 { 5683 /* the same block code placed in ProductListFeed.cshtml */ 5684 Dictionary<string, bool> views = new Dictionary<string, bool>() 5685 { 5686 { "ProductItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableListView") }, 5687 { "ProductGridItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableGridView") }, 5688 { "ProductDetailsItemContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableDetailsView") }, 5689 { "ProductTilesViewContainer", Pageview.AreaSettings.GetItem("ProductList").GetBoolean("EnableTilesView") } 5690 }; 5691 5692 string defaultView = Pageview.AreaSettings.GetItem("ProductList").GetList("DefaultListView") != null ? Pageview.AreaSettings.GetItem("ProductList").GetList("DefaultListView").SelectedValue : ""; 5693 5694 if (string.IsNullOrEmpty(defaultView) || !views[defaultView]) 5695 { 5696 defaultView = views.FirstOrDefault(x => x.Value).Key ?? "ProductItemContainer"; 5697 } 5698 5699 <script> 5700 let defaultTemplate = '@defaultView'; 5701 let container = 'productList'; 5702 let cookieName = 'ProductsContainerTemplate'; 5703 5704 document.addEventListener('DOMContentLoaded', function (event) { 5705 document.getElementById(container).addEventListener('contentLoaded', function () { 5706 let selectedMode = RememberState.GetCookie(cookieName); 5707 let element = document.getElementById('ListViewBtn_' + (selectedMode ? selectedMode : defaultTemplate)); 5708 if (element != null) { 5709 element.checked = true; 5710 } 5711 }, false); 5712 }); 5713 </script> 5714 } 5715 5716 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5717 @using Dynamicweb.Core 5718 @using System 5719 @using System.Web 5720 @using System.Collections.Generic 5721 @using Dynamicweb.Rapido.Blocks 5722 5723 @{ 5724 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("ProductList"); 5725 5726 } 5727 5728 5729 @if (productListNavigation.BlocksList.Count == 0) 5730 { 5731 productListNavigation.Design.RenderType = RenderType.Hide; 5732 } 5733 5734 <form name="multiForm" id="multiForm" method="post" onkeypress="return event.keyCode != 13;"> 5735 @* onkeypress is the fix for disabling submit form on Enter key from any field in product list *@ 5736 <input type="hidden" name="CartCmd" id="CartCmd" value="addMulti" /> 5737 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 5738 @RenderBlockList(productListPage.BlocksRoot.BlocksList) 5739 </form> 5740 5741 @helper RenderPageContainer() 5742 { 5743 List<Block> subBlocks = this.productListPage.GetBlockListById("PageContainer").OrderBy(item => item.SortId).ToList(); 5744 var groupid = HttpContext.Current.Request.QueryString["groupid"]; 5745 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 5746 string feedFullUrl = pageUrl + "&feed=true"; 5747 feedFullUrl += !isFavoriteList ? "&DoNotShowVariantsAsSingleProducts=True" : ""; 5748 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "" : "u-padding"; 5749 string pageId = Convert.ToString(Dynamicweb.Frontend.PageView.Current().Page.ID); 5750 string groupUrl = $"/default.aspx?id={pageId}&GroupId="; 5751 var renderGroups = true; 5752 var renderProducts = true; 5753 var group = Services.ProductGroups.GetGroup(groupid); 5754 5755 if (!string.IsNullOrWhiteSpace(groupid)) 5756 { 5757 if (Services.ProductGroups.HasSubgroups(group)) 5758 { 5759 renderProducts = false; 5760 } 5761 else 5762 { 5763 renderGroups = false; 5764 } 5765 5766 } 5767 5768 5769 5770 5771 5772 if (groupid == "GROUP318" || groupid == "GROUP758" || groupid == "1011atSHOP17" || groupid == "1011atSHOP16" || groupid == "1011atSHOP15") 5773 { 5774 renderGroups = false; 5775 } 5776 5777 5778 5779 if (renderGroups) 5780 { 5781 <section class="multiple-paragraphs-container multiple-paragraphs-container--spacing-sm dw-mod groupheader-fix"> 5782 <div class="paragraph-container__grid--bleed-x "> 5783 <div class="grid grid--align-content-start js-handlebars-root" id="groupList" data-template="GroupContainer" data-pre-render-template="ProductPreRenderContainer" data-json-feed="@feedFullUrl" data-no-result-template="NoGroupsFound" data-preloader="overlay"></div> 5784 </div> 5785 </section> 5786 } 5787 5788 if (renderProducts) 5789 { 5790 <div class="grid grid--align-content-start @smallDeviceCss js-handlebars-root" id="productList" data-template="ProductContainer" data-pre-render-template="ProductPreRenderContainer" data-json-feed="@feedFullUrl" data-preloader="overlay"></div> 5791 } 5792 else 5793 { 5794 <div id="productList"></div> 5795 } 5796 5797 5798 5799 5800 <script id="GroupContainer" type="text/x-template"> 5801 {{#.}} 5802 5803 {{#if groupLargeImage}} 5804 <div class="grid"> 5805 <div class="grid__col-12 grid__col--bleed-x"> 5806 <div class="grid__cell group-image"> 5807 <img src="{{groupLargeImage}}" alt="{{groupName}}" /> 5808 </div> 5809 </div> 5810 </div> 5811 {{/if}} 5812 5813 <div class="grid"> 5814 <div class="grid__col-12"> 5815 <div class="grid__cell"> 5816 <div class="u-pull--left"> 5817 <h1><i class="{{headerIcon}}"></i>{{groupName}}</h1> 5818 <div class="u-margin-bottom-lg">{{{groupDescription}}}</div> 5819 </div> 5820 </div> 5821 </div> 5822 </div> 5823 5824 <div class="grid"> 5825 <div class="grid__col-12 grid__col--bleed-x"> 5826 <div class="grid__cell"> 5827 <div id="GroupsContainer" class="grid product-list dw-mod" data-template="GroupGridItemContainer" data-preloader="minimal"> 5828 {{#GroupsContainer}} 5829 {{>GroupGridItemContainer}} 5830 {{/GroupsContainer}} 5831 </div> 5832 </div> 5833 </div> 5834 </div> 5835 5836 5837 5838 {{/.}} 5839 </script> 5840 5841 <script id="GroupGridItemContainer" type="text/x-template"> 5842 {{#.}} 5843 <div id="Group{{id}}" class="grid__col-lg-3 grid__col-md-3 grid__col-sm-3 grid__col-xs-6 product-list__list-item dw-mod" style="{{hide}}" data-template="GroupGridItem" data-preloader="false"> 5844 {{#Group}} 5845 {{>GroupGridItem}} 5846 {{/Group}} 5847 </div> 5848 {{/.}} 5849 </script> 5850 5851 <script id="GroupGridItem" type="text/x-template"> 5852 {{#.}} 5853 <div class="grid__cell u-border dw-mod {{noImage}}"> 5854 <a href="@groupUrl{{link}}" onclick="Scroll.SavePosition(event)"><img class="grid__cell-img grid__cell-sm-img--centered" src="/Admin/Public/GetImage.ashx?width=350&amp;height=350&amp;crop=0&amp;Compression=75&amp;image={{image}}" alt="{{name}}" /></a> 5855 </div> 5856 5857 <div class="grid__cell dw-mod u-margin-top"> 5858 <a href="@groupUrl{{link}}" onclick="Scroll.SavePosition(event)" title="{{name}}"><h6 class="u-condensed-text grid__cell-sm-img--centered">{{name}}</h6></a> 5859 </div> 5860 {{/.}} 5861 </script> 5862 5863 5864 <script id="ProductContainer" type="text/x-template"> 5865 {{#each .}} 5866 @RenderBlockList(subBlocks) 5867 {{else}} 5868 5869 @{ 5870 var searchText = HttpContext.Current.Request.QueryString.Get("Search") != null ? HttpContext.Current.Request.QueryString.Get("Search") : ""; 5871 5872 if (!string.IsNullOrWhiteSpace(searchText)) 5873 { 5874 <div class="grid__col-12"> 5875 <h2 class="u-ta-center">@Translate("Your search gave 0 results")</h2> 5876 </div> 5877 } 5878 5879 } 5880 5881 {{/each}} 5882 </script> 5883 } 5884 5885 @helper RenderProductList() 5886 { 5887 @*This is part of a script template *@ 5888 5889 List<Block> subBlocks = productListPage.GetBlockListById("ProductList").OrderBy(item => item.SortId).ToList(); 5890 string smallDeviceCss = Pageview.Device.ToString() == "Mobile" ? "u-no-padding" : ""; 5891 string columnClass = "auto"; 5892 5893 if (productListPage.GetBlockListById("Navigation").Count == 0) 5894 { 5895 columnClass = "12"; 5896 } 5897 5898 <div class="grid"> 5899 <div class="grid__col-12"> 5900 <div class="grid__cell"> 5901 <div class="u-pull--left"> 5902 <h1><i class="{{headerIcon}}"></i>{{groupName}}</h1> 5903 <div class="u-margin-bottom-lg">{{{groupDescription}}}</div> 5904 </div> 5905 </div> 5906 </div> 5907 </div> 5908 5909 <div class="grid__col-@columnClass @smallDeviceCss"> 5910 @RenderBlockList(subBlocks) 5911 </div> 5912 } 5913 5914 @helper RenderProductListHeader() 5915 { 5916 List<Block> subBlocks = this.productListPage.GetBlockListById("ProductListHeader"); 5917 bool enableSeparationLine = productListSettings.GetBoolean("EnableSeparationLine"); 5918 string className = (enableSeparationLine != null && enableSeparationLine ? "u-border-bottom u-padding-bottom" : ""); 5919 5920 <div class="grid grid--align-content-start grid--justify-end grid--bleed u-margin-bottom--lg u-padding grid--wrap u-flex-grow--0 dw-mod"> 5921 <div class="grid @className"> 5922 @RenderBlockList(subBlocks) 5923 </div> 5924 </div> 5925 } 5926 5927 @helper RenderProductListTitle() 5928 { 5929 var header = new Heading { Title = "{{{header}}}", CssClass = "u-no-margin" }; 5930 var searchText = HttpContext.Current.Request.QueryString.Get("Search") != null ? HttpContext.Current.Request.QueryString.Get("Search") : ""; 5931 5932 if (isFavoriteList) 5933 { 5934 var selectedFavoriteIcon = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon") != null ? Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("FavoriteIcon").SelectedValue : "star"; 5935 header.Icon = new Icon { Prefix = "fas", Name = "fa-" + selectedFavoriteIcon, LabelPosition = IconLabelPosition.After }; 5936 @Render(header) 5937 } 5938 5939 5940 if (!string.IsNullOrWhiteSpace(searchText)) 5941 { 5942 @Render(header) 5943 } 5944 5945 5946 } 5947 5948 @helper RenderFavoriteListSearch() 5949 { 5950 string pageId = GetGlobalValue("Global:Page.ID"); 5951 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 5952 string feedFullUrl = pageUrl + "&feed=true"; 5953 string searchPlaceholder = Translate("Search favorite products"); 5954 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 5955 5956 <div class="typeahead u-color-inherit typeahead--favorites js-typeahead" data-page-size="10" id="FavoritesSearch" data-list-id="@favoriteListId" data-search-feed-id="@pageId&feed=true" data-result-page-id="@pageId"> 5957 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 5958 <ul class="dropdown dropdown--absolute-position u-full-width js-handlebars-root js-typeahead-search-content u-min-w220px u-full-width dw-mod" id="FavoritesSearchContent" data-template="SearchProductsTemplate" data-json-feed="@feedFullUrl&ListID=@favoriteListId" data-init-onload="false" data-preloader="minimal"></ul> 5959 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="fas fa-search"></i></button> 5960 </div> 5961 }