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