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