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