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