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