Error executing template "Designs/Rapido/eCom/ProductCatalog/SpReorderListAjax.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_685e3b92f95949f48a5b74edfa00f059.Execute() in D:\Dynamicweb.net\Solutions\frellsen.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom\ProductCatalog\SpReorderListAjax.cshtml:line 2249
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits ViewModelTemplate<ProductListViewModel> 2 @using Dynamicweb.Rendering 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 @using Smartpage.Frellsen.Reorder 5 @using Dynamicweb.Core 6 @using System.Globalization 7 @using System.Web; 8 @using System.Linq; 9 @using Dynamicweb.Ecommerce.Products 10 @using Smartpage.Frellsen.Reorder.Models 11 12 @inherits ViewModelTemplate<ProductListViewModel> 13 @using System.Linq; 14 @using Dynamicweb.Rapido.Blocks.Components.General 15 @using System.Collections.Generic 16 17 @using Dynamicweb.Rapido.Blocks.Components 18 @using Dynamicweb.Rapido.Blocks.Components.General 19 @using Dynamicweb.Rapido.Blocks 20 @using System.IO 21 22 @* Required *@ 23 @using Dynamicweb.Rapido.Blocks.Components 24 @using Dynamicweb.Rapido.Blocks.Components.General 25 @using Dynamicweb.Rapido.Blocks 26 27 28 @helper Render(ComponentBase component) 29 { 30 if (component != null) 31 { 32 @component.Render(this) 33 } 34 } 35 36 @* Components *@ 37 @using System.Reflection 38 @using Dynamicweb.Rapido.Blocks.Components.General 39 40 41 @* Component *@ 42 43 @helper RenderIcon(Icon settings) 44 { 45 if (settings != null) 46 { 47 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 48 49 if (settings.Name != null) 50 { 51 if (string.IsNullOrEmpty(settings.Label)) 52 { 53 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 54 } 55 else 56 { 57 if (settings.LabelPosition == IconLabelPosition.Before) 58 { 59 <div class="u-flex u-flex--align-items-center @settings.CssClass">@settings.Label <i class="@settings.Prefix @settings.Name u-margin-left" @color></i></div> 60 } 61 else 62 { 63 <div class="u-flex u-flex--align-items-center @settings.CssClass"><i class="@settings.Prefix @settings.Name u-margin-right--lg u-w20px" @color></i>@settings.Label</div> 64 } 65 } 66 } 67 else if (!string.IsNullOrEmpty(settings.Label)) 68 { 69 @settings.Label 70 } 71 } 72 } 73 @using System.Reflection 74 @using Dynamicweb.Rapido.Blocks.Components.General 75 @using Dynamicweb.Rapido.Blocks.Components 76 @using Dynamicweb.Core 77 78 @* Component *@ 79 80 @helper RenderButton(Button settings) 81 { 82 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 83 { 84 Dictionary<string, string> attributes = new Dictionary<string, string>(); 85 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 86 if (settings.Disabled) { 87 attributes.Add("disabled", "true"); 88 classList.Add("disabled"); 89 } 90 91 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 92 { 93 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 94 @RenderConfirmDialog(settings); 95 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 96 } 97 98 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 99 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 100 if (!string.IsNullOrEmpty(settings.AltText)) 101 { 102 attributes.Add("title", settings.AltText); 103 } 104 else if (!string.IsNullOrEmpty(settings.Title)) 105 { 106 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 107 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 108 attributes.Add("title", cleanTitle); 109 } 110 111 var onClickEvents = new List<string>(); 112 if (!string.IsNullOrEmpty(settings.OnClick)) 113 { 114 onClickEvents.Add(settings.OnClick); 115 } 116 if (!string.IsNullOrEmpty(settings.Href)) 117 { 118 onClickEvents.Add("location.href='" + settings.Href + "'"); 119 } 120 if (onClickEvents.Count > 0) 121 { 122 attributes.Add("onClick", string.Join(";", onClickEvents)); 123 } 124 125 //If link is a paragraph, go to that paragraph 126 if (!string.IsNullOrEmpty(settings.Href) && settings.Href.Contains("#")) 127 { 128 int pageId = Dynamicweb.Environment.Helpers.LinkHelper.GetInternalPageId(settings.Href); 129 string[] hrefSplit = settings.Href.Trim().Split('#'); 130 string idToScrollTo = "p_" + hrefSplit[1].Trim(); 131 132 if (Pageview.ID == pageId) 133 { 134 attributes.Remove("onClick"); 135 attributes.Add("onClick", "window.scrollIntoViewHeaderOffset(document.getElementById('" + idToScrollTo + "'))"); 136 } 137 else if (pageId != 0) 138 { 139 settings.Href = hrefSplit[0].Trim() + "#" + hrefSplit[1].Trim(); 140 attributes.Remove("onClick"); 141 attributes.Add("onClick", "location.href='" + settings.Href + "'"); 142 } 143 } 144 145 if (settings.ButtonLayout != ButtonLayout.None) 146 { 147 classList.Add("btn"); 148 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 149 if (btnLayout == "linkclean") 150 { 151 btnLayout = "link-clean"; //fix 152 } 153 classList.Add("btn--" + btnLayout); 154 } 155 156 if (settings.Icon == null) 157 { 158 settings.Icon = new Icon(); 159 } 160 161 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 162 settings.Icon.Label = settings.Title; 163 164 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 165 166 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 167 } 168 } 169 170 @helper RenderConfirmDialog(Button settings) 171 { 172 Modal confirmDialog = new Modal { 173 Id = settings.Id, 174 Width = ModalWidth.Sm, 175 Heading = new Heading 176 { 177 Level = 2, 178 Title = settings.ConfirmTitle 179 }, 180 BodyText = settings.ConfirmText 181 }; 182 183 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 184 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 185 186 @Render(confirmDialog) 187 } 188 @using Dynamicweb.Rapido.Blocks.Components.General 189 @using Dynamicweb.Rapido.Blocks.Components 190 @using Dynamicweb.Core 191 192 @helper RenderDashboard(Dashboard settings) 193 { 194 var widgets = settings.GetWidgets(); 195 196 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 197 { 198 //set bg color for them 199 200 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 201 int r = Convert.ToInt16(color.R); 202 int g = Convert.ToInt16(color.G); 203 int b = Convert.ToInt16(color.B); 204 205 var count = widgets.Length; 206 var max = Math.Max(r, Math.Max(g, b)); 207 double step = 255.0 / (max * count); 208 var i = 0; 209 foreach (var widget in widgets) 210 { 211 i++; 212 213 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 214 widget.BackgroundColor = shade; 215 } 216 } 217 218 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 219 @foreach (var widget in widgets) 220 { 221 <div class="dashboard__widget"> 222 @Render(widget) 223 </div> 224 } 225 </div> 226 } 227 @using Dynamicweb.Rapido.Blocks.Components.General 228 @using Dynamicweb.Rapido.Blocks.Components 229 230 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 231 { 232 if (!string.IsNullOrEmpty(settings.Link)) 233 { 234 var backgroundStyles = ""; 235 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 236 { 237 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 238 } 239 240 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 241 <div class="u-center-middle u-color-light"> 242 @if (settings.Icon != null) 243 { 244 settings.Icon.CssClass += "widget__icon"; 245 @Render(settings.Icon) 246 } 247 <div class="widget__title">@settings.Title</div> 248 </div> 249 </a> 250 } 251 } 252 @using Dynamicweb.Rapido.Blocks.Components.General 253 @using Dynamicweb.Rapido.Blocks.Components 254 255 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 256 { 257 var backgroundStyles = ""; 258 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 259 { 260 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 261 } 262 263 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 264 <div class="u-center-middle u-color-light"> 265 @if (settings.Icon != null) 266 { 267 settings.Icon.CssClass += "widget__icon"; 268 @Render(settings.Icon) 269 } 270 <div class="widget__counter">@settings.Count</div> 271 <div class="widget__title">@settings.Title</div> 272 </div> 273 </div> 274 } 275 @using System.Reflection 276 @using Dynamicweb.Rapido.Blocks.Components.General 277 @using Dynamicweb.Rapido.Blocks.Components 278 @using Dynamicweb.Core 279 280 @* Component *@ 281 282 @helper RenderLink(Link settings) 283 { 284 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 285 { 286 Dictionary<string, string> attributes = new Dictionary<string, string>(); 287 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 288 if (settings.Disabled) 289 { 290 attributes.Add("disabled", "true"); 291 classList.Add("disabled"); 292 } 293 294 if (!string.IsNullOrEmpty(settings.AltText)) 295 { 296 attributes.Add("title", settings.AltText); 297 } 298 else if (!string.IsNullOrEmpty(settings.Title)) 299 { 300 attributes.Add("title", settings.Title); 301 } 302 303 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 304 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 305 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 306 attributes.Add("href", settings.Href); 307 308 if (settings.ButtonLayout != ButtonLayout.None) 309 { 310 classList.Add("btn"); 311 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 312 if (btnLayout == "linkclean") 313 { 314 btnLayout = "link-clean"; //fix 315 } 316 classList.Add("btn--" + btnLayout); 317 } 318 319 if (settings.Icon == null) 320 { 321 settings.Icon = new Icon(); 322 } 323 settings.Icon.Label = settings.Title; 324 325 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 326 { 327 settings.Rel = LinkRelType.Noopener; 328 } 329 if (settings.Target != LinkTargetType.None) 330 { 331 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 332 } 333 if (settings.Download) 334 { 335 attributes.Add("download", "true"); 336 } 337 if (settings.Rel != LinkRelType.None) 338 { 339 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 340 } 341 342 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 343 } 344 } 345 @using System.Reflection 346 @using Dynamicweb.Rapido.Blocks.Components 347 @using Dynamicweb.Rapido.Blocks.Components.General 348 @using Dynamicweb.Rapido.Blocks 349 350 351 @* Component *@ 352 353 @helper RenderRating(Rating settings) 354 { 355 if (settings.Score > 0) 356 { 357 int rating = settings.Score; 358 string iconType = "fa-star"; 359 360 switch (settings.Type.ToString()) { 361 case "Stars": 362 iconType = "fa-star"; 363 break; 364 case "Hearts": 365 iconType = "fa-heart"; 366 break; 367 case "Lemons": 368 iconType = "fa-lemon"; 369 break; 370 case "Bombs": 371 iconType = "fa-bomb"; 372 break; 373 } 374 375 <div class="u-ta-right"> 376 @for (int i = 0; i < settings.OutOf; i++) 377 { 378 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 379 } 380 </div> 381 } 382 } 383 @using System.Reflection 384 @using Dynamicweb.Rapido.Blocks.Components.General 385 @using Dynamicweb.Rapido.Blocks.Components 386 387 388 @* Component *@ 389 390 @helper RenderSelectFieldOption(SelectFieldOption settings) 391 { 392 Dictionary<string, string> attributes = new Dictionary<string, string>(); 393 if (settings.Checked) { attributes.Add("selected", "true"); } 394 if (settings.Disabled) { attributes.Add("disabled", "true"); } 395 if (settings.Value != null) { attributes.Add("value", settings.Value); } 396 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 397 398 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 399 } 400 @using System.Reflection 401 @using Dynamicweb.Rapido.Blocks.Components.General 402 @using Dynamicweb.Rapido.Blocks.Components 403 404 405 @* Component *@ 406 407 @helper RenderNavigation(Navigation settings) { 408 @RenderNavigation(new 409 { 410 id = settings.Id, 411 cssclass = settings.CssClass, 412 startLevel = settings.StartLevel, 413 endlevel = settings.EndLevel, 414 expandmode = settings.Expandmode, 415 sitemapmode = settings.SitemapMode, 416 template = settings.Template 417 }) 418 } 419 @using Dynamicweb.Rapido.Blocks.Components.General 420 @using Dynamicweb.Rapido.Blocks.Components 421 422 423 @* Component *@ 424 425 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 426 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 427 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 428 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 429 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 430 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 431 settings.SitemapMode = false; 432 433 @RenderNavigation(settings) 434 } 435 @using Dynamicweb.Rapido.Blocks.Components.General 436 @using Dynamicweb.Rapido.Blocks.Components 437 438 439 @* Component *@ 440 441 @helper RenderLeftNavigation(LeftNavigation settings) { 442 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 443 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 444 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 445 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 446 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 447 448 <div class="grid__cell"> 449 @RenderNavigation(settings) 450 </div> 451 } 452 @using System.Reflection 453 @using Dynamicweb.Rapido.Blocks.Components.General 454 @using Dynamicweb.Core 455 456 @* Component *@ 457 458 @helper RenderHeading(Heading settings) 459 { 460 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 461 { 462 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 463 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 464 465 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 466 if (!string.IsNullOrEmpty(settings.Link)) 467 { 468 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 469 } 470 else 471 { 472 if (settings.Icon == null) 473 { 474 settings.Icon = new Icon(); 475 } 476 settings.Icon.Label = settings.Title; 477 @Render(settings.Icon) 478 } 479 @("</" + tagName + ">"); 480 } 481 } 482 @using Dynamicweb.Rapido.Blocks.Components 483 @using Dynamicweb.Rapido.Blocks.Components.General 484 @using Dynamicweb.Rapido.Blocks 485 486 487 @* Component *@ 488 489 @helper RenderImage(Image settings) 490 { 491 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 492 { 493 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 494 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 495 496 if (settings.Caption != null) 497 { 498 @:<div> 499 } 500 501 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 502 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 503 504 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 505 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 506 @if (settings.Link != null) 507 { 508 <a href="@settings.Link"> 509 @RenderTheImage(settings) 510 </a> 511 } 512 else 513 { 514 @RenderTheImage(settings) 515 } 516 </div> 517 </div> 518 519 if (settings.Caption != null) 520 { 521 <span class="image-caption dw-mod">@settings.Caption</span> 522 @:</div> 523 } 524 } 525 else 526 { 527 if (settings.Caption != null) 528 { 529 @:<div> 530 } 531 if (!string.IsNullOrEmpty(settings.Link)) 532 { 533 <a href="@settings.Link"> 534 @RenderTheImage(settings) 535 </a> 536 } 537 else 538 { 539 @RenderTheImage(settings) 540 } 541 542 if (settings.Caption != null) 543 { 544 <span class="image-caption dw-mod">@settings.Caption</span> 545 @:</div> 546 } 547 } 548 } 549 550 @helper RenderTheImage(Image settings) 551 { 552 if (settings != null) 553 { 554 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 555 string placeholderImage = "/Files/Images/placeholder.gif"; 556 string imageEngine = "/Admin/Public/GetImage.ashx?"; 557 558 string imageStyle = ""; 559 560 switch (settings.Style) 561 { 562 case ImageStyle.Ball: 563 imageStyle = "grid__cell-img--ball"; 564 break; 565 566 case ImageStyle.Triangle: 567 imageStyle = "grid__cell-img--triangle"; 568 break; 569 } 570 571 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 572 { 573 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 574 575 if (settings.ImageDefault != null) 576 { 577 settings.ImageDefault.Height = settings.ImageDefault.Width; 578 } 579 if (settings.ImageMedium != null) 580 { 581 settings.ImageMedium.Height = settings.ImageMedium.Width; 582 } 583 if (settings.ImageSmall != null) 584 { 585 settings.ImageSmall.Height = settings.ImageSmall.Width; 586 } 587 } 588 589 string defaultImage = imageEngine; 590 string imageSmall = ""; 591 string imageMedium = ""; 592 593 if (settings.DisableImageEngine) 594 { 595 defaultImage = settings.Path; 596 } 597 else 598 { 599 if (settings.ImageDefault != null) 600 { 601 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 602 603 if (settings.Path?.GetType() != typeof(string)) 604 { 605 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 606 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 607 } 608 else 609 { 610 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 611 } 612 613 defaultImage += "&AlternativeImage=" + alternativeImage; 614 } 615 616 if (settings.ImageSmall != null) 617 { 618 imageSmall = "data-src-small=\"" + imageEngine; 619 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 620 621 if (settings.Path?.GetType() != typeof(string)) 622 { 623 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 624 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 625 } 626 else 627 { 628 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 629 } 630 631 imageSmall += "&alternativeImage=" + alternativeImage; 632 633 imageSmall += "\""; 634 } 635 636 if (settings.ImageMedium != null) 637 { 638 imageMedium = "data-src-medium=\"" + imageEngine; 639 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 640 641 if (settings.Path?.GetType() != typeof(string)) 642 { 643 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 644 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 645 } 646 else 647 { 648 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 649 } 650 651 imageMedium += "&alternativeImage=" + alternativeImage; 652 653 imageMedium += "\""; 654 } 655 } 656 657 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 658 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 659 if (!string.IsNullOrEmpty(settings.Title)) 660 { 661 optionalAttributes.Add("alt", settings.Title); 662 optionalAttributes.Add("title", settings.Title); 663 } 664 665 if (settings.DisableLazyLoad) 666 { 667 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 668 } 669 else 670 { 671 <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) /> 672 } 673 } 674 } 675 @using System.Reflection 676 @using Dynamicweb.Rapido.Blocks.Components.General 677 @using Dynamicweb.Rapido.Blocks.Components 678 679 @* Component *@ 680 681 @helper RenderFileField(FileField settings) 682 { 683 var attributes = new Dictionary<string, string>(); 684 if (string.IsNullOrEmpty(settings.Id)) 685 { 686 settings.Id = Guid.NewGuid().ToString("N"); 687 } 688 689 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 690 if (settings.Disabled) { attributes.Add("disabled", "true"); } 691 if (settings.Required) { attributes.Add("required", "true"); } 692 if (settings.Multiple) { attributes.Add("multiple", "true"); } 693 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 694 if (string.IsNullOrEmpty(settings.ChooseFileText)) 695 { 696 settings.ChooseFileText = Translate("Choose file"); 697 } 698 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 699 { 700 settings.NoFilesChosenText = Translate("No files chosen..."); 701 } 702 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 703 704 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 705 706 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 707 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 708 709 attributes.Add("type", "file"); 710 if (settings.Value != null) { attributes.Add("value", settings.Value); } 711 settings.CssClass = "u-full-width " + settings.CssClass; 712 713 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 714 715 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 716 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 717 { 718 <div class="u-full-width"> 719 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 720 @if (settings.Link != null) { 721 <div class="u-pull--right"> 722 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 723 @Render(settings.Link) 724 </div> 725 } 726 </div> 727 728 } 729 730 @if (!string.IsNullOrEmpty(settings.HelpText)) 731 { 732 <small class="form__help-text">@settings.HelpText</small> 733 } 734 735 <div class="form__field-combi file-input u-no-margin dw-mod"> 736 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 737 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 738 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 739 @if (settings.UploadButton != null) 740 { 741 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 742 @Render(settings.UploadButton) 743 } 744 </div> 745 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 746 </div> 747 } 748 @using System.Reflection 749 @using Dynamicweb.Rapido.Blocks.Components.General 750 @using Dynamicweb.Rapido.Blocks.Components 751 @using Dynamicweb.Core 752 @using System.Linq 753 754 @* Component *@ 755 756 @helper RenderDateTimeField(DateTimeField settings) 757 { 758 if (string.IsNullOrEmpty(settings.Id)) 759 { 760 settings.Id = Guid.NewGuid().ToString("N"); 761 } 762 763 var textField = new TextField { 764 Name = settings.Name, 765 Id = settings.Id, 766 Label = settings.Label, 767 HelpText = settings.HelpText, 768 Value = settings.Value, 769 Disabled = settings.Disabled, 770 Required = settings.Required, 771 ErrorMessage = settings.ErrorMessage, 772 CssClass = settings.CssClass, 773 WrapperCssClass = settings.WrapperCssClass, 774 OnChange = settings.OnChange, 775 OnClick = settings.OnClick, 776 Link = settings.Link, 777 ExtraAttributes = settings.ExtraAttributes, 778 // 779 Placeholder = settings.Placeholder 780 }; 781 782 @Render(textField) 783 784 List<string> jsAttributes = new List<string>(); 785 786 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 787 788 if (!string.IsNullOrEmpty(settings.DateFormat)) 789 { 790 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 791 } 792 if (!string.IsNullOrEmpty(settings.MinDate)) 793 { 794 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 795 } 796 if (!string.IsNullOrEmpty(settings.MaxDate)) 797 { 798 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 799 } 800 if (settings.IsInline) 801 { 802 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 803 } 804 if (settings.EnableTime) 805 { 806 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 807 } 808 if (settings.EnableWeekNumbers) 809 { 810 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 811 } 812 813 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 814 815 <script> 816 document.addEventListener("DOMContentLoaded", function () { 817 flatpickr("#@textField.Id", { 818 @string.Join(",", jsAttributes) 819 }); 820 }); 821 </script> 822 } 823 @using System.Reflection 824 @using Dynamicweb.Rapido.Blocks.Components.General 825 @using Dynamicweb.Rapido.Blocks.Components 826 827 @* Component *@ 828 829 @helper RenderTextField(TextField settings) 830 { 831 var attributes = new Dictionary<string, string>(); 832 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 833 { 834 settings.Id = Guid.NewGuid().ToString("N"); 835 } 836 837 /*base settings*/ 838 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 839 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 840 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 841 if (settings.Disabled) { attributes.Add("disabled", "true"); } 842 if (settings.Required) { attributes.Add("required", "true"); } 843 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 844 /*end*/ 845 846 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 847 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 848 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 849 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 850 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 851 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 852 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 853 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 854 if (settings.Value != null) { attributes.Add("value", settings.Value); } 855 856 settings.CssClass = "u-full-width " + settings.CssClass; 857 858 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 859 860 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 861 862 string noMargin = "u-no-margin"; 863 if (!settings.ReadOnly) 864 { 865 noMargin = ""; 866 } 867 868 if (!string.IsNullOrEmpty(settings.HelpText)) 869 { 870 settings.WrapperCssClass += " tooltip"; 871 } 872 873 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 874 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null) 875 { 876 <div class="u-full-width"> 877 @if (!string.IsNullOrEmpty(settings.Label)) 878 {<label for="@settings.Id" class="u-pull--left">@settings.Label</label>} 879 @if (settings.Link != null) 880 { 881 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 882 883 <div class="u-pull--right"> 884 @Render(settings.Link) 885 </div> 886 } 887 </div> 888 889 } 890 891 @if (!string.IsNullOrEmpty(settings.HelpText)) 892 { 893 <span class="tooltip-content"> 894 <span class="tooltip-text"> 895 <span class="tooltip-inner"> 896 @settings.HelpText 897 </span> 898 </span> 899 </span> 900 } 901 902 @if (settings.ActionButton != null) 903 { 904 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 905 <div class="form__field-combi u-no-margin dw-mod"> 906 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 907 @Render(settings.ActionButton) 908 </div> 909 } 910 else 911 { 912 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 913 } 914 915 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 916 </div> 917 } 918 @using System.Reflection 919 @using Dynamicweb.Rapido.Blocks.Components.General 920 @using Dynamicweb.Rapido.Blocks.Components 921 922 @* Component *@ 923 924 @helper RenderNumberField(NumberField settings) 925 { 926 var attributes = new Dictionary<string, string>(); 927 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 928 { 929 settings.Id = Guid.NewGuid().ToString("N"); 930 } 931 932 /*base settings*/ 933 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 934 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 935 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 936 if (settings.Disabled) { attributes.Add("disabled", "true"); } 937 if (settings.Required) { attributes.Add("required", "true"); } 938 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 939 /*end*/ 940 941 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 942 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 943 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 944 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 945 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 946 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 947 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 948 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 949 attributes.Add("type", "number"); 950 951 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 952 953 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 954 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 955 { 956 <div class="u-full-width"> 957 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 958 @if (settings.Link != null) { 959 <div class="u-pull--right"> 960 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 961 @Render(settings.Link) 962 </div> 963 } 964 </div> 965 966 } 967 968 @if (!string.IsNullOrEmpty(settings.HelpText)) 969 { 970 <small class="form__help-text">@settings.HelpText</small> 971 } 972 973 @if (settings.ActionButton != null) 974 { 975 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 976 <div class="form__field-combi u-no-margin dw-mod"> 977 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 978 @Render(settings.ActionButton) 979 </div> 980 } 981 else 982 { 983 <div class="form__field-combi u-no-margin dw-mod"> 984 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 985 </div> 986 } 987 988 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 989 </div> 990 } 991 @using System.Reflection 992 @using Dynamicweb.Rapido.Blocks.Components.General 993 @using Dynamicweb.Rapido.Blocks.Components 994 995 996 @* Component *@ 997 998 @helper RenderTextareaField(TextareaField settings) 999 { 1000 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1001 string id = settings.Id; 1002 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1003 { 1004 id = Guid.NewGuid().ToString("N"); 1005 } 1006 1007 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1008 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1009 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1010 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1011 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1012 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1013 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1014 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1015 if (settings.Required) { attributes.Add("required", "true"); } 1016 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1017 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1018 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1019 attributes.Add("name", settings.Name); 1020 1021 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1022 1023 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1024 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1025 { 1026 <div class="u-full-width"> 1027 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1028 @if (settings.Link != null) { 1029 <div class="u-pull--right"> 1030 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1031 @Render(settings.Link) 1032 </div> 1033 } 1034 </div> 1035 } 1036 1037 @if (!string.IsNullOrEmpty(settings.HelpText)) 1038 { 1039 <small class="form__help-text">@settings.HelpText</small> 1040 } 1041 1042 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1043 1044 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1045 </div> 1046 } 1047 @using System.Reflection 1048 @using Dynamicweb.Rapido.Blocks.Components.General 1049 @using Dynamicweb.Rapido.Blocks.Components 1050 1051 1052 @* Component *@ 1053 1054 @helper RenderHiddenField(HiddenField settings) { 1055 var attributes = new Dictionary<string, string>(); 1056 attributes.Add("type", "hidden"); 1057 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1058 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1059 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1060 1061 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1062 } 1063 @using System.Reflection 1064 @using Dynamicweb.Rapido.Blocks.Components.General 1065 @using Dynamicweb.Rapido.Blocks.Components 1066 1067 @* Component *@ 1068 1069 @helper RenderCheckboxField(CheckboxField settings) 1070 { 1071 var attributes = new Dictionary<string, string>(); 1072 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1073 { 1074 settings.Id = Guid.NewGuid().ToString("N"); 1075 } 1076 1077 /*base settings*/ 1078 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1079 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1080 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1081 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1082 if (settings.Required) { attributes.Add("required", "true"); } 1083 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1084 /*end*/ 1085 1086 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1087 1088 attributes.Add("type", "checkbox"); 1089 if (settings.Checked) { attributes.Add("checked", "true"); } 1090 settings.CssClass = "form__control " + settings.CssClass; 1091 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1092 1093 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1094 1095 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1096 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1097 @if (!string.IsNullOrEmpty(settings.Label)) 1098 { 1099 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1100 } 1101 1102 @if (settings.Link != null) { 1103 <span> 1104 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1105 @Render(settings.Link) 1106 </span> 1107 } 1108 1109 @if (!string.IsNullOrEmpty(settings.HelpText)) 1110 { 1111 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1112 } 1113 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1114 </div> 1115 } 1116 @using System.Reflection 1117 @using Dynamicweb.Rapido.Blocks.Components.General 1118 @using Dynamicweb.Rapido.Blocks.Components 1119 1120 1121 @* Component *@ 1122 1123 @helper RenderCheckboxListField(CheckboxListField settings) 1124 { 1125 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1126 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1127 { 1128 <div class="u-full-width"> 1129 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1130 @if (settings.Link != null) { 1131 <div class="u-pull--right"> 1132 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1133 @Render(settings.Link) 1134 </div> 1135 } 1136 </div> 1137 1138 } 1139 1140 <div class="u-pull--left"> 1141 @if (!string.IsNullOrEmpty(settings.HelpText)) 1142 { 1143 <small class="form__help-text">@settings.HelpText</small> 1144 } 1145 1146 @foreach (var item in settings.Options) 1147 { 1148 if (settings.Required) 1149 { 1150 item.Required = true; 1151 } 1152 if (settings.Disabled) 1153 { 1154 item.Disabled = true; 1155 } 1156 if (!string.IsNullOrEmpty(settings.Name)) 1157 { 1158 item.Name = settings.Name; 1159 } 1160 if (!string.IsNullOrEmpty(settings.CssClass)) 1161 { 1162 item.CssClass += settings.CssClass; 1163 } 1164 1165 /* value is not supported */ 1166 1167 if (!string.IsNullOrEmpty(settings.OnClick)) 1168 { 1169 item.OnClick += settings.OnClick; 1170 } 1171 if (!string.IsNullOrEmpty(settings.OnChange)) 1172 { 1173 item.OnChange += settings.OnChange; 1174 } 1175 @Render(item) 1176 } 1177 1178 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1179 </div> 1180 1181 </div> 1182 } 1183 @using Dynamicweb.Rapido.Blocks.Components.General 1184 1185 @* Component *@ 1186 1187 @helper RenderSearch(Search settings) 1188 { 1189 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1190 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1191 1192 if (string.IsNullOrEmpty(settings.Id)) 1193 { 1194 settings.Id = Guid.NewGuid().ToString("N"); 1195 } 1196 1197 var resultAttributes = new Dictionary<string, string>(); 1198 1199 if (settings.PageSize != 0) 1200 { 1201 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1202 } 1203 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1204 { 1205 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1206 if (!string.IsNullOrEmpty(groupValue)) 1207 { 1208 resultAttributes.Add("data-selected-group", groupValue); 1209 } 1210 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1211 { 1212 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1213 } 1214 } 1215 resultAttributes.Add("data-force-init", "true"); 1216 if (settings.GoToFirstSearchResultOnEnter) 1217 { 1218 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1219 } 1220 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1221 { 1222 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1223 } 1224 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1225 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1226 1227 if (settings.SecondSearchData != null) 1228 { 1229 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1230 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1231 } 1232 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1233 { 1234 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1235 } 1236 1237 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1238 1239 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1240 1241 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1242 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1243 { 1244 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1245 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1246 } 1247 1248 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1249 1250 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1251 @if (settings.SecondSearchData != null) 1252 { 1253 <div class="search__column search__column--products dw-mod"> 1254 <div class="search__column-header dw-mod">@Translate("Products")</div> 1255 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1256 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1257 { 1258 @Render(new Link { 1259 Title = Translate("View all"), 1260 CssClass = "js-view-all-button u-margin", 1261 Href = settings.SearchData.ResultsPageUrl 1262 }); 1263 } 1264 </div> 1265 <div class="search__column search__column--pages dw-mod"> 1266 <div class="search__column-header">@Translate("Pages")</div> 1267 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1268 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1269 { 1270 @Render(new Link 1271 { 1272 Title = Translate("View all"), 1273 CssClass = "js-view-all-button u-margin", 1274 Href = settings.SecondSearchData.ResultsPageUrl 1275 }); 1276 } 1277 </div> 1278 } 1279 else 1280 { 1281 <div class="search__column search__column--only dw-mod"> 1282 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1283 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1284 { 1285 @Render(new Link { 1286 Title = Translate("View all"), 1287 CssClass = "js-view-all-button u-margin", 1288 Href = settings.SearchData.ResultsPageUrl 1289 }); 1290 } 1291 </div> 1292 } 1293 </div> 1294 1295 @if (settings.SearchButton != null) 1296 { 1297 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1298 if (settings.RenderDefaultSearchIcon) 1299 { 1300 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1301 } 1302 @Render(settings.SearchButton); 1303 } 1304 </div> 1305 } 1306 @using System.Reflection 1307 @using Dynamicweb.Rapido.Blocks.Components.General 1308 @using Dynamicweb.Rapido.Blocks.Components 1309 1310 1311 @* Component *@ 1312 1313 @helper RenderSelectField(SelectField settings) 1314 { 1315 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1316 { 1317 settings.Id = Guid.NewGuid().ToString("N"); 1318 } 1319 1320 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1321 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1322 { 1323 <div class="u-full-width"> 1324 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1325 @if (settings.Link != null) { 1326 <div class="u-pull--right"> 1327 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1328 @Render(settings.Link) 1329 </div> 1330 } 1331 </div> 1332 } 1333 1334 @if (!string.IsNullOrEmpty(settings.HelpText)) 1335 { 1336 <small class="form__help-text">@settings.HelpText</small> 1337 } 1338 1339 @if (settings.ActionButton != null) 1340 { 1341 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1342 <div class="form__field-combi u-no-margin dw-mod"> 1343 @RenderSelectBase(settings) 1344 @Render(settings.ActionButton) 1345 </div> 1346 } 1347 else 1348 { 1349 @RenderSelectBase(settings) 1350 } 1351 1352 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1353 </div> 1354 } 1355 1356 @helper RenderSelectBase(SelectField settings) 1357 { 1358 var attributes = new Dictionary<string, string>(); 1359 1360 /*base settings*/ 1361 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1362 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1363 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1364 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1365 if (settings.Required) { attributes.Add("required", "true"); } 1366 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1367 /*end*/ 1368 1369 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1370 1371 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1372 @if (settings.Default != null) 1373 { 1374 @Render(settings.Default) 1375 } 1376 1377 @foreach (var item in settings.Options) 1378 { 1379 if (settings.Value != null) { 1380 item.Checked = item.Value == settings.Value; 1381 } 1382 @Render(item) 1383 } 1384 </select> 1385 } 1386 @using System.Reflection 1387 @using Dynamicweb.Rapido.Blocks.Components.General 1388 @using Dynamicweb.Rapido.Blocks.Components 1389 1390 @* Component *@ 1391 1392 @helper RenderRadioButtonField(RadioButtonField settings) 1393 { 1394 var attributes = new Dictionary<string, string>(); 1395 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1396 { 1397 settings.Id = Guid.NewGuid().ToString("N"); 1398 } 1399 1400 /*base settings*/ 1401 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1402 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1403 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1404 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1405 if (settings.Required) { attributes.Add("required", "true"); } 1406 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1407 /*end*/ 1408 1409 attributes.Add("type", "radio"); 1410 if (settings.Checked) { attributes.Add("checked", "true"); } 1411 settings.CssClass = "form__control " + settings.CssClass; 1412 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1413 1414 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1415 1416 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1417 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1418 @if (!string.IsNullOrEmpty(settings.Label)) 1419 { 1420 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1421 } 1422 @if (!string.IsNullOrEmpty(settings.HelpText)) 1423 { 1424 <small class="form__help-text">@settings.HelpText</small> 1425 } 1426 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1427 </div> 1428 } 1429 @using System.Reflection 1430 @using Dynamicweb.Rapido.Blocks.Components.General 1431 @using Dynamicweb.Rapido.Blocks.Components 1432 1433 1434 @* Component *@ 1435 1436 @helper RenderRadioButtonListField(RadioButtonListField settings) 1437 { 1438 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1439 1440 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1441 @if (!string.IsNullOrEmpty(settings.Label)) 1442 { 1443 <label>@settings.Label</label> 1444 } 1445 @if (!string.IsNullOrEmpty(settings.HelpText)) 1446 { 1447 <small class="form__help-text">@settings.HelpText</small> 1448 } 1449 1450 @foreach (var item in settings.Options) 1451 { 1452 if (settings.Required) 1453 { 1454 item.Required = true; 1455 } 1456 if (settings.Disabled) 1457 { 1458 item.Disabled = true; 1459 } 1460 if (!string.IsNullOrEmpty(settings.Name)) 1461 { 1462 item.Name = settings.Name; 1463 } 1464 if (settings.Value != null && settings.Value == item.Value) 1465 { 1466 item.Checked = true; 1467 } 1468 if (!string.IsNullOrEmpty(settings.OnClick)) 1469 { 1470 item.OnClick += settings.OnClick; 1471 } 1472 if (!string.IsNullOrEmpty(settings.OnChange)) 1473 { 1474 item.OnChange += settings.OnChange; 1475 } 1476 if (!string.IsNullOrEmpty(settings.CssClass)) 1477 { 1478 item.CssClass += settings.CssClass; 1479 } 1480 @Render(item) 1481 } 1482 1483 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1484 </div> 1485 } 1486 @using System.Reflection 1487 @using Dynamicweb.Rapido.Blocks.Components.General 1488 @using Dynamicweb.Rapido.Blocks.Components 1489 1490 1491 @* Component *@ 1492 1493 @helper RenderNotificationMessage(NotificationMessage settings) 1494 { 1495 if (!string.IsNullOrEmpty(settings.Message)) 1496 { 1497 var attributes = new Dictionary<string, string>(); 1498 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1499 1500 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1501 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 1502 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 1503 1504 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 1505 @if (settings.Icon != null) { 1506 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 1507 @Render(settings.Icon) 1508 } else { 1509 @settings.Message 1510 } 1511 </div> 1512 } 1513 } 1514 @using Dynamicweb.Rapido.Blocks.Components.General 1515 1516 1517 @* Component *@ 1518 1519 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1520 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1521 1522 <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> 1523 @if (settings.SubBlocks != null) { 1524 @RenderBlockList(settings.SubBlocks) 1525 } 1526 </div> 1527 } 1528 @using System.Reflection 1529 @using Dynamicweb.Rapido.Blocks.Components.General 1530 @using Dynamicweb.Rapido.Blocks.Components 1531 @using System.Text.RegularExpressions 1532 1533 1534 @* Component *@ 1535 1536 @helper RenderSticker(Sticker settings) { 1537 if (!String.IsNullOrEmpty(settings.Title)) { 1538 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1539 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1540 1541 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1542 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1543 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1544 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1545 optionalAttributes.Add("style", styleTag); 1546 } 1547 1548 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1549 } 1550 } 1551 1552 @using System.Reflection 1553 @using Dynamicweb.Rapido.Blocks.Components.General 1554 @using Dynamicweb.Rapido.Blocks.Components 1555 1556 1557 @* Component *@ 1558 1559 @helper RenderStickersCollection(StickersCollection settings) 1560 { 1561 if (settings.Stickers.Count > 0) 1562 { 1563 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1564 1565 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1566 @foreach (Sticker sticker in settings.Stickers) 1567 { 1568 @Render(sticker) 1569 } 1570 </div> 1571 } 1572 } 1573 1574 @using Dynamicweb.Rapido.Blocks.Components.General 1575 1576 1577 @* Component *@ 1578 1579 @helper RenderForm(Form settings) { 1580 if (settings != null) 1581 { 1582 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1583 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1584 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1585 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1586 var enctypes = new Dictionary<string, string> 1587 { 1588 { "multipart", "multipart/form-data" }, 1589 { "text", "text/plain" }, 1590 { "application", "application/x-www-form-urlencoded" } 1591 }; 1592 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1593 optionalAttributes.Add("method", settings.Method.ToString()); 1594 1595 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1596 { 1597 @settings.FormStartMarkup 1598 } 1599 else 1600 { 1601 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1602 } 1603 1604 foreach (var field in settings.GetFields()) 1605 { 1606 @Render(field) 1607 } 1608 1609 @:</form> 1610 } 1611 } 1612 @using System.Reflection 1613 @using Dynamicweb.Rapido.Blocks.Components.General 1614 @using Dynamicweb.Rapido.Blocks.Components 1615 1616 1617 @* Component *@ 1618 1619 @helper RenderText(Text settings) 1620 { 1621 @settings.Content 1622 } 1623 @using System.Reflection 1624 @using Dynamicweb.Rapido.Blocks.Components.General 1625 @using Dynamicweb.Rapido.Blocks.Components 1626 1627 1628 @* Component *@ 1629 1630 @helper RenderContentModule(ContentModule settings) { 1631 if (!string.IsNullOrEmpty(settings.Content)) 1632 { 1633 @settings.Content 1634 } 1635 } 1636 @using System.Reflection 1637 @using Dynamicweb.Rapido.Blocks.Components.General 1638 @using Dynamicweb.Rapido.Blocks.Components 1639 1640 1641 @* Component *@ 1642 1643 @helper RenderModal(Modal settings) { 1644 if (settings != null) 1645 { 1646 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1647 1648 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1649 1650 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1651 1652 <div class="modal-container"> 1653 @if (!settings.DisableDarkOverlay) 1654 { 1655 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1656 } 1657 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1658 @if (settings.Heading != null) 1659 { 1660 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1661 { 1662 <div class="modal__header"> 1663 @Render(settings.Heading) 1664 </div> 1665 } 1666 } 1667 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1668 @if (!string.IsNullOrEmpty(settings.BodyText)) 1669 { 1670 @settings.BodyText 1671 } 1672 @if (settings.BodyTemplate != null) 1673 { 1674 @settings.BodyTemplate 1675 } 1676 @{ 1677 var actions = settings.GetActions(); 1678 } 1679 </div> 1680 @if (actions.Length > 0) 1681 { 1682 <div class="modal__footer"> 1683 @foreach (var action in actions) 1684 { 1685 if (Pageview.Device.ToString() != "Mobile") { 1686 action.CssClass += " u-no-margin"; 1687 } else { 1688 action.CssClass += " u-full-width u-margin-bottom"; 1689 } 1690 1691 @Render(action) 1692 } 1693 </div> 1694 } 1695 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1696 </div> 1697 </div> 1698 } 1699 } 1700 @using Dynamicweb.Rapido.Blocks.Components.General 1701 1702 @* Component *@ 1703 1704 @helper RenderMediaListItem(MediaListItem settings) 1705 { 1706 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1707 @if (!string.IsNullOrEmpty(settings.Label)) 1708 { 1709 if (!string.IsNullOrEmpty(settings.Link)) 1710 { 1711 @Render(new Link 1712 { 1713 Href = settings.Link, 1714 CssClass = "media-list-item__sticker dw-mod", 1715 ButtonLayout = ButtonLayout.None, 1716 Title = settings.Label, 1717 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1718 }) 1719 } 1720 else if (!string.IsNullOrEmpty(settings.OnClick)) 1721 { 1722 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1723 <span class="u-uppercase">@settings.Label</span> 1724 </span> 1725 } 1726 else 1727 { 1728 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1729 <span class="u-uppercase">@settings.Label</span> 1730 </span> 1731 } 1732 } 1733 <div class="media-list-item__wrap"> 1734 <div class="media-list-item__info dw-mod"> 1735 <div class="media-list-item__header dw-mod"> 1736 @if (!string.IsNullOrEmpty(settings.Title)) 1737 { 1738 if (!string.IsNullOrEmpty(settings.Link)) 1739 { 1740 @Render(new Link 1741 { 1742 Href = settings.Link, 1743 CssClass = "media-list-item__name dw-mod", 1744 ButtonLayout = ButtonLayout.None, 1745 Title = settings.Title, 1746 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1747 }) 1748 } 1749 else if (!string.IsNullOrEmpty(settings.OnClick)) 1750 { 1751 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1752 } 1753 else 1754 { 1755 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1756 } 1757 } 1758 1759 @if (!string.IsNullOrEmpty(settings.Status)) 1760 { 1761 <div class="media-list-item__state dw-mod">@settings.Status</div> 1762 } 1763 </div> 1764 @{ 1765 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1766 } 1767 1768 @Render(settings.InfoTable) 1769 </div> 1770 <div class="media-list-item__actions dw-mod"> 1771 <div class="media-list-item__actions-list dw-mod"> 1772 @{ 1773 var actions = settings.GetActions(); 1774 1775 foreach (ButtonBase action in actions) 1776 { 1777 action.ButtonLayout = ButtonLayout.None; 1778 action.CssClass += " media-list-item__action link"; 1779 1780 @Render(action) 1781 } 1782 } 1783 </div> 1784 1785 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1786 { 1787 settings.SelectButton.CssClass += " u-no-margin"; 1788 1789 <div class="media-list-item__action-button"> 1790 @Render(settings.SelectButton) 1791 </div> 1792 } 1793 </div> 1794 </div> 1795 </div> 1796 } 1797 @using Dynamicweb.Rapido.Blocks.Components.General 1798 @using Dynamicweb.Rapido.Blocks.Components 1799 1800 @helper RenderTable(Table settings) 1801 { 1802 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1803 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1804 1805 var enumToClasses = new Dictionary<TableDesign, string> 1806 { 1807 { TableDesign.Clean, "table--clean" }, 1808 { TableDesign.Bordered, "table--bordered" }, 1809 { TableDesign.Striped, "table--striped" }, 1810 { TableDesign.Hover, "table--hover" }, 1811 { TableDesign.Compact, "table--compact" }, 1812 { TableDesign.Condensed, "table--condensed" }, 1813 { TableDesign.NoTopBorder, "table--no-top-border" } 1814 }; 1815 string tableDesignClass = ""; 1816 if (settings.Design != TableDesign.None) 1817 { 1818 tableDesignClass = enumToClasses[settings.Design]; 1819 } 1820 1821 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1822 1823 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1824 1825 <table @ComponentMethods.AddAttributes(resultAttributes)> 1826 @if (settings.Header != null) 1827 { 1828 <thead> 1829 @Render(settings.Header) 1830 </thead> 1831 } 1832 <tbody> 1833 @foreach (var row in settings.Rows) 1834 { 1835 @Render(row) 1836 } 1837 </tbody> 1838 @if (settings.Footer != null) 1839 { 1840 <tfoot> 1841 @Render(settings.Footer) 1842 </tfoot> 1843 } 1844 </table> 1845 } 1846 @using Dynamicweb.Rapido.Blocks.Components.General 1847 @using Dynamicweb.Rapido.Blocks.Components 1848 1849 @helper RenderTableRow(TableRow settings) 1850 { 1851 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1852 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1853 1854 var enumToClasses = new Dictionary<TableRowDesign, string> 1855 { 1856 { TableRowDesign.NoBorder, "table__row--no-border" }, 1857 { TableRowDesign.Border, "table__row--border" }, 1858 { TableRowDesign.TopBorder, "table__row--top-line" }, 1859 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1860 { TableRowDesign.Solid, "table__row--solid" } 1861 }; 1862 1863 string tableRowDesignClass = ""; 1864 if (settings.Design != TableRowDesign.None) 1865 { 1866 tableRowDesignClass = enumToClasses[settings.Design]; 1867 } 1868 1869 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1870 1871 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1872 1873 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1874 @foreach (var cell in settings.Cells) 1875 { 1876 if (settings.IsHeaderRow) 1877 { 1878 cell.IsHeader = true; 1879 } 1880 @Render(cell) 1881 } 1882 </tr> 1883 } 1884 @using Dynamicweb.Rapido.Blocks.Components.General 1885 @using Dynamicweb.Rapido.Blocks.Components 1886 @using Dynamicweb.Core 1887 1888 @helper RenderTableCell(TableCell settings) 1889 { 1890 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1891 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1892 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1893 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1894 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1895 1896 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1897 1898 string tagName = settings.IsHeader ? "th" : "td"; 1899 1900 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 1901 @settings.Content 1902 @("</" + tagName + ">"); 1903 } 1904 @using System.Linq 1905 @using Dynamicweb.Rapido.Blocks.Components.General 1906 1907 @* Component *@ 1908 1909 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1910 { 1911 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1912 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1913 1914 if (settings.NumberOfPages > 1) 1915 { 1916 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1917 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1918 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1919 1920 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1921 @if (settings.ShowPagingInfo) 1922 { 1923 <div class="pager__info dw-mod"> 1924 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1925 </div> 1926 } 1927 <ul class="pager__list dw-mod"> 1928 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1929 { 1930 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1931 } 1932 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1933 { 1934 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1935 } 1936 @if (settings.GetPages().Any()) 1937 { 1938 foreach (var page in settings.GetPages()) 1939 { 1940 @Render(page) 1941 } 1942 } 1943 else 1944 { 1945 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1946 { 1947 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1948 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1949 } 1950 } 1951 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1952 { 1953 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1954 } 1955 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1956 { 1957 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1958 } 1959 </ul> 1960 </div> 1961 } 1962 } 1963 1964 @helper RenderPaginationItem(PaginationItem settings) 1965 { 1966 if (settings.Icon == null) 1967 { 1968 settings.Icon = new Icon(); 1969 } 1970 1971 settings.Icon.Label = settings.Label; 1972 <li class="pager__btn dw-mod"> 1973 @if (settings.IsActive) 1974 { 1975 <span class="pager__num pager__num--current dw-mod"> 1976 @Render(settings.Icon) 1977 </span> 1978 } 1979 else 1980 { 1981 <a href="@settings.Link" class="pager__num dw-mod"> 1982 @Render(settings.Icon) 1983 </a> 1984 } 1985 </li> 1986 } 1987 1988 1989 @using Dynamicweb.Rapido.Blocks.Components.General 1990 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1991 1992 1993 @using System.Text.RegularExpressions 1994 @using System.Collections.Generic 1995 @using System.Reflection 1996 @using System.Web 1997 @using System.Web.UI.HtmlControls 1998 @using Dynamicweb.Rapido.Blocks.Components 1999 @using Dynamicweb.Rapido.Blocks.Components.Articles 2000 @using Dynamicweb.Rapido.Blocks.Components.Documentation 2001 @using Dynamicweb.Rapido.Blocks 2002 2003 2004 @*--- START: Base block renderers ---*@ 2005 2006 @helper RenderBlockList(List<Block> blocks) 2007 { 2008 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 2009 blocks = blocks.OrderBy(item => item.SortId).ToList(); 2010 2011 foreach (Block item in blocks) 2012 { 2013 if (debug) { 2014 <!-- Block START: @item.Id --> 2015 } 2016 2017 if (item.Design == null) 2018 { 2019 @RenderBlock(item) 2020 } 2021 else if (item.Design.RenderType == RenderType.None) { 2022 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 2023 2024 <div class="@cssClass dw-mod"> 2025 @RenderBlock(item) 2026 </div> 2027 } 2028 else if (item.Design.RenderType != RenderType.Hide) 2029 { 2030 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 2031 2032 if (!item.SkipRenderBlocksList) { 2033 if (item.Design.RenderType == RenderType.Row) 2034 { 2035 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 2036 @RenderBlock(item) 2037 </div> 2038 } 2039 2040 if (item.Design.RenderType == RenderType.Column) 2041 { 2042 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 2043 string size = item.Design.Size ?? "12"; 2044 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 2045 2046 <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"> 2047 @RenderBlock(item) 2048 </div> 2049 } 2050 2051 if (item.Design.RenderType == RenderType.Table) 2052 { 2053 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 2054 @RenderBlock(item) 2055 </table> 2056 } 2057 2058 if (item.Design.RenderType == RenderType.TableRow) 2059 { 2060 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 2061 @RenderBlock(item) 2062 </tr> 2063 } 2064 2065 if (item.Design.RenderType == RenderType.TableColumn) 2066 { 2067 <td class="@cssClass dw-mod" id="Block__@item.Id"> 2068 @RenderBlock(item) 2069 </td> 2070 } 2071 2072 if (item.Design.RenderType == RenderType.CardHeader) 2073 { 2074 <div class="card-header @cssClass dw-mod"> 2075 @RenderBlock(item) 2076 </div> 2077 } 2078 2079 if (item.Design.RenderType == RenderType.CardBody) 2080 { 2081 <div class="card @cssClass dw-mod"> 2082 @RenderBlock(item) 2083 </div> 2084 } 2085 2086 if (item.Design.RenderType == RenderType.CardFooter) 2087 { 2088 <div class="card-footer @cssClass dw-mod"> 2089 @RenderBlock(item) 2090 </div> 2091 } 2092 } 2093 else 2094 { 2095 @RenderBlock(item) 2096 } 2097 } 2098 2099 if (debug) { 2100 <!-- Block END: @item.Id --> 2101 } 2102 } 2103 } 2104 2105 @helper RenderBlock(Block item) 2106 { 2107 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 2108 2109 if (item.Template != null) 2110 { 2111 @BlocksPage.RenderTemplate(item.Template) 2112 } 2113 2114 if (item.Component != null) 2115 { 2116 string customSufix = "Custom"; 2117 string methodName = item.Component.HelperName; 2118 2119 ComponentBase[] methodParameters = new ComponentBase[1]; 2120 methodParameters[0] = item.Component; 2121 Type methodType = this.GetType(); 2122 2123 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 2124 MethodInfo generalMethod = methodType.GetMethod(methodName); 2125 2126 try { 2127 if (debug) { 2128 <!-- Component: @methodName.Replace("Render", "") --> 2129 } 2130 @customMethod.Invoke(this, methodParameters).ToString(); 2131 } catch { 2132 try { 2133 @generalMethod.Invoke(this, methodParameters).ToString(); 2134 } catch(Exception ex) { 2135 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 2136 } 2137 } 2138 } 2139 2140 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 2141 { 2142 @RenderBlockList(item.BlocksList) 2143 } 2144 } 2145 2146 @*--- END: Base block renderers ---*@ 2147 2148 2149 @functions{ 2150 Dictionary<string, StickersListPosition> stickerPositions = new Dictionary<string, StickersListPosition> 2151 { 2152 { "top-left", StickersListPosition.TopLeft }, 2153 { "top-right", StickersListPosition.TopRight }, 2154 { "bottom-left", StickersListPosition.BottomLeft }, 2155 { "bottom-right", StickersListPosition.BottomRight } 2156 }; 2157 2158 public void AddSticker(List<StickersCollection> list, Sticker sticker, StickersListPosition stickerPosition) 2159 { 2160 StickersCollection stickersContainerTemp = list.FirstOrDefault(stickersContainer => stickersContainer.Position == stickerPosition); 2161 if (stickersContainerTemp == null) 2162 { 2163 stickersContainerTemp = new StickersCollection() 2164 { 2165 Position = stickerPosition, 2166 Stickers = new List<Sticker>() 2167 }; 2168 list.Add(stickersContainerTemp); 2169 } 2170 stickersContainerTemp.Stickers.Add(sticker); 2171 } 2172 2173 public List<StickersCollection> GetStickersContainersList(string customStickerValue, string productInfoStickerValue) 2174 { 2175 bool pointShopOnly = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2176 bool isCustomStickersEnabled = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("CustomSticker").GetBoolean("Enable"); 2177 bool isSoldOutStickerEnabled = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("SoldOutSticker").GetBoolean("Enable"); 2178 bool isComingSoonStickerEnabled = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("ComingSoonSticker").GetBoolean("Enable"); 2179 2180 List<StickersCollection> resultList = new List<StickersCollection>(); 2181 2182 if (!pointShopOnly && isCustomStickersEnabled && !string.IsNullOrEmpty(customStickerValue)) 2183 { 2184 Sticker customSticker = new Sticker(); 2185 customSticker.CssClass = "stickers-container__tag--custom"; 2186 customSticker.Title = customStickerValue; 2187 2188 StickersListPosition customStickerPosition = StickersListPosition.TopLeft; 2189 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("CustomSticker").GetList("Position") != null) 2190 { 2191 string value = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("CustomSticker").GetList("Position").SelectedValue; 2192 customStickerPosition = stickerPositions.ContainsKey(value) ? stickerPositions[value] : stickerPositions["top-left"]; 2193 } 2194 if (!string.IsNullOrEmpty(customSticker.Title)) 2195 { 2196 AddSticker(resultList, customSticker, customStickerPosition); 2197 } 2198 } 2199 2200 if (!pointShopOnly && isSoldOutStickerEnabled && productInfoStickerValue?.ToLower() == "soldoutsticker") 2201 { 2202 Sticker soldOutSticker = new Sticker(); 2203 soldOutSticker.CssClass = "stickers-container__tag--soldout"; 2204 soldOutSticker.Title = Translate("Smartpage:Sticker.SoldOut", "Udsolgt"); 2205 2206 StickersListPosition soldOutStickerPosition = StickersListPosition.TopLeft; 2207 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("SoldOutSticker").GetList("Position") != null) 2208 { 2209 string value = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("SoldOutSticker").GetList("Position").SelectedValue; 2210 soldOutStickerPosition = stickerPositions.ContainsKey(value) ? stickerPositions[value] : stickerPositions["top-left"]; 2211 } 2212 if (!string.IsNullOrEmpty(soldOutSticker.Title)) 2213 { 2214 AddSticker(resultList, soldOutSticker, soldOutStickerPosition); 2215 } 2216 } 2217 else if (!pointShopOnly && isComingSoonStickerEnabled && productInfoStickerValue?.ToLower() == "comingsoonsticker") 2218 { 2219 Sticker comingSoonSticker = new Sticker(); 2220 comingSoonSticker.CssClass = "stickers-container__tag--comingsoon"; 2221 comingSoonSticker.Title = Translate("Smartpage:Sticker.ComingSoon", "Kommer snart"); 2222 2223 StickersListPosition comingSoonStickerPosition = StickersListPosition.TopLeft; 2224 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("ComingSoonSticker").GetList("Position") != null) 2225 { 2226 string value = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("ComingSoonSticker").GetList("Position").SelectedValue; 2227 comingSoonStickerPosition = stickerPositions.ContainsKey(value) ? stickerPositions[value] : stickerPositions["top-left"]; 2228 } 2229 if (!string.IsNullOrEmpty(comingSoonSticker.Title)) 2230 { 2231 AddSticker(resultList, comingSoonSticker, comingSoonStickerPosition); 2232 } 2233 } 2234 2235 return resultList; 2236 } 2237 } 2238 2239 @functions { 2240 private ProductFieldValue GetProductFieldValueFromReorderItem(ReorderItem item, string field) 2241 { 2242 return Dynamicweb.Ecommerce.Services.Products.GetProductByNumber( 2243 item.ProductNo.ToString(), true)?.ProductFieldValues?.GetProductFieldValue(field); 2244 } 2245 } 2246 @{ 2247 Dynamicweb.Ecommerce.International.CurrencyService currencyService = new Dynamicweb.Ecommerce.International.CurrencyService(); 2248 var currentUser = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser(); 2249 var currency = currencyService.GetCurrency(currentUser.Currency); 2250 var cartPageId = GetPageIdByNavigationTag("MiniCartFeed"); 2251 var ajaxReorderPricesId = GetPageIdByNavigationTag("ajaxreorderprices"); 2252 2253 if (currency == null) 2254 { 2255 currency = currencyService.GetDefaultCurrency(); 2256 } 2257 2258 List<Smartpage.Frellsen.Reorder.Models.ReorderItem> productList = new List<Smartpage.Frellsen.Reorder.Models.ReorderItem>(); 2259 2260 foreach (var product in Model.Products) 2261 { 2262 var reorderInfo = Smartpage.Frellsen.Reorder.Repositories.ReorderService.GetCustomerProduct(currentUser?.CustomerNumber, product.Id); 2263 productList.Add(reorderInfo); 2264 } 2265 2266 var groupedList = productList 2267 .OrderByDescending(item => GetProductFieldValueFromReorderItem(item, "SpProductSorting")?.Value?.ToString() ?? "0") 2268 .ThenByDescending(item => GetProductFieldValueFromReorderItem(item, "SpProductPriceGroup1")?.Value?.ToString() ?? "0") 2269 .ThenByDescending(item => GetProductFieldValueFromReorderItem(item, "SpProductPriceGroup2")?.Value?.ToString() ?? "0") 2270 .ThenByDescending(item => GetProductFieldValueFromReorderItem(item, "SpProductPriceGroup3")?.Value?.ToString() ?? "0") 2271 .GroupBy(u => u.MainProductCategory) 2272 .OrderBy(item => item.First().MainProductCategoryNo) 2273 .Select(grp => grp.ToList()) 2274 .ToList(); 2275 2276 } 2277 2278 <div class="custom-box-wrap dashboard-reorderlist js-box" data-ajaxpricesurl="Default.aspx?ID=@ajaxReorderPricesId&redirect=false"> 2279 <div> 2280 <h2 class="u-margin-bottom-5px dw-mod"> 2281 @Translate("Genkøbsliste") 2282 <span class="reorder-mobile-buttons"> 2283 <button onclick="orderChecked(event)" data-cartid="@cartPageId" class="btn btn--primary dw-mod btn--sm u-margin-left u-pull--right js-order-checked-button reorder-mobile-button" type="button">@Translate("Bestil markerede")</button> 2284 <button onclick="checkAllInputs(event)" class="btn btn--primary dw-mod btn--sm u-margin-left js-check-all-groups u-pull--right reorder-mobile-button" type="button" data-checked="@HttpUtility.HtmlAttributeEncode(Translate("Vælg alle"))" data-unchecked="@HttpUtility.HtmlAttributeEncode(Translate("Fravælg alle"))">@Translate("Vælg alle")</button> 2285 <button onclick="toggleAllGroups()" class="btn btn--primary dw-mod btn--sm u-margin-left js-open-all-groups u-pull--right fold-all-btn reorder-mobile-button" type="button" data-open="@HttpUtility.HtmlAttributeEncode(Translate("Fold alle lister ud"))" data-close="@HttpUtility.HtmlAttributeEncode(Translate("Luk alle lister"))">@Translate("Fold alle lister ud")</button> 2286 </span> 2287 </h2> 2288 </div> 2289 2290 <div class="custom-boxlist-wrap"> 2291 @foreach (var group in groupedList) 2292 { 2293 <div class="boxline-group"> 2294 <h3 onclick="toggleGroup(event)" class="custom-line-headline js-group-headline">@group.First().MainProductCategory <i class="u-pull--right fas fa-plus-square u-font-size--lg group-icon js-toggle-box-group" data-minus="fa-minus-square" data-plus="fa-plus-square"></i></h3> 2295 2296 @foreach (var reorderInfo in group) 2297 { 2298 var product = Model.Products.Single(x => x.Number == Converter.ToString(reorderInfo.ProductNo)); 2299 //var pricePrKg = 0.0; 2300 //var priceUnit = 0; 2301 //var price = product.Price; // Activate dynamicweb to lazy load prices to have productInfo loaded in liveintegration (viewmodel) 2302 //var apiProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(reorderInfo.ProductNo.ToString(), "", Dynamicweb.Ecommerce.Common.Context.LanguageID); 2303 //if (apiProduct != null) 2304 //{ 2305 // var productInfo = Dynamicweb.Ecommerce.LiveIntegration.Products.ProductManager.GetProductInfo(apiProduct); 2306 // if (productInfo != null) 2307 // { 2308 // pricePrKg = Converter.ToDouble(productInfo["SpPricePrKg"]); 2309 // priceUnit = Converter.ToInt32(productInfo["SpPriceUnit"]); 2310 // } 2311 //} 2312 2313 2314 var productTrackingInfo = "{'link':'','image':'%2fImages%2fmissing_image.jpg','name':'" + HttpUtility.JavaScriptStringEncode(reorderInfo.Description) + "','variantName':'','unitName':'','googleImpression':null}"; 2315 DateTime lastOrderingDate = DateTime.ParseExact(reorderInfo.LastOrderingDate, "yyyyMMdd", CultureInfo.InvariantCulture); 2316 2317 var mainProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(reorderInfo.ProductNo.ToString(), "", Dynamicweb.Ecommerce.Common.Context.LanguageID, false); 2318 var productInfoSticker = mainProduct?.ProductFieldValues?.GetProductFieldValue("ProductInfoSticker")?.Value?.ToString(); 2319 2320 var stickerCollections = GetStickersContainersList( 2321 mainProduct?.ProductFieldValues?.GetProductFieldValue("CustomSticker")?.Value?.ToString(), 2322 productInfoSticker 2323 ); 2324 2325 <div class="custom-all-product-wrap js-box-group"> 2326 <div class="custom-product-wrap"> 2327 <div class="image-wrap u-position-relative"> 2328 <img src="/Admin/Public/GetImage.ashx?width=120&amp;crop=0&amp;Compression=75&amp;image=@product.DefaultImage.Value" alt="@HttpUtility.HtmlAttributeEncode(product.Name)" /> 2329 @foreach (var stickerCollection in stickerCollections) 2330 { 2331 @RenderStickersCollection(stickerCollection); 2332 } 2333 </div> 2334 <div class="info"> 2335 <div class="info--headline"> 2336 <a class="u-bold u-margin-bottom" href="/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")&ProductID=@product.Id">@product.Name</a> 2337 <div class="box-price js-box-price" data-productid="@reorderInfo.ProductNo"> 2338 @*<p class="u-bold u-margin-bottom">@product.Price.PriceFormatted</p> 2339 @if (priceUnit == 5) 2340 { 2341 <small class="u-no-margin u-color-font-black">@Translate("Pris pr. kg"):<strong> @currencyService.FormatCurrency(currency, pricePrKg, true)</strong></small> 2342 }*@ 2343 <div class="loading-prices">@Translate("Henter priser")<span class="loader-dot-one">.</span><span class="loader-dot-two">.</span><span class="loader-dot-three">.</span></div> 2344 </div> 2345 </div> 2346 2347 <p class="u-no-margin">@Translate("Nettovægt"): @product.Weight @Translate("kg.")</p> 2348 2349 <p class="u-no-margin">@Translate("Varenr").: @reorderInfo.ProductNo</p> 2350 <div class="last-order-info"> 2351 <div class="title"> 2352 <strong>@Translate("Sidste køb")</strong> 2353 </div> 2354 <div class="date"> 2355 @Translate("Dato"): <strong>@lastOrderingDate.ToString("dd-MM-yyyy")</strong> 2356 </div> 2357 <div> 2358 @Translate("Antal"): <strong>@reorderInfo.QuantityOrderLastTime</strong> 2359 </div> 2360 <div> 2361 @Translate("Pris"): <strong>@currencyService.FormatCurrency(currency, reorderInfo.UnitPrice, true)</strong> 2362 </div> 2363 </div> 2364 2365 @* hideBuyButton logic *@ 2366 @if (!string.IsNullOrWhiteSpace(productInfoSticker)) 2367 { 2368 <div class="u-ta-center"> 2369 <div class="buttons-collection buttons-collection--center dw-mod"> 2370 <a href="/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")&ProductID=@product.Id" 2371 class="btn btn--primary u-no-margin dw-mod" 2372 title="@HttpUtility.HtmlAttributeEncode(Translate("Vis"))">@Translate("Vis")</a> 2373 </div> 2374 </div> 2375 } 2376 else 2377 { 2378 <div class="buttons-collection buttons-collection--center js-check-parent"> 2379 <input class="js-input" type="hidden" name="ProductLoopCounter@(reorderInfo.ProductNo)" id="ProductLoopCounter@(reorderInfo.ProductNo)" value="@reorderInfo.ProductNo" disabled /> 2380 <input class="js-input" type="hidden" name="ProductID@(reorderInfo.ProductNo)" id="ProductID@(reorderInfo.ProductNo)" value="@reorderInfo.ProductNo" disabled /> 2381 <input class="js-input js-quantity dw-mod" id="Quantity@(reorderInfo.ProductNo)" name="Quantity@(reorderInfo.ProductNo)" min="1" value="@reorderInfo.QuantityOrderLastTime" type="number"> 2382 2383 <button class=" btn--condensed btn btn--primary dw-mod" onclick="Cart.AddToCart(event, { id: '@reorderInfo.ProductNo',variantId: '',unitId: '',productInfo: @productTrackingInfo ,quantity: parseFloat(document.getElementById('Quantity'+@reorderInfo.ProductNo).value)});" type="button"> 2384 <i class="fal fa-shopping-bag u-flex--align-center"></i> 2385 @Translate("Bestil") 2386 </button> 2387 <input type="checkbox" data-productid="@reorderInfo.ProductNo" id="Checked@(reorderInfo.ProductNo)" name="Checked@(reorderInfo.ProductNo)" class="js-reorder-checkbox dw-mod" /> 2388 </div> 2389 } 2390 </div> 2391 </div> 2392 </div> 2393 } 2394 </div> 2395 } 2396 </div> 2397 </div> 2398 2399