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