Error executing template "Designs/Rapido/ContentPage/Paragraph/Job.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_f3443991745e47eba979618a337160d6.Execute() in D:\dynamicweb.net\Solutions\danishagro-various.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\ContentPage\Paragraph\Job.cshtml:line 52
   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 3 @using System.Web 4 @using DanishagroBrandingMaster.JobsApi 5 @using Dynamicweb.Rapido.Blocks.Components.General 6 @using HtmlAgilityPack 7 @using Dynamicweb.Frontend.Devices 8 9 10 @functions 11 { 12 dynamic GetEnumSetting(dynamic enumSetting, string name = null) 13 { 14 string enumName = name == null ? enumSetting.GetType().Name : name; 15 enumSetting = HttpContext.Current.Request.QueryString.Get(enumName) != null ? System.Enum.Parse(enumSetting.GetType(), HttpContext.Current.Request.QueryString.Get(enumName)) : enumSetting; 16 return enumSetting; 17 } 18 19 string jobUrl = string.Empty; 20 string address = ""; 21 Dynamicweb.Content.ParagraphService paragraphService = new Dynamicweb.Content.ParagraphService(); 22 bool isMobileOrTablet; 23 string colorSetting; 24 25 } 26 27 @{ 28 isMobileOrTablet = Pageview.Device == DeviceType.Mobile || Pageview.Device == DeviceType.Tablet; 29 int jobId; 30 DanishagroBrandingMaster.JobsApi.Content contentList; 31 colorSetting = Pageview.AreaSettings?.GetItem("Layout")?.GetString("DropdownActiveColor") ?? ""; //Tag DropdownActiveColor fra layout 32 colorSetting = colorSetting != "" ? colorSetting : "#849938"; 33 34 HttpContext context = HttpContext.Current; 35 var customerAlias = Model.Item.GetString("CustomerAliasJob"); 36 jobUrl = "/Default.aspx?ID=" + GetPageIdByNavigationTag("InactiveJobRedirect"); 37 38 if (context.Session["JobId"] == null || context.Session["Positions"] == null) 39 { 40 jobId = Convert.ToInt32(context.Request.QueryString["jobId"]); ; 41 42 IService service = new Service(); 43 contentList = service.CreateObject(customerAlias); 44 } 45 else 46 { 47 jobId = (int)(context.Session["jobId"]); 48 contentList = (DanishagroBrandingMaster.JobsApi.Content)(context.Session["Positions"]); 49 } 50 51 52 Item3 item = contentList.PositionList.Items.FirstOrDefault(x => x.Id == jobId); 53 if (item != null) 54 { 55 Users users = item.Users; 56 57 IService service = new Service(); 58 string advertisementUrl = service.GetAdvertisementUrl(item.AdvertisementUrl); 59 60 HtmlDocument doc = new HtmlDocument(); 61 doc.LoadHtml(advertisementUrl); 62 63 advertisementUrl = doc.GetElementbyId("AdvertisementInnerContent").OuterHtml; 64 address = service.GetAddressByCoordinates(item.WorkPlaceCoordinates); 65 66 @RenderJobPage(advertisementUrl, item, users, contentList, context); 67 } 68 else 69 { 70 @Render404() 71 } 72 } 73 74 @helper RenderJobPage(string advertisementUrl, Item3 item, Users users, DanishagroBrandingMaster.JobsApi.Content contentList, HttpContext context) 75 { 76 var advertisementImage = item.Advertisements?.FirstOrDefault()?.ImageUrlSecure; 77 if (!string.IsNullOrEmpty(advertisementImage)) 78 { 79 if (isMobileOrTablet) 80 { 81 <div class="background-image-container-job"> 82 <img class="" src="@advertisementImage"> 83 </div> 84 } 85 else 86 { 87 <div></div> 88 <div class="image-cover-job" style="background-image: url(@advertisementImage);"></div> 89 90 } 91 } 92 93 <div class="grid content-row--spacing-xl"> 94 <div class="grid__col-lg-8 content-text"> 95 <header> 96 <h1> 97 @item.Name 98 </h1> 99 </header> 100 @advertisementUrl 101 </div> 102 <div class="grid__col-lg-4 padding-none" style="margin-top: 15px;"> 103 <div class="content-row__item rowItemContent-12903 dw-mod u-flex--column"> 104 105 <div class="u-full-width u-align-left u-align-self-start dw-mod content--background-and-color" style="background-color:@colorSetting;" id="jobInformationBox"> 106 <div class="u-full-height"> 107 <div class="content-row__item__body padding-size-md padding-position-around dw-mod"> 108 <div class="u-margin-bottom--md"> 109 @{ 110 var headline = Model.Item.GetString("JobinfoBox_Headline"); 111 if (string.IsNullOrEmpty(headline)) 112 { 113 headline = "Job info"; 114 } 115 <h3 class="u-margin-bottom--md-custom" style="color:white">@headline</h3> 116 } 117 118 @if (!string.IsNullOrWhiteSpace(address)) 119 { 120 <p> 121 <strong>@Translate("Workplace")</strong><br> 122 @{ 123 string mapsUrl = "https://www.google.com/maps/place/" + address; 124 var city = item.Department?.City ?? Translate("Ingen by fundet"); 125 @item.Department.Name 126 <br /> 127 @address <br /> 128 <a style="color:white;text-decoration:underline" href="@mapsUrl" target="_blank">@Translate("View map location") </a> 129 } 130 </p> 131 } 132 133 134 <p> 135 <strong>@Translate("Application due")</strong><br> 136 @if (item.ApplicationDue != DateTime.MinValue) 137 { 138 @item.ApplicationDue.ToShortDateString() 139 } 140 else 141 { 142 @Translate("As soon as possible") 143 } 144 </p> 145 <p> 146 @if (item.StartDate != DateTime.MinValue && !item.StartDateASAP) 147 { 148 <strong>@Translate("Start date")</strong><br> 149 @item.StartDate.ToShortDateString() 150 } 151 else 152 { 153 <strong>@Translate("Start date")</strong><br> 154 @Translate("As soon as possible") 155 } 156 </p> 157 158 @{ 159 ButtonLayout ButtonLayoutJobAgent; 160 try 161 { 162 ButtonLayoutJobAgent = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(Model.Item.GetItem("Apply_Job_Button").GetList("Layout").SelectedValue[0]) + Model.Item.GetItem("Apply_Job_Button").GetList("Layout").SelectedValue.Substring(1)); 163 } 164 catch 165 { 166 ButtonLayoutJobAgent = ButtonLayout.Tertiary; 167 } 168 169 170 string ButtonTitleJobAgent = Model?.Item?.GetItem("Apply_Job_Button")?.GetString("Title") ?? Translate("JobAgentTitle"); 171 var applyJobButton = new Button 172 { 173 Id = "ApplyJob", 174 ButtonLayout = GetEnumSetting(ButtonLayoutJobAgent), 175 Title = ButtonTitleJobAgent, 176 CssClass = "u-margin-bottom--lg-custom", 177 //Icon = new Icon { Prefix = "fas", Name = "fa-plus", LabelPosition = IconLabelPosition.After }, 178 OnClick = $"window.location.href='{item.ApplicationFormUrl}';", 179 }; 180 if ((Model?.Item?.GetItem("Apply_Job_Button")?.GetBoolean("OpenInNewTab") ?? false) == true) 181 { 182 applyJobButton.OnClick = $"window.open('{item.ApplicationFormUrl}','_blank')"; 183 } 184 185 186 @Render(applyJobButton) 187 } 188 </div> 189 190 <div> 191 @{ 192 object ogImagePath = new object(); 193 var ogImageExists = Pageview.Page.PropertyItem.TryGetValue("OpenGraphImage", out ogImagePath); 194 HtmlDocument doc = new HtmlDocument(); 195 doc.LoadHtml(advertisementUrl); 196 var description = doc.DocumentNode.SelectSingleNode(".//p").InnerText; 197 } 198 @RenderSocialMediaShareIcons(new DanishagroBrandingMaster.Files.Files.Templates.Designs.Rapido.Components.Custom.SocialMediaShareIcon(Pageview) 199 { 200 EnableFacebook = Pageview.AreaSettings.GetItem("Danish_Agro_Branding").GetBoolean("Enable_Facebook"), 201 EnableTwitter = Pageview.AreaSettings.GetItem("Danish_Agro_Branding").GetBoolean("Enable_Twitter"), 202 EnableLinkedin = Pageview.AreaSettings.GetItem("Danish_Agro_Branding").GetBoolean("Enable_Linkedin"), 203 EnableMail = Pageview.AreaSettings.GetItem("Danish_Agro_Branding").GetBoolean("Enable_Mail"), 204 MetaTitle = Pageview.Page.MetaTitle, 205 OpengraphImage = !string.IsNullOrEmpty(advertisementImage) ? advertisementImage : ogImagePath.ToString(), 206 isExternal = !string.IsNullOrEmpty(advertisementImage) ? true : false, 207 OpengraphTitle = item.Name, 208 OpengraphDescription = description 209 }) 210 </div> 211 </div> 212 </div> 213 </div> 214 215 <div class="u-full-width u-align-left u-align-self-start dw-mod content--background-and-color" style="background-color: #B1B1B1; margin-top: 47px;" id="jobInformationBox"> 216 <div class="u-full-height"> 217 <div class="content-row__item__body padding-size-md padding-position-around dw-mod"> 218 <div class=""> 219 <div class="buttons-collection flex-start u-block dw-mod u-flex grid--direction-column"> 220 @{var jobagentBoxTitle = Model.Item.GetString("Headline"); 221 var jobagentBoxText = Model.Item.GetString("JobagentText"); 222 } 223 <h3 style="color: white; @(isMobileOrTablet? "margin-bottom: 0px;" : "")" class="">@jobagentBoxTitle</h3> 224 <div style="color: white;" class=""> 225 @jobagentBoxText 226 </div> 227 @{ 228 ButtonLayout ButtonLayoutApplyJob; 229 try 230 { 231 ButtonLayoutApplyJob = (ButtonLayout)System.Enum.Parse(typeof(ButtonLayout), char.ToUpper(Model.Item.GetItem("Job_Agent_Button").GetList("Layout").SelectedValue[0]) + Model.Item.GetItem("Job_Agent_Button").GetList("Layout").SelectedValue.Substring(1)); 232 } 233 catch 234 { 235 ButtonLayoutApplyJob = ButtonLayout.Tertiary; 236 } 237 238 string ButtonTitleApplyJob = Model?.Item?.GetItem("Job_Agent_Button")?.GetString("Title") ?? Translate("JobagentButtonTitle"); 239 var jobButton = new Button 240 { 241 Id = "JobAgent", 242 ButtonLayout = GetEnumSetting(ButtonLayoutApplyJob), 243 Title = ButtonTitleApplyJob, 244 OnClick = $"window.location.href='https://candidate.hr-manager.net/Agent/Subscription.aspx?customer={contentList.CustomerAlias}';" 245 }; 246 if ((Model?.Item?.GetItem("Job_Agent_Button")?.GetBoolean("OpenInNewTab") ?? false) == true) 247 { 248 jobButton.OnClick = "window.open('https://candidate.hr-manager.net/Agent/Subscription.aspx?customer=" + contentList.CustomerAlias + "','_blank')"; 249 } 250 251 @Render(jobButton) 252 } 253 </div> 254 </div> 255 </div> 256 </div> 257 </div> 258 </div> 259 </div> 260 </div> 261 if (users.ProjectLeader != null || users.ProjectParticipants != null) 262 { 263 if (!isMobileOrTablet) 264 { 265 <div class="grid"> 266 <div class="grid__col-lg-12 content-text" style="padding-top: 0px; padding-bottom: 0px; padding-right: 0px; height: 0px;"> 267 <div class="content-container dw-mod"> 268 <div class="content-row content-row--full content-row--column-gap-lg content-row--center content-row--height-auto content-row--spacing-xl content-row--spacing-position-bottom dw-mod"> 269 <div class="content-row__item rowItemContent-32508 dw-mod"> 270 <div class="u-full-width u-align-center dw-mod"> 271 <div class="separation-line-container separation-line-container--align-center dw-mod"> 272 <div class="separation-line separation-line--weight-xs separation-line--width-full dw-mod" style="border-color: #B1B1B1"></div> 273 </div> 274 </div> 275 </div> 276 </div> 277 </div> 278 </div> 279 </div> 280 } 281 282 <div class="grid"> 283 <div class="grid__col-lg-12 content-text"> 284 <div class="content-row content-row--full content-row--column-gap-lg content-row--center content-row--height-auto content-row--spacing-xl content-row--spacing-position-top dw-mod" style="margin-top: 0px;"> 285 <div class="content-row__item rowItemContent-12905 dw-mod"> 286 <div class="u-full-width u-align-left u-align-self-start dw-mod"> 287 <div class="u-full-height"> 288 <div class="content-row__item__body padding-size-none padding-position-around dw-mod"> 289 <div class="u-margin-bottom--lg"> 290 <h2>@Translate("Yderligere info")</h2> 291 <p>@Translate("Har du spørgsmål til stillingen, er du velkommen til at kontakte")</p> 292 </div> 293 </div> 294 </div> 295 </div> 296 </div> 297 </div> 298 </div> 299 <div class="grid__col-lg-12"> 300 <div class="content-row content-row--4col content-row--column-gap-none content-row--center content-row--height-auto content-row--spacing-xl content-row--spacing-position-bottom dw-mod"> 301 @{ 302 if (users.ProjectLeader != null) 303 { 304 <div class="content-row__item rowItemContent-12915 dw-mod @(isMobileOrTablet ? "job-margin-top" : "")"> 305 <div class="content-row__item__body padding-size-none padding-position-around u-align-left u-align-self-start dw-mod"> 306 <img class="b-lazy grid__cell-img--ball dw-mod b-loaded jobProfileImage" src="@users.ProjectLeader.ImageUrl?Width=130&amp;Height=130&amp;Crop=0&amp;BackgroundColor=&amp;DoNotUpscale=True&amp;FillCanvas=False&amp;Image=&amp;AlternativeImage=/Images/missing_image.jpg"> 307 <div class="u-full-width u-padding-top dw-mod"> 308 <div class="u-margin-bottom--lg"> 309 310 @if (users.ProjectLeader.FirstName != String.Empty) 311 { 312 <p class="content-p-margin">@users.ProjectLeader.FirstName @users.ProjectLeader.LastName</p> 313 } 314 @if (users.ProjectLeader.Title != String.Empty) 315 { 316 <p class="content-p-margin"> @users.ProjectLeader.Title</p> 317 } 318 @if (users.ProjectLeader.Phone != String.Empty || users.ProjectLeader.PhoneMobile != String.Empty) 319 { 320 var phone = !string.IsNullOrWhiteSpace(users.ProjectLeader.PhoneMobile) ? users.ProjectLeader.PhoneMobile : users.ProjectLeader.Phone; 321 <p class="content-p-margin"> @phone</p> 322 } 323 @if (users.ProjectLeader.Email != String.Empty) 324 { 325 <p class="content-p-margin"> <a href="mailto:@users.ProjectLeader.Email?subject=Vedr. @item.Name ">@users.ProjectLeader.Email</a></p> 326 } 327 </div> 328 </div> 329 </div> 330 </div> 331 } 332 if (users.ProjectParticipants != null) 333 { 334 foreach (var usersProjectParticipant in users.ProjectParticipants) 335 { 336 <div class="content-row__item rowItemContent-12915 dw-mod"> 337 <div class="content-row__item__body padding-size-none padding-position-around u-align-left u-align-self-start dw-mod"> 338 <img class="b-lazy grid__cell-img--ball dw-mod b-loaded jobProfileImage @(isMobileOrTablet ? "job-margin-top" : "")" src="@usersProjectParticipant.ImageUrl?Width=130&amp;Height=130&amp;Crop=0&amp;BackgroundColor=&amp;DoNotUpscale=True&amp;FillCanvas=False&amp;Image=&amp;AlternativeImage=/Images/missing_image.jpg"> 339 <div class="u-full-width u-padding-top dw-mod"> 340 <div class="u-margin-bottom--lg"> 341 @if (usersProjectParticipant.FirstName != String.Empty) 342 { 343 <p class="content-p-margin">@usersProjectParticipant.FirstName @usersProjectParticipant.LastName </p> 344 } 345 @if (usersProjectParticipant.Title != String.Empty) 346 { 347 <p class="content-p-margin">@usersProjectParticipant.Title </p> 348 } 349 @if (usersProjectParticipant.Phone != String.Empty || usersProjectParticipant.PhoneMobile != String.Empty) 350 { 351 var phone = !string.IsNullOrWhiteSpace(usersProjectParticipant.PhoneMobile) ? usersProjectParticipant.PhoneMobile : usersProjectParticipant.Phone; 352 <p class="content-p-margin"> @phone </p> 353 } 354 @if (usersProjectParticipant.Email != String.Empty) 355 { 356 <p class="content-p-margin"> <a href="mailto:@usersProjectParticipant.Email?subject=Vedr. @item.Name ">@usersProjectParticipant.Email</a> </p> 357 } 358 </div> 359 </div> 360 </div> 361 </div> 362 } 363 } 364 } 365 <div class="content-row__item dw-mod"> 366 <div class="content-row__item__body dw-mod"> 367 </div> 368 </div> 369 </div> 370 </div> 371 </div>} 372 373 <script> 374 document.addEventListener('DOMContentLoaded', () => { 375 var el = createBreadcrumbItem(); 376 var lastBreadcrumb = makePreviousLastBCrumbClickable(); 377 if (lastBreadcrumb) { 378 insertAfter(lastBreadcrumb, el); 379 } 380 }); 381 382 function createBreadcrumbItem() { 383 var el = document.createElement("li"); 384 el.innerHTML = `<span class="dw-mod">@item.Name</span>`; 385 el.classList.add("breadcrumb__item"); 386 return el; 387 } 388 389 function makePreviousLastBCrumbClickable() { 390 var breadcrumbItems = document.getElementsByClassName("breadcrumb__item"); 391 if (breadcrumbItems.length > 0) { 392 var lastBreadcrumb = breadcrumbItems[breadcrumbItems.length - 1]; 393 var breadcrumbLinkElement = lastBreadcrumb.firstElementChild; 394 var originalInnerHTML = breadcrumbLinkElement.innerHTML; 395 breadcrumbLinkElement.innerHTML = "<a href='" + breadcrumbLinkElement.getAttribute("data-link") + "'>" + originalInnerHTML + "</a>"; 396 return lastBreadcrumb; 397 } 398 return null; 399 400 } 401 402 function insertAfter(referenceNode, newNode) { 403 referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling); 404 } 405 </script> 406 } 407 408 @helper Render404() 409 { 410 <script> 411 window.location.replace("@jobUrl"); 412 </script> 413 } 414 415 @using System.Text.RegularExpressions 416 @using System.Collections.Generic 417 @using System.Reflection 418 @using System.Web 419 @using System.Web.UI.HtmlControls 420 @using Dynamicweb.Rapido.Blocks.Components 421 @using Dynamicweb.Rapido.Blocks.Components.Articles 422 @using Dynamicweb.Rapido.Blocks.Components.Documentation 423 @using Dynamicweb.Rapido.Blocks 424 425 426 @*--- START: Base block renderers ---*@ 427 428 @helper RenderBlockList(List<Block> blocks) 429 { 430 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 431 blocks = blocks.OrderBy(item => item.SortId).ToList(); 432 433 foreach (Block item in blocks) 434 { 435 if (debug) { 436 <!-- Block START: @item.Id --> 437 } 438 439 if (item.Design == null) 440 { 441 @RenderBlock(item) 442 } 443 else if (item.Design.RenderType == RenderType.None) { 444 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 445 446 <div class="@cssClass dw-mod"> 447 @RenderBlock(item) 448 </div> 449 } 450 else if (item.Design.RenderType != RenderType.Hide) 451 { 452 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 453 454 if (!item.SkipRenderBlocksList) { 455 if (item.Design.RenderType == RenderType.Row) 456 { 457 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 458 @RenderBlock(item) 459 </div> 460 } 461 462 if (item.Design.RenderType == RenderType.Column) 463 { 464 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 465 string size = item.Design.Size ?? "12"; 466 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 467 468 <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"> 469 @RenderBlock(item) 470 </div> 471 } 472 473 if (item.Design.RenderType == RenderType.Table) 474 { 475 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 476 @RenderBlock(item) 477 </table> 478 } 479 480 if (item.Design.RenderType == RenderType.TableRow) 481 { 482 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 483 @RenderBlock(item) 484 </tr> 485 } 486 487 if (item.Design.RenderType == RenderType.TableColumn) 488 { 489 <td class="@cssClass dw-mod" id="Block__@item.Id"> 490 @RenderBlock(item) 491 </td> 492 } 493 494 if (item.Design.RenderType == RenderType.CardHeader) 495 { 496 <div class="card-header @cssClass dw-mod"> 497 @RenderBlock(item) 498 </div> 499 } 500 501 if (item.Design.RenderType == RenderType.CardBody) 502 { 503 <div class="card @cssClass dw-mod"> 504 @RenderBlock(item) 505 </div> 506 } 507 508 if (item.Design.RenderType == RenderType.CardFooter) 509 { 510 <div class="card-footer @cssClass dw-mod"> 511 @RenderBlock(item) 512 </div> 513 } 514 } 515 else 516 { 517 @RenderBlock(item) 518 } 519 } 520 521 if (debug) { 522 <!-- Block END: @item.Id --> 523 } 524 } 525 } 526 527 @helper RenderBlock(Block item) 528 { 529 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 530 531 if (item.Template != null) 532 { 533 @BlocksPage.RenderTemplate(item.Template) 534 } 535 536 if (item.Component != null) 537 { 538 string customSufix = "Custom"; 539 string methodName = item.Component.HelperName; 540 541 ComponentBase[] methodParameters = new ComponentBase[1]; 542 methodParameters[0] = item.Component; 543 Type methodType = this.GetType(); 544 545 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 546 547 try { 548 if (debug) { 549 <!-- Component: @methodName.Replace("Render", "") --> 550 } 551 if(customMethod != null) { 552 @customMethod.Invoke(this, methodParameters).ToString(); 553 } else { 554 MethodInfo generalMethod = methodType.GetMethod(methodName); 555 @generalMethod.Invoke(this, methodParameters).ToString(); 556 } 557 } catch { 558 try { 559 MethodInfo generalMethod = methodType.GetMethod(methodName); 560 @generalMethod.Invoke(this, methodParameters).ToString(); 561 } catch(Exception ex) { 562 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 563 } 564 } 565 } 566 567 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 568 { 569 @RenderBlockList(item.BlocksList) 570 } 571 } 572 573 @*--- END: Base block renderers ---*@ 574 575 @using Dynamicweb.Rapido.Blocks.Components 576 @using Dynamicweb.Rapido.Blocks.Components.General 577 @using Dynamicweb.Rapido.Blocks 578 @using System.IO 579 580 @* Required *@ 581 @using Dynamicweb.Rapido.Blocks.Components 582 @using Dynamicweb.Rapido.Blocks.Components.General 583 @using Dynamicweb.Rapido.Blocks 584 585 586 @helper Render(ComponentBase component) 587 { 588 if (component != null) 589 { 590 @component.Render(this) 591 } 592 } 593 594 @* Components *@ 595 @using System.Reflection 596 @using Dynamicweb.Rapido.Blocks.Components.General 597 598 599 @* Component *@ 600 601 @helper RenderIcon(Icon settings) 602 { 603 if (settings != null) 604 { 605 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 606 607 if (settings.Name != null) 608 { 609 if (string.IsNullOrEmpty(settings.Label)) 610 { 611 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 612 } 613 else 614 { 615 if (settings.LabelPosition == IconLabelPosition.Before) 616 { 617 <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> 618 } 619 else 620 { 621 <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> 622 } 623 } 624 } 625 else if (!string.IsNullOrEmpty(settings.Label)) 626 { 627 @settings.Label 628 } 629 } 630 } 631 @using System.Reflection 632 @using Dynamicweb.Rapido.Blocks.Components.General 633 @using Dynamicweb.Rapido.Blocks.Components 634 @using Dynamicweb.Core 635 636 @* Component *@ 637 638 @helper RenderButton(Button settings) 639 { 640 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 641 { 642 Dictionary<string, string> attributes = new Dictionary<string, string>(); 643 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 644 if (settings.Disabled) { 645 attributes.Add("disabled", "true"); 646 classList.Add("disabled"); 647 } 648 649 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 650 { 651 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 652 @RenderConfirmDialog(settings); 653 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 654 } 655 656 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 657 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 658 if (!string.IsNullOrEmpty(settings.AltText)) 659 { 660 attributes.Add("title", settings.AltText); 661 } 662 else if (!string.IsNullOrEmpty(settings.Title)) 663 { 664 string cleanTitle = Regex.Replace(settings.Title, "<.*?>", String.Empty); 665 cleanTitle = cleanTitle.Replace("&nbsp;", " "); 666 attributes.Add("title", cleanTitle); 667 } 668 669 var onClickEvents = new List<string>(); 670 if (!string.IsNullOrEmpty(settings.OnClick)) 671 { 672 onClickEvents.Add(settings.OnClick); 673 } 674 if (!string.IsNullOrEmpty(settings.Href)) 675 { 676 onClickEvents.Add("location.href='" + settings.Href + "'"); 677 } 678 if (onClickEvents.Count > 0) 679 { 680 attributes.Add("onClick", string.Join(";", onClickEvents)); 681 } 682 683 if (settings.ButtonLayout != ButtonLayout.None) 684 { 685 classList.Add("btn"); 686 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 687 if (btnLayout == "linkclean") 688 { 689 btnLayout = "link-clean"; //fix 690 } 691 classList.Add("btn--" + btnLayout); 692 } 693 694 if (settings.Icon == null) 695 { 696 settings.Icon = new Icon(); 697 } 698 699 settings.Icon.CssClass += Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower() != "linkclean" ? " u-flex--align-center" : ""; 700 settings.Icon.Label = settings.Title; 701 702 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 703 704 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 705 } 706 } 707 708 @helper RenderConfirmDialog(Button settings) 709 { 710 Modal confirmDialog = new Modal { 711 Id = settings.Id, 712 Width = ModalWidth.Sm, 713 Heading = new Heading 714 { 715 Level = 2, 716 Title = settings.ConfirmTitle 717 }, 718 BodyText = settings.ConfirmText 719 }; 720 721 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 722 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 723 724 @Render(confirmDialog) 725 } 726 @using Dynamicweb.Rapido.Blocks.Components.General 727 @using Dynamicweb.Rapido.Blocks.Components 728 @using Dynamicweb.Core 729 730 @helper RenderDashboard(Dashboard settings) 731 { 732 var widgets = settings.GetWidgets(); 733 734 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 735 { 736 //set bg color for them 737 738 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 739 int r = Convert.ToInt16(color.R); 740 int g = Convert.ToInt16(color.G); 741 int b = Convert.ToInt16(color.B); 742 743 var count = widgets.Length; 744 var max = Math.Max(r, Math.Max(g, b)); 745 double step = 255.0 / (max * count); 746 var i = 0; 747 foreach (var widget in widgets) 748 { 749 i++; 750 751 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 752 widget.BackgroundColor = shade; 753 } 754 } 755 756 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 757 @foreach (var widget in widgets) 758 { 759 <div class="dashboard__widget"> 760 @Render(widget) 761 </div> 762 } 763 </div> 764 } 765 @using Dynamicweb.Rapido.Blocks.Components.General 766 @using Dynamicweb.Rapido.Blocks.Components 767 768 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 769 { 770 if (!string.IsNullOrEmpty(settings.Link)) 771 { 772 var backgroundStyles = ""; 773 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 774 { 775 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 776 } 777 778 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 779 <div class="u-center-middle u-color-light"> 780 @if (settings.Icon != null) 781 { 782 settings.Icon.CssClass += "widget__icon"; 783 @Render(settings.Icon) 784 } 785 <div class="widget__title">@settings.Title</div> 786 </div> 787 </a> 788 } 789 } 790 @using Dynamicweb.Rapido.Blocks.Components.General 791 @using Dynamicweb.Rapido.Blocks.Components 792 793 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 794 { 795 var backgroundStyles = ""; 796 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 797 { 798 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 799 } 800 801 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 802 <div class="u-center-middle u-color-light"> 803 @if (settings.Icon != null) 804 { 805 settings.Icon.CssClass += "widget__icon"; 806 @Render(settings.Icon) 807 } 808 <div class="widget__counter">@settings.Count</div> 809 <div class="widget__title">@settings.Title</div> 810 </div> 811 </div> 812 } 813 @using System.Reflection 814 @using Dynamicweb.Rapido.Blocks.Components.General 815 @using Dynamicweb.Rapido.Blocks.Components 816 @using Dynamicweb.Core 817 818 @* Component *@ 819 820 @helper RenderLink(Link settings) 821 { 822 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 823 { 824 Dictionary<string, string> attributes = new Dictionary<string, string>(); 825 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 826 if (settings.Disabled) 827 { 828 attributes.Add("disabled", "true"); 829 classList.Add("disabled"); 830 } 831 832 if (!string.IsNullOrEmpty(settings.AltText)) 833 { 834 attributes.Add("title", settings.AltText); 835 } 836 else if (!string.IsNullOrEmpty(settings.Title)) 837 { 838 attributes.Add("title", settings.Title); 839 } 840 841 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 842 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 843 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 844 attributes.Add("href", settings.Href); 845 846 if (settings.ButtonLayout != ButtonLayout.None) 847 { 848 classList.Add("btn"); 849 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 850 if (btnLayout == "linkclean") 851 { 852 btnLayout = "link-clean"; //fix 853 } 854 classList.Add("btn--" + btnLayout); 855 } 856 857 if (settings.Icon == null) 858 { 859 settings.Icon = new Icon(); 860 } 861 settings.Icon.Label = settings.Title; 862 863 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 864 { 865 settings.Rel = LinkRelType.Noopener; 866 } 867 if (settings.Target != LinkTargetType.None) 868 { 869 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 870 } 871 if (settings.Download) 872 { 873 attributes.Add("download", "true"); 874 } 875 if (settings.Rel != LinkRelType.None) 876 { 877 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 878 } 879 880 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 881 } 882 } 883 @using System.Reflection 884 @using Dynamicweb.Rapido.Blocks.Components 885 @using Dynamicweb.Rapido.Blocks.Components.General 886 @using Dynamicweb.Rapido.Blocks 887 888 889 @* Component *@ 890 891 @helper RenderRating(Rating settings) 892 { 893 if (settings.Score > 0) 894 { 895 int rating = settings.Score; 896 string iconType = "fa-star"; 897 898 switch (settings.Type.ToString()) { 899 case "Stars": 900 iconType = "fa-star"; 901 break; 902 case "Hearts": 903 iconType = "fa-heart"; 904 break; 905 case "Lemons": 906 iconType = "fa-lemon"; 907 break; 908 case "Bombs": 909 iconType = "fa-bomb"; 910 break; 911 } 912 913 <div class="u-ta-right"> 914 @for (int i = 0; i < settings.OutOf; i++) 915 { 916 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 917 } 918 </div> 919 } 920 } 921 @using System.Reflection 922 @using Dynamicweb.Rapido.Blocks.Components.General 923 @using Dynamicweb.Rapido.Blocks.Components 924 925 926 @* Component *@ 927 928 @helper RenderSelectFieldOption(SelectFieldOption settings) 929 { 930 Dictionary<string, string> attributes = new Dictionary<string, string>(); 931 if (settings.Checked) { attributes.Add("selected", "true"); } 932 if (settings.Disabled) { attributes.Add("disabled", "true"); } 933 if (settings.Value != null) { attributes.Add("value", settings.Value); } 934 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 935 936 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 937 } 938 @using System.Reflection 939 @using Dynamicweb.Rapido.Blocks.Components.General 940 @using Dynamicweb.Rapido.Blocks.Components 941 942 943 @* Component *@ 944 945 @helper RenderNavigation(Navigation settings) { 946 @RenderNavigation(new 947 { 948 id = settings.Id, 949 cssclass = settings.CssClass, 950 startLevel = settings.StartLevel, 951 endlevel = settings.EndLevel, 952 expandmode = settings.Expandmode, 953 sitemapmode = settings.SitemapMode, 954 template = settings.Template 955 }) 956 } 957 @using Dynamicweb.Rapido.Blocks.Components.General 958 @using Dynamicweb.Rapido.Blocks.Components 959 960 961 @* Component *@ 962 963 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 964 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 965 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 966 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 967 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 968 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 969 settings.SitemapMode = false; 970 971 @RenderNavigation(settings) 972 } 973 @using Dynamicweb.Rapido.Blocks.Components.General 974 @using Dynamicweb.Rapido.Blocks.Components 975 976 977 @* Component *@ 978 979 @helper RenderLeftNavigation(LeftNavigation settings) { 980 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 981 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 982 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 983 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 984 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 985 986 <div class="grid__cell"> 987 @RenderNavigation(settings) 988 </div> 989 } 990 @using System.Reflection 991 @using Dynamicweb.Rapido.Blocks.Components.General 992 @using Dynamicweb.Core 993 994 @* Component *@ 995 996 @helper RenderHeading(Heading settings) 997 { 998 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 999 { 1000 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1001 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 1002 1003 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 1004 if (!string.IsNullOrEmpty(settings.Link)) 1005 { 1006 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 1007 } 1008 else 1009 { 1010 if (settings.Icon == null) 1011 { 1012 settings.Icon = new Icon(); 1013 } 1014 settings.Icon.Label = settings.Title; 1015 @Render(settings.Icon) 1016 } 1017 @("</" + tagName + ">"); 1018 } 1019 } 1020 @using Dynamicweb.Rapido.Blocks.Components 1021 @using Dynamicweb.Rapido.Blocks.Components.General 1022 @using Dynamicweb.Rapido.Blocks 1023 1024 1025 @* Component *@ 1026 1027 @helper RenderImage(Image settings) 1028 { 1029 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 1030 { 1031 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1032 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 1033 1034 if (settings.Caption != null) 1035 { 1036 @:<div> 1037 } 1038 1039 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 1040 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 1041 1042 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 1043 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 1044 @if (settings.Link != null) 1045 { 1046 <a href="@settings.Link"> 1047 @RenderTheImage(settings) 1048 </a> 1049 } 1050 else 1051 { 1052 @RenderTheImage(settings) 1053 } 1054 </div> 1055 </div> 1056 1057 if (settings.Caption != null) 1058 { 1059 <span class="image-caption dw-mod">@settings.Caption</span> 1060 @:</div> 1061 } 1062 } 1063 else 1064 { 1065 if (settings.Caption != null) 1066 { 1067 @:<div> 1068 } 1069 if (!string.IsNullOrEmpty(settings.Link)) 1070 { 1071 <a href="@settings.Link"> 1072 @RenderTheImage(settings) 1073 </a> 1074 } 1075 else 1076 { 1077 @RenderTheImage(settings) 1078 } 1079 1080 if (settings.Caption != null) 1081 { 1082 <span class="image-caption dw-mod">@settings.Caption</span> 1083 @:</div> 1084 } 1085 } 1086 } 1087 1088 @helper RenderTheImage(Image settings) 1089 { 1090 if (settings != null) 1091 { 1092 string alternativeImage = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("AlternativeImage")) ? Pageview.AreaSettings.GetItem("Settings").GetFile("AlternativeImage").PathUrlEncoded : "/Images/missing_image.jpg"; 1093 string placeholderImage = "/Files/Images/placeholder.gif"; 1094 string imageEngine = "/Admin/Public/GetImage.ashx?"; 1095 1096 string imageStyle = ""; 1097 1098 switch (settings.Style) 1099 { 1100 case ImageStyle.Ball: 1101 imageStyle = "grid__cell-img--ball"; 1102 break; 1103 1104 case ImageStyle.Triangle: 1105 imageStyle = "grid__cell-img--triangle"; 1106 break; 1107 } 1108 1109 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle || settings.Style == ImageStyle.Triangle) 1110 { 1111 settings.ImageDefault.Crop = settings.ImageDefault.Crop == 5 ? settings.ImageDefault.Crop = 0 : settings.ImageDefault.Crop; 1112 1113 if (settings.ImageDefault != null) 1114 { 1115 settings.ImageDefault.Height = settings.ImageDefault.Width; 1116 } 1117 if (settings.ImageMedium != null) 1118 { 1119 settings.ImageMedium.Height = settings.ImageMedium.Width; 1120 } 1121 if (settings.ImageSmall != null) 1122 { 1123 settings.ImageSmall.Height = settings.ImageSmall.Width; 1124 } 1125 } 1126 1127 string defaultImage = imageEngine; 1128 string imageSmall = ""; 1129 string imageMedium = ""; 1130 1131 if (settings.DisableImageEngine) 1132 { 1133 defaultImage = settings.Path; 1134 } 1135 else 1136 { 1137 if (settings.ImageDefault != null) 1138 { 1139 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 1140 1141 if (settings.Path.GetType() != typeof(string)) 1142 { 1143 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1144 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1145 } 1146 else 1147 { 1148 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 1149 } 1150 1151 defaultImage += "&AlternativeImage=" + alternativeImage; 1152 } 1153 1154 if (settings.ImageSmall != null) 1155 { 1156 imageSmall = "data-src-small=\"" + imageEngine; 1157 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 1158 1159 if (settings.Path.GetType() != typeof(string)) 1160 { 1161 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1162 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1163 } 1164 else 1165 { 1166 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 1167 } 1168 1169 imageSmall += "&alternativeImage=" + alternativeImage; 1170 1171 imageSmall += "\""; 1172 } 1173 1174 if (settings.ImageMedium != null) 1175 { 1176 imageMedium = "data-src-medium=\"" + imageEngine; 1177 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 1178 1179 if (settings.Path.GetType() != typeof(string)) 1180 { 1181 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1182 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1183 } 1184 else 1185 { 1186 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 1187 } 1188 1189 imageMedium += "&alternativeImage=" + alternativeImage; 1190 1191 imageMedium += "\""; 1192 } 1193 } 1194 1195 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1196 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 1197 if (!string.IsNullOrEmpty(settings.Title)) 1198 { 1199 optionalAttributes.Add("alt", settings.Title); 1200 optionalAttributes.Add("title", settings.Title); 1201 } 1202 1203 if (settings.DisableLazyLoad) 1204 { 1205 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 1206 } 1207 else 1208 { 1209 <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) /> 1210 } 1211 } 1212 } 1213 @using System.Reflection 1214 @using Dynamicweb.Rapido.Blocks.Components.General 1215 @using Dynamicweb.Rapido.Blocks.Components 1216 1217 @* Component *@ 1218 1219 @helper RenderFileField(FileField settings) 1220 { 1221 var attributes = new Dictionary<string, string>(); 1222 if (string.IsNullOrEmpty(settings.Id)) 1223 { 1224 settings.Id = Guid.NewGuid().ToString("N"); 1225 } 1226 1227 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1228 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1229 if (settings.Required) { attributes.Add("required", "true"); } 1230 if (settings.Multiple) { attributes.Add("multiple", "true"); } 1231 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1232 if (string.IsNullOrEmpty(settings.ChooseFileText)) 1233 { 1234 settings.ChooseFileText = Translate("Choose file"); 1235 } 1236 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 1237 { 1238 settings.NoFilesChosenText = Translate("No files chosen..."); 1239 } 1240 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1241 1242 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1243 1244 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 1245 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 1246 1247 attributes.Add("type", "file"); 1248 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1249 settings.CssClass = "u-full-width " + settings.CssClass; 1250 1251 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1252 1253 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1254 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1255 { 1256 <div class="u-full-width"> 1257 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1258 @if (settings.Link != null) { 1259 <div class="u-pull--right"> 1260 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1261 @Render(settings.Link) 1262 </div> 1263 } 1264 </div> 1265 1266 } 1267 1268 @if (!string.IsNullOrEmpty(settings.HelpText)) 1269 { 1270 <small class="form__help-text">@settings.HelpText</small> 1271 } 1272 1273 <div class="form__field-combi file-input u-no-margin dw-mod"> 1274 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 1275 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 1276 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 1277 @if (settings.UploadButton != null) 1278 { 1279 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 1280 @Render(settings.UploadButton) 1281 } 1282 </div> 1283 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1284 </div> 1285 } 1286 @using System.Reflection 1287 @using Dynamicweb.Rapido.Blocks.Components.General 1288 @using Dynamicweb.Rapido.Blocks.Components 1289 @using Dynamicweb.Core 1290 @using System.Linq 1291 1292 @* Component *@ 1293 1294 @helper RenderDateTimeField(DateTimeField settings) 1295 { 1296 if (string.IsNullOrEmpty(settings.Id)) 1297 { 1298 settings.Id = Guid.NewGuid().ToString("N"); 1299 } 1300 1301 var textField = new TextField { 1302 Name = settings.Name, 1303 Id = settings.Id, 1304 Label = settings.Label, 1305 HelpText = settings.HelpText, 1306 Value = settings.Value, 1307 Disabled = settings.Disabled, 1308 Required = settings.Required, 1309 ErrorMessage = settings.ErrorMessage, 1310 CssClass = settings.CssClass, 1311 WrapperCssClass = settings.WrapperCssClass, 1312 OnChange = settings.OnChange, 1313 OnClick = settings.OnClick, 1314 Link = settings.Link, 1315 ExtraAttributes = settings.ExtraAttributes, 1316 // 1317 Placeholder = settings.Placeholder 1318 }; 1319 1320 @Render(textField) 1321 1322 List<string> jsAttributes = new List<string>(); 1323 1324 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1325 1326 if (!string.IsNullOrEmpty(settings.DateFormat)) 1327 { 1328 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1329 } 1330 if (!string.IsNullOrEmpty(settings.MinDate)) 1331 { 1332 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1333 } 1334 if (!string.IsNullOrEmpty(settings.MaxDate)) 1335 { 1336 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1337 } 1338 if (settings.IsInline) 1339 { 1340 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1341 } 1342 if (settings.EnableTime) 1343 { 1344 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1345 } 1346 if (settings.EnableWeekNumbers) 1347 { 1348 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1349 } 1350 1351 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1352 1353 <script> 1354 document.addEventListener("DOMContentLoaded", function () { 1355 flatpickr("#@textField.Id", { 1356 @string.Join(",", jsAttributes) 1357 }); 1358 }); 1359 </script> 1360 } 1361 @using System.Reflection 1362 @using Dynamicweb.Rapido.Blocks.Components.General 1363 @using Dynamicweb.Rapido.Blocks.Components 1364 1365 @* Component *@ 1366 1367 @helper RenderTextField(TextField settings) 1368 { 1369 var attributes = new Dictionary<string, string>(); 1370 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1371 { 1372 settings.Id = Guid.NewGuid().ToString("N"); 1373 } 1374 1375 /*base settings*/ 1376 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1377 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1378 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1379 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1380 if (settings.Required) { attributes.Add("required", "true"); } 1381 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1382 /*end*/ 1383 1384 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1385 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1386 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1387 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1388 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1389 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1390 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1391 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1392 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1393 1394 settings.CssClass = "u-full-width " + settings.CssClass; 1395 1396 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1397 1398 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1399 1400 string noMargin = "u-no-margin"; 1401 if (!settings.ReadOnly) { 1402 noMargin = ""; 1403 } 1404 1405 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1406 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1407 { 1408 <div class="u-full-width"> 1409 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1410 @if (settings.Link != null) { 1411 settings.Link.ButtonLayout = ButtonLayout.LinkClean; 1412 1413 <div class="u-pull--right"> 1414 @Render(settings.Link) 1415 </div> 1416 } 1417 </div> 1418 1419 } 1420 1421 @if (!string.IsNullOrEmpty(settings.HelpText)) 1422 { 1423 <small class="form__help-text">@settings.HelpText</small> 1424 } 1425 1426 @if (settings.ActionButton != null) 1427 { 1428 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1429 <div class="form__field-combi u-no-margin dw-mod"> 1430 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1431 @Render(settings.ActionButton) 1432 </div> 1433 } 1434 else 1435 { 1436 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1437 } 1438 1439 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1440 </div> 1441 } 1442 @using System.Reflection 1443 @using Dynamicweb.Rapido.Blocks.Components.General 1444 @using Dynamicweb.Rapido.Blocks.Components 1445 1446 @* Component *@ 1447 1448 @helper RenderNumberField(NumberField settings) 1449 { 1450 var attributes = new Dictionary<string, string>(); 1451 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1452 { 1453 settings.Id = Guid.NewGuid().ToString("N"); 1454 } 1455 1456 /*base settings*/ 1457 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1458 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1459 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1460 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1461 if (settings.Required) { attributes.Add("required", "true"); } 1462 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1463 /*end*/ 1464 1465 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1466 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1467 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1468 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1469 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1470 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1471 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1472 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1473 attributes.Add("type", "number"); 1474 1475 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1476 1477 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1478 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1479 { 1480 <div class="u-full-width"> 1481 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1482 @if (settings.Link != null) { 1483 <div class="u-pull--right"> 1484 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1485 @Render(settings.Link) 1486 </div> 1487 } 1488 </div> 1489 1490 } 1491 1492 @if (!string.IsNullOrEmpty(settings.HelpText)) 1493 { 1494 <small class="form__help-text">@settings.HelpText</small> 1495 } 1496 1497 @if (settings.ActionButton != null) 1498 { 1499 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1500 <div class="form__field-combi u-no-margin dw-mod"> 1501 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1502 @Render(settings.ActionButton) 1503 </div> 1504 } 1505 else 1506 { 1507 <div class="form__field-combi u-no-margin dw-mod"> 1508 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1509 </div> 1510 } 1511 1512 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1513 </div> 1514 } 1515 @using System.Reflection 1516 @using Dynamicweb.Rapido.Blocks.Components.General 1517 @using Dynamicweb.Rapido.Blocks.Components 1518 1519 1520 @* Component *@ 1521 1522 @helper RenderTextareaField(TextareaField settings) 1523 { 1524 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1525 string id = settings.Id; 1526 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1527 { 1528 id = Guid.NewGuid().ToString("N"); 1529 } 1530 1531 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1532 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1533 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1534 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1535 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1536 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1537 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1538 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1539 if (settings.Required) { attributes.Add("required", "true"); } 1540 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1541 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1542 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1543 attributes.Add("name", settings.Name); 1544 1545 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1546 1547 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1548 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1549 { 1550 <div class="u-full-width"> 1551 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1552 @if (settings.Link != null) { 1553 <div class="u-pull--right"> 1554 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1555 @Render(settings.Link) 1556 </div> 1557 } 1558 </div> 1559 } 1560 1561 @if (!string.IsNullOrEmpty(settings.HelpText)) 1562 { 1563 <small class="form__help-text">@settings.HelpText</small> 1564 } 1565 1566 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1567 1568 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1569 </div> 1570 } 1571 @using System.Reflection 1572 @using Dynamicweb.Rapido.Blocks.Components.General 1573 @using Dynamicweb.Rapido.Blocks.Components 1574 1575 1576 @* Component *@ 1577 1578 @helper RenderHiddenField(HiddenField settings) { 1579 var attributes = new Dictionary<string, string>(); 1580 attributes.Add("type", "hidden"); 1581 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1582 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1583 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1584 1585 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1586 } 1587 @using System.Reflection 1588 @using Dynamicweb.Rapido.Blocks.Components.General 1589 @using Dynamicweb.Rapido.Blocks.Components 1590 1591 @* Component *@ 1592 1593 @helper RenderCheckboxField(CheckboxField settings) 1594 { 1595 var attributes = new Dictionary<string, string>(); 1596 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1597 { 1598 settings.Id = Guid.NewGuid().ToString("N"); 1599 } 1600 1601 /*base settings*/ 1602 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1603 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1604 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1605 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1606 if (settings.Required) { attributes.Add("required", "true"); } 1607 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1608 /*end*/ 1609 1610 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1611 1612 attributes.Add("type", "checkbox"); 1613 if (settings.Checked) { attributes.Add("checked", "true"); } 1614 settings.CssClass = "form__control " + settings.CssClass; 1615 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1616 1617 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1618 1619 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1620 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1621 @if (!string.IsNullOrEmpty(settings.Label)) 1622 { 1623 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1624 } 1625 1626 @if (settings.Link != null) { 1627 <span> 1628 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1629 @Render(settings.Link) 1630 </span> 1631 } 1632 1633 @if (!string.IsNullOrEmpty(settings.HelpText)) 1634 { 1635 <small class="form__help-text checkbox-help dw-mod">@settings.HelpText</small> 1636 } 1637 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1638 </div> 1639 } 1640 @using System.Reflection 1641 @using Dynamicweb.Rapido.Blocks.Components.General 1642 @using Dynamicweb.Rapido.Blocks.Components 1643 1644 1645 @* Component *@ 1646 1647 @helper RenderCheckboxListField(CheckboxListField settings) 1648 { 1649 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1650 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1651 { 1652 <div class="u-full-width"> 1653 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1654 @if (settings.Link != null) { 1655 <div class="u-pull--right"> 1656 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1657 @Render(settings.Link) 1658 </div> 1659 } 1660 </div> 1661 1662 } 1663 1664 <div class="u-pull--left"> 1665 @if (!string.IsNullOrEmpty(settings.HelpText)) 1666 { 1667 <small class="form__help-text">@settings.HelpText</small> 1668 } 1669 1670 @foreach (var item in settings.Options) 1671 { 1672 if (settings.Required) 1673 { 1674 item.Required = true; 1675 } 1676 if (settings.Disabled) 1677 { 1678 item.Disabled = true; 1679 } 1680 if (!string.IsNullOrEmpty(settings.Name)) 1681 { 1682 item.Name = settings.Name; 1683 } 1684 if (!string.IsNullOrEmpty(settings.CssClass)) 1685 { 1686 item.CssClass += settings.CssClass; 1687 } 1688 1689 /* value is not supported */ 1690 1691 if (!string.IsNullOrEmpty(settings.OnClick)) 1692 { 1693 item.OnClick += settings.OnClick; 1694 } 1695 if (!string.IsNullOrEmpty(settings.OnChange)) 1696 { 1697 item.OnChange += settings.OnChange; 1698 } 1699 @Render(item) 1700 } 1701 1702 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1703 </div> 1704 1705 </div> 1706 } 1707 @using Dynamicweb.Rapido.Blocks.Components.General 1708 1709 @* Component *@ 1710 1711 @helper RenderSearch(Search settings) 1712 { 1713 var searchValue = HttpContext.Current.Request.QueryString.Get(settings.SearchParameter) ?? ""; 1714 var groupValue = HttpContext.Current.Request.QueryString.Get(settings.GroupsParameter) ?? ""; 1715 1716 if (string.IsNullOrEmpty(settings.Id)) 1717 { 1718 settings.Id = Guid.NewGuid().ToString("N"); 1719 } 1720 1721 var resultAttributes = new Dictionary<string, string>(); 1722 1723 if (settings.PageSize != 0) 1724 { 1725 resultAttributes.Add("data-page-size", settings.PageSize.ToString()); 1726 } 1727 if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1728 { 1729 resultAttributes.Add("data-groups-feed-url", settings.GroupItemsFeedUrl); 1730 if (!string.IsNullOrEmpty(groupValue)) 1731 { 1732 resultAttributes.Add("data-selected-group", groupValue); 1733 } 1734 if (!string.IsNullOrEmpty(settings.GroupsParameter)) 1735 { 1736 resultAttributes.Add("data-groups-parameter", settings.GroupsParameter); 1737 } 1738 } 1739 resultAttributes.Add("data-force-init", "true"); 1740 if (settings.GoToFirstSearchResultOnEnter) 1741 { 1742 resultAttributes.Add("data-go-to-first-search-result-on-enter", settings.GoToFirstSearchResultOnEnter.ToString().ToLower()); 1743 } 1744 if (!string.IsNullOrEmpty(settings.SearchParameter)) 1745 { 1746 resultAttributes.Add("data-search-parameter", settings.SearchParameter); 1747 } 1748 resultAttributes.Add("data-search-feed-url", settings.SearchData.SearchFeedUrl); 1749 resultAttributes.Add("data-results-template-id", settings.SearchData.ResultsTemplateId); 1750 1751 if (settings.SecondSearchData != null) 1752 { 1753 resultAttributes.Add("data-second-search-feed-url", settings.SecondSearchData.SearchFeedUrl); 1754 resultAttributes.Add("data-second-results-template-id", settings.SecondSearchData.ResultsTemplateId); 1755 } 1756 if (!string.IsNullOrEmpty(settings.ResultsPageUrl)) 1757 { 1758 resultAttributes.Add("data-results-page-url", settings.ResultsPageUrl); 1759 } 1760 1761 resultAttributes = resultAttributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1762 1763 string searchFieldCss = (settings.SearchButton == null) ? "search--with-icon" : ""; 1764 1765 <div class="search @settings.CssClass @searchFieldCss js-search-data-source dw-mod" id="@settings.Id" @ComponentMethods.AddAttributes(resultAttributes)> 1766 @if (!string.IsNullOrEmpty(settings.GroupItemsFeedUrl)) 1767 { 1768 <button type="button" class="search__groups-btn dw-mod js-search-groups-btn">@Translate("All")</button> 1769 <ul class="dropdown dropdown--absolute-position dw-mod search__groups-results js-search-groups-list"></ul> 1770 } 1771 1772 <input type="text" class="search__field dw-mod js-search-field" placeholder="@settings.Placeholder" value="@searchValue"> 1773 1774 <div class="dropdown dropdown--absolute-position search__results dw-mod js-search-results @(settings.SecondSearchData != null ? "search__results--combined" : "")"> 1775 @if (settings.SecondSearchData != null) 1776 { 1777 <div class="search__column search__column--products dw-mod"> 1778 <div class="search__column-header dw-mod">@Translate("Products")</div> 1779 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1780 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1781 { 1782 @Render(new Link { 1783 Title = Translate("View all"), 1784 CssClass = "js-view-all-button u-margin", 1785 Href = settings.SearchData.ResultsPageUrl 1786 }); 1787 } 1788 </div> 1789 <div class="search__column search__column--pages dw-mod"> 1790 <div class="search__column-header">@Translate("Pages")</div> 1791 <ul class="search__results-list dw-mod js-search-results-second-list" id="@(settings.Id)_SecondResultsList"></ul> 1792 @if (!string.IsNullOrEmpty(settings.SecondSearchData.ResultsPageUrl)) 1793 { 1794 @Render(new Link 1795 { 1796 Title = Translate("View all"), 1797 CssClass = "js-view-all-button u-margin", 1798 Href = settings.SecondSearchData.ResultsPageUrl 1799 }); 1800 } 1801 </div> 1802 } 1803 else 1804 { 1805 <div class="search__column search__column--only dw-mod"> 1806 <ul class="search__results-list dw-mod js-search-results-list" id="@(settings.Id)_ResultsList"></ul> 1807 @if (!string.IsNullOrEmpty(settings.SearchData.ResultsPageUrl)) 1808 { 1809 @Render(new Link { 1810 Title = Translate("View all"), 1811 CssClass = "js-view-all-button u-margin", 1812 Href = settings.SearchData.ResultsPageUrl 1813 }); 1814 } 1815 </div> 1816 } 1817 </div> 1818 1819 @if (settings.SearchButton != null) 1820 { 1821 settings.SearchButton.CssClass += " search__btn js-search-btn"; 1822 if (settings.RenderDefaultSearchIcon) 1823 { 1824 settings.SearchButton.Icon = new Icon { Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("SearchIcon").SelectedValue }; 1825 } 1826 @Render(settings.SearchButton); 1827 } 1828 </div> 1829 } 1830 @using System.Reflection 1831 @using Dynamicweb.Rapido.Blocks.Components.General 1832 @using Dynamicweb.Rapido.Blocks.Components 1833 1834 1835 @* Component *@ 1836 1837 @helper RenderSelectField(SelectField settings) 1838 { 1839 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1840 { 1841 settings.Id = Guid.NewGuid().ToString("N"); 1842 } 1843 1844 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1845 @if (!string.IsNullOrEmpty(settings.Label) || settings.Link != null ) 1846 { 1847 <div class="u-full-width"> 1848 @if (!string.IsNullOrEmpty(settings.Label)) { <label for="@settings.Id" class="u-pull--left">@settings.Label</label> } 1849 @if (settings.Link != null) { 1850 <div class="u-pull--right"> 1851 @{ settings.Link.ButtonLayout = ButtonLayout.LinkClean; } 1852 @Render(settings.Link) 1853 </div> 1854 } 1855 </div> 1856 } 1857 1858 @if (!string.IsNullOrEmpty(settings.HelpText)) 1859 { 1860 <small class="form__help-text">@settings.HelpText</small> 1861 } 1862 1863 @if (settings.ActionButton != null) 1864 { 1865 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1866 <div class="form__field-combi u-no-margin dw-mod"> 1867 @RenderSelectBase(settings) 1868 @Render(settings.ActionButton) 1869 </div> 1870 } 1871 else 1872 { 1873 @RenderSelectBase(settings) 1874 } 1875 1876 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1877 </div> 1878 } 1879 1880 @helper RenderSelectBase(SelectField settings) 1881 { 1882 var attributes = new Dictionary<string, string>(); 1883 1884 /*base settings*/ 1885 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1886 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1887 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1888 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1889 if (settings.Required) { attributes.Add("required", "true"); } 1890 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1891 /*end*/ 1892 1893 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1894 1895 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1896 @if (settings.Default != null) 1897 { 1898 @Render(settings.Default) 1899 } 1900 1901 @foreach (var item in settings.Options) 1902 { 1903 if (settings.Value != null) { 1904 item.Checked = item.Value == settings.Value; 1905 } 1906 @Render(item) 1907 } 1908 </select> 1909 } 1910 @using System.Reflection 1911 @using Dynamicweb.Rapido.Blocks.Components.General 1912 @using Dynamicweb.Rapido.Blocks.Components 1913 1914 @* Component *@ 1915 1916 @helper RenderRadioButtonField(RadioButtonField settings) 1917 { 1918 var attributes = new Dictionary<string, string>(); 1919 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1920 { 1921 settings.Id = Guid.NewGuid().ToString("N"); 1922 } 1923 1924 /*base settings*/ 1925 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1926 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1927 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1928 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1929 if (settings.Required) { attributes.Add("required", "true"); } 1930 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1931 /*end*/ 1932 1933 attributes.Add("type", "radio"); 1934 if (settings.Checked) { attributes.Add("checked", "true"); } 1935 settings.CssClass = "form__control " + settings.CssClass; 1936 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1937 1938 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1939 1940 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1941 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1942 @if (!string.IsNullOrEmpty(settings.Label)) 1943 { 1944 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1945 } 1946 @if (!string.IsNullOrEmpty(settings.HelpText)) 1947 { 1948 <small class="form__help-text">@settings.HelpText</small> 1949 } 1950 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1951 </div> 1952 } 1953 @using System.Reflection 1954 @using Dynamicweb.Rapido.Blocks.Components.General 1955 @using Dynamicweb.Rapido.Blocks.Components 1956 1957 1958 @* Component *@ 1959 1960 @helper RenderRadioButtonListField(RadioButtonListField settings) 1961 { 1962 if (settings.Required && !String.IsNullOrEmpty(settings.Label)) { settings.Label += " <span class=\"required dw-mod\">*</span>"; } 1963 1964 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1965 @if (!string.IsNullOrEmpty(settings.Label)) 1966 { 1967 <label>@settings.Label</label> 1968 } 1969 @if (!string.IsNullOrEmpty(settings.HelpText)) 1970 { 1971 <small class="form__help-text">@settings.HelpText</small> 1972 } 1973 1974 @foreach (var item in settings.Options) 1975 { 1976 if (settings.Required) 1977 { 1978 item.Required = true; 1979 } 1980 if (settings.Disabled) 1981 { 1982 item.Disabled = true; 1983 } 1984 if (!string.IsNullOrEmpty(settings.Name)) 1985 { 1986 item.Name = settings.Name; 1987 } 1988 if (settings.Value != null && settings.Value == item.Value) 1989 { 1990 item.Checked = true; 1991 } 1992 if (!string.IsNullOrEmpty(settings.OnClick)) 1993 { 1994 item.OnClick += settings.OnClick; 1995 } 1996 if (!string.IsNullOrEmpty(settings.OnChange)) 1997 { 1998 item.OnChange += settings.OnChange; 1999 } 2000 if (!string.IsNullOrEmpty(settings.CssClass)) 2001 { 2002 item.CssClass += settings.CssClass; 2003 } 2004 @Render(item) 2005 } 2006 2007 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2008 </div> 2009 } 2010 @using System.Reflection 2011 @using Dynamicweb.Rapido.Blocks.Components.General 2012 @using Dynamicweb.Rapido.Blocks.Components 2013 2014 2015 @* Component *@ 2016 2017 @helper RenderNotificationMessage(NotificationMessage settings) 2018 { 2019 if (!string.IsNullOrEmpty(settings.Message)) 2020 { 2021 var attributes = new Dictionary<string, string>(); 2022 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2023 2024 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 2025 string messageLayoutClass = Enum.GetName(typeof(NotificationMessageLayout), settings.MessageLayout).ToLower(); 2026 string minHeightClass = settings.Icon != null ? "u-min-h70px" : ""; 2027 2028 <div class="notification-message-@messageTypeClass notification-message-@messageLayoutClass @messageLayoutClass @minHeightClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)> 2029 @if (settings.Icon != null) { 2030 settings.Icon.Label = !string.IsNullOrEmpty(settings.Icon.Label) ? settings.Message + settings.Icon.Label : settings.Message; 2031 @Render(settings.Icon) 2032 } else { 2033 @settings.Message 2034 } 2035 </div> 2036 } 2037 } 2038 @using Dynamicweb.Rapido.Blocks.Components.General 2039 2040 2041 @* Component *@ 2042 2043 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 2044 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 2045 2046 <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> 2047 @if (settings.SubBlocks != null) { 2048 @RenderBlockList(settings.SubBlocks) 2049 } 2050 </div> 2051 } 2052 @using System.Reflection 2053 @using Dynamicweb.Rapido.Blocks.Components.General 2054 @using Dynamicweb.Rapido.Blocks.Components 2055 @using System.Text.RegularExpressions 2056 2057 2058 @* Component *@ 2059 2060 @helper RenderSticker(Sticker settings) { 2061 if (!String.IsNullOrEmpty(settings.Title)) { 2062 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 2063 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 2064 2065 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 2066 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 2067 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 2068 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 2069 optionalAttributes.Add("style", styleTag); 2070 } 2071 2072 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 2073 } 2074 } 2075 2076 @using System.Reflection 2077 @using Dynamicweb.Rapido.Blocks.Components.General 2078 @using Dynamicweb.Rapido.Blocks.Components 2079 2080 2081 @* Component *@ 2082 2083 @helper RenderStickersCollection(StickersCollection settings) 2084 { 2085 if (settings.Stickers.Count > 0) 2086 { 2087 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 2088 2089 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2090 @foreach (Sticker sticker in settings.Stickers) 2091 { 2092 @Render(sticker) 2093 } 2094 </div> 2095 } 2096 } 2097 2098 @using Dynamicweb.Rapido.Blocks.Components.General 2099 2100 2101 @* Component *@ 2102 2103 @helper RenderForm(Form settings) { 2104 if (settings != null) 2105 { 2106 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2107 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 2108 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 2109 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 2110 var enctypes = new Dictionary<string, string> 2111 { 2112 { "multipart", "multipart/form-data" }, 2113 { "text", "text/plain" }, 2114 { "application", "application/x-www-form-urlencoded" } 2115 }; 2116 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 2117 optionalAttributes.Add("method", settings.Method.ToString()); 2118 2119 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 2120 { 2121 @settings.FormStartMarkup 2122 } 2123 else 2124 { 2125 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2126 } 2127 2128 foreach (var field in settings.GetFields()) 2129 { 2130 @Render(field) 2131 } 2132 2133 @:</form> 2134 } 2135 } 2136 @using System.Reflection 2137 @using Dynamicweb.Rapido.Blocks.Components.General 2138 @using Dynamicweb.Rapido.Blocks.Components 2139 2140 2141 @* Component *@ 2142 2143 @helper RenderText(Text settings) 2144 { 2145 @settings.Content 2146 } 2147 @using System.Reflection 2148 @using Dynamicweb.Rapido.Blocks.Components.General 2149 @using Dynamicweb.Rapido.Blocks.Components 2150 2151 2152 @* Component *@ 2153 2154 @helper RenderContentModule(ContentModule settings) { 2155 if (!string.IsNullOrEmpty(settings.Content)) 2156 { 2157 @settings.Content 2158 } 2159 } 2160 @using System.Reflection 2161 @using Dynamicweb.Rapido.Blocks.Components.General 2162 @using Dynamicweb.Rapido.Blocks.Components 2163 2164 2165 @* Component *@ 2166 2167 @helper RenderModal(Modal settings) { 2168 if (settings != null) 2169 { 2170 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 2171 2172 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 2173 2174 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 2175 2176 <div class="modal-container"> 2177 @if (!settings.DisableDarkOverlay) 2178 { 2179 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 2180 } 2181 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 2182 @if (settings.Heading != null) 2183 { 2184 if (!string.IsNullOrEmpty(settings.Heading.Title)) 2185 { 2186 <div class="modal__header"> 2187 @Render(settings.Heading) 2188 </div> 2189 } 2190 } 2191 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 2192 @if (!string.IsNullOrEmpty(settings.BodyText)) 2193 { 2194 @settings.BodyText 2195 } 2196 @if (settings.BodyTemplate != null) 2197 { 2198 @settings.BodyTemplate 2199 } 2200 @{ 2201 var actions = settings.GetActions(); 2202 } 2203 </div> 2204 @if (actions.Length > 0) 2205 { 2206 <div class="modal__footer"> 2207 @foreach (var action in actions) 2208 { 2209 if (Pageview.Device.ToString() != "Mobile") { 2210 action.CssClass += " u-no-margin"; 2211 } else { 2212 action.CssClass += " u-full-width u-margin-bottom"; 2213 } 2214 2215 @Render(action) 2216 } 2217 </div> 2218 } 2219 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 2220 </div> 2221 </div> 2222 } 2223 } 2224 @using Dynamicweb.Rapido.Blocks.Components.General 2225 2226 @* Component *@ 2227 2228 @helper RenderMediaListItem(MediaListItem settings) 2229 { 2230 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 2231 @if (!string.IsNullOrEmpty(settings.Label)) 2232 { 2233 if (!string.IsNullOrEmpty(settings.Link)) 2234 { 2235 @Render(new Link 2236 { 2237 Href = settings.Link, 2238 CssClass = "media-list-item__sticker dw-mod", 2239 ButtonLayout = ButtonLayout.None, 2240 Title = settings.Label, 2241 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2242 }) 2243 } 2244 else if (!string.IsNullOrEmpty(settings.OnClick)) 2245 { 2246 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 2247 <span class="u-uppercase">@settings.Label</span> 2248 </span> 2249 } 2250 else 2251 { 2252 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 2253 <span class="u-uppercase">@settings.Label</span> 2254 </span> 2255 } 2256 } 2257 <div class="media-list-item__wrap"> 2258 <div class="media-list-item__info dw-mod"> 2259 <div class="media-list-item__header dw-mod"> 2260 @if (!string.IsNullOrEmpty(settings.Title)) 2261 { 2262 if (!string.IsNullOrEmpty(settings.Link)) 2263 { 2264 @Render(new Link 2265 { 2266 Href = settings.Link, 2267 CssClass = "media-list-item__name dw-mod", 2268 ButtonLayout = ButtonLayout.None, 2269 Title = settings.Title, 2270 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2271 }) 2272 } 2273 else if (!string.IsNullOrEmpty(settings.OnClick)) 2274 { 2275 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 2276 } 2277 else 2278 { 2279 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 2280 } 2281 } 2282 2283 @if (!string.IsNullOrEmpty(settings.Status)) 2284 { 2285 <div class="media-list-item__state dw-mod">@settings.Status</div> 2286 } 2287 </div> 2288 @{ 2289 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 2290 } 2291 2292 @Render(settings.InfoTable) 2293 </div> 2294 <div class="media-list-item__actions dw-mod"> 2295 <div class="media-list-item__actions-list dw-mod"> 2296 @{ 2297 var actions = settings.GetActions(); 2298 2299 foreach (ButtonBase action in actions) 2300 { 2301 action.ButtonLayout = ButtonLayout.None; 2302 action.CssClass += " media-list-item__action link"; 2303 2304 @Render(action) 2305 } 2306 } 2307 </div> 2308 2309 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2310 { 2311 settings.SelectButton.CssClass += " u-no-margin"; 2312 2313 <div class="media-list-item__action-button"> 2314 @Render(settings.SelectButton) 2315 </div> 2316 } 2317 </div> 2318 </div> 2319 </div> 2320 } 2321 @using Dynamicweb.Rapido.Blocks.Components.General 2322 @using Dynamicweb.Rapido.Blocks.Components 2323 2324 @helper RenderTable(Table settings) 2325 { 2326 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2327 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2328 2329 var enumToClasses = new Dictionary<TableDesign, string> 2330 { 2331 { TableDesign.Clean, "table--clean" }, 2332 { TableDesign.Bordered, "table--bordered" }, 2333 { TableDesign.Striped, "table--striped" }, 2334 { TableDesign.Hover, "table--hover" }, 2335 { TableDesign.Compact, "table--compact" }, 2336 { TableDesign.Condensed, "table--condensed" }, 2337 { TableDesign.NoTopBorder, "table--no-top-border" } 2338 }; 2339 string tableDesignClass = ""; 2340 if (settings.Design != TableDesign.None) 2341 { 2342 tableDesignClass = enumToClasses[settings.Design]; 2343 } 2344 2345 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2346 2347 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2348 2349 <table @ComponentMethods.AddAttributes(resultAttributes)> 2350 @if (settings.Header != null) 2351 { 2352 <thead> 2353 @Render(settings.Header) 2354 </thead> 2355 } 2356 <tbody> 2357 @foreach (var row in settings.Rows) 2358 { 2359 @Render(row) 2360 } 2361 </tbody> 2362 @if (settings.Footer != null) 2363 { 2364 <tfoot> 2365 @Render(settings.Footer) 2366 </tfoot> 2367 } 2368 </table> 2369 } 2370 @using Dynamicweb.Rapido.Blocks.Components.General 2371 @using Dynamicweb.Rapido.Blocks.Components 2372 2373 @helper RenderTableRow(TableRow settings) 2374 { 2375 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2376 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2377 2378 var enumToClasses = new Dictionary<TableRowDesign, string> 2379 { 2380 { TableRowDesign.NoBorder, "table__row--no-border" }, 2381 { TableRowDesign.Border, "table__row--border" }, 2382 { TableRowDesign.TopBorder, "table__row--top-line" }, 2383 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2384 { TableRowDesign.Solid, "table__row--solid" } 2385 }; 2386 2387 string tableRowDesignClass = ""; 2388 if (settings.Design != TableRowDesign.None) 2389 { 2390 tableRowDesignClass = enumToClasses[settings.Design]; 2391 } 2392 2393 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2394 2395 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2396 2397 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2398 @foreach (var cell in settings.Cells) 2399 { 2400 if (settings.IsHeaderRow) 2401 { 2402 cell.IsHeader = true; 2403 } 2404 @Render(cell) 2405 } 2406 </tr> 2407 } 2408 @using Dynamicweb.Rapido.Blocks.Components.General 2409 @using Dynamicweb.Rapido.Blocks.Components 2410 @using Dynamicweb.Core 2411 2412 @helper RenderTableCell(TableCell settings) 2413 { 2414 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2415 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2416 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2417 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2418 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2419 2420 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2421 2422 string tagName = settings.IsHeader ? "th" : "td"; 2423 2424 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2425 @settings.Content 2426 @("</" + tagName + ">"); 2427 } 2428 @using System.Linq 2429 @using Dynamicweb.Rapido.Blocks.Components.General 2430 2431 @* Component *@ 2432 2433 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2434 { 2435 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2436 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2437 2438 if (settings.NumberOfPages > 1) 2439 { 2440 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2441 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2442 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2443 2444 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2445 @if (settings.ShowPagingInfo) 2446 { 2447 <div class="pager__info dw-mod"> 2448 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2449 </div> 2450 } 2451 <ul class="pager__list dw-mod"> 2452 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2453 { 2454 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2455 } 2456 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2457 { 2458 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2459 } 2460 @if (settings.GetPages().Any()) 2461 { 2462 foreach (var page in settings.GetPages()) 2463 { 2464 @Render(page) 2465 } 2466 } 2467 else 2468 { 2469 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2470 { 2471 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2472 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2473 } 2474 } 2475 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2476 { 2477 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2478 } 2479 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2480 { 2481 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2482 } 2483 </ul> 2484 </div> 2485 } 2486 } 2487 2488 @helper RenderPaginationItem(PaginationItem settings) 2489 { 2490 if (settings.Icon == null) 2491 { 2492 settings.Icon = new Icon(); 2493 } 2494 2495 settings.Icon.Label = settings.Label; 2496 <li class="pager__btn dw-mod"> 2497 @if (settings.IsActive) 2498 { 2499 <span class="pager__num pager__num--current dw-mod"> 2500 @Render(settings.Icon) 2501 </span> 2502 } 2503 else 2504 { 2505 <a href="@settings.Link" class="pager__num dw-mod"> 2506 @Render(settings.Icon) 2507 </a> 2508 } 2509 </li> 2510 } 2511 2512 2513 @using Dynamicweb.Rapido.Blocks.Components.General 2514 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2515 2516 @using System.Web.Http.Results 2517 @using System.Web; 2518 @using Dynamicweb.Frontend 2519 @using Dynamicweb.Rapido.Blocks.Components 2520 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2521 @using Dynamicweb.Frontend.Devices 2522 @using Dynamicweb.Rapido.Blocks; 2523 @using Dynamicweb.Rapido.Blocks.Components.General 2524 @using System.Linq; 2525 @using Dynamicweb.Rendering 2526 2527 2528 @helper RenderSocialMediaShareIcons(DanishagroBrandingMaster.Files.Files.Templates.Designs.Rapido.Components.Custom.SocialMediaShareIcon settings) 2529 { 2530 string requestHttpHost = HttpContext.Current.Request.Url.Host + HttpContext.Current.Request.RawUrl; 2531 string facebookUrl = "https://www.facebook.com/sharer/sharer.php?u=" + requestHttpHost; 2532 string twitterUrl = "https://twitter.com/intent/tweet?url=" + requestHttpHost; 2533 string linkedinUrl = "https://www.linkedin.com/sharing/share-offsite/?url=" + requestHttpHost.Replace("=", "%3D"); 2534 string mailUrl = ""; 2535 if (string.IsNullOrEmpty(settings.MetaTitle)) 2536 { 2537 mailUrl = "mailto:?body=" + requestHttpHost; 2538 } 2539 else 2540 { 2541 mailUrl = "mailto:?subject=" + settings.MetaTitle + "&body=" + requestHttpHost; 2542 } 2543 bool facebook = settings.EnableFacebook; 2544 bool twitter = settings.EnableTwitter; 2545 bool linkedin = settings.EnableLinkedin; 2546 bool mail = settings.EnableMail; 2547 var colorSetting = settings.Color != "" && settings.Color != "0" ? settings.Color : "#3D3D3C"; 2548 var ogImage = settings.OpengraphImage; 2549 2550 if (!string.IsNullOrEmpty(ogImage)) 2551 { 2552 2553 if (settings.isExternal) 2554 { 2555 System.Web.HttpContext.Current.Items["ogImageCustom"] = ogImage; 2556 } 2557 else 2558 { 2559 System.Web.HttpContext.Current.Items["ogImageCustom"] = string.Format("{0}://{1}{2}", Dynamicweb.Context.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, ogImage); 2560 2561 } 2562 } 2563 else 2564 { 2565 string fallbackLogo = settings.CurrentPageview?.AreaSettings?.GetItem("Settings")?.GetFile("BusinessLogo")?.Path ?? ""; 2566 System.Web.HttpContext.Current.Items["ogImageCustom"] = string.Format("{0}://{1}{2}", Dynamicweb.Context.Current.Request.Url.Scheme, HttpContext.Current.Request.Url.Host, fallbackLogo); 2567 } 2568 if (!string.IsNullOrEmpty(settings.OpengraphDescription)) 2569 { 2570 2571 System.Web.HttpContext.Current.Items["ogDescriptionCustom"] = settings.OpengraphDescription; 2572 2573 } 2574 if (!string.IsNullOrEmpty(settings.OpengraphTitle)) 2575 { 2576 System.Web.HttpContext.Current.Items["ogTitleCustom"] = settings.OpengraphTitle; 2577 } 2578 2579 <div class="u-flex u-flex--row grid--justify-start" id="socialMediaShareButtonsCustom"> 2580 @if (facebook) 2581 { 2582 <a title="@settings.MetaTitle" style="color:@(colorSetting)!important" href="@facebookUrl" target="_blank" class="fab social-media-icon fa-facebook u-margin-md-custom" onmouseover="mouseOverEffect(this)" onmouseout="mouseOutEffect(this)"></a> 2583 } 2584 @if (twitter) 2585 { 2586 <a title="@settings.MetaTitle" style="color:@(colorSetting)!important" href="@twitterUrl" target="_blank" class="fab social-media-icon fa-twitter u-margin-md-custom" onmouseover="mouseOverEffect(this)" onmouseout="mouseOutEffect(this)"></a> 2587 } 2588 @if (linkedin) 2589 { 2590 <a title="@settings.MetaTitle" style="color:@(colorSetting)!important" href="@linkedinUrl" target="_blank" class="fab social-media-icon fa-linkedin-in u-margin-md-custom" onmouseover="mouseOverEffect(this)" onmouseout="mouseOutEffect(this)"></a> 2591 } 2592 @if (mail) 2593 { 2594 <a title="@settings.MetaTitle" style="color:@(colorSetting)!important" href="@mailUrl" target="_blank" class="fas social-media-icon fa-envelope u-margin-md-custom" onmouseover="mouseOverEffect(this)" onmouseout="mouseOutEffect(this)"></a> 2595 } 2596 </div> 2597 2598 <script> 2599 function mouseOverEffect(event) { 2600 event.style.opacity = "0.7"; 2601 } 2602 2603 function mouseOutEffect(event) { 2604 event.style.opacity = "1.0"; 2605 } 2606 </script> 2607 2608 2609 2610 } 2611 2612 @using Dynamicweb.Rapido.Blocks.Components 2613 @using Dynamicweb.Rapido.Blocks.Components.General 2614 @using Dynamicweb.Rapido.Blocks 2615 @using System.IO 2616 2617 2618 @using Dynamicweb.Rapido.Blocks.Components.General 2619 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2620 2621 2622 @* Component *@ 2623 2624 @helper RenderVariantMatrix(VariantMatrix settings) { 2625 if (settings != null) 2626 { 2627 int productLoopCounter = 0; 2628 int groupCount = 0; 2629 List<VariantOption> firstDimension = new List<VariantOption>(); 2630 List<VariantOption> secondDimension = new List<VariantOption>(); 2631 List<VariantOption> thirdDimension = new List<VariantOption>(); 2632 2633 foreach (VariantGroup variantGroup in settings.GetVariantGroups()) 2634 { 2635 foreach (VariantOption variantOptions in variantGroup.GetVariantOptions()) 2636 { 2637 if (groupCount == 0) { 2638 firstDimension.Add(variantOptions); 2639 } 2640 if (groupCount == 1) 2641 { 2642 secondDimension.Add(variantOptions); 2643 } 2644 if (groupCount == 2) 2645 { 2646 thirdDimension.Add(variantOptions); 2647 } 2648 } 2649 groupCount++; 2650 } 2651 2652 int rowCount = 0; 2653 int columnCount = 0; 2654 2655 <script> 2656 var variantsCollection = []; 2657 </script> 2658 2659 <table class="table table--compact js-variants-matrix dw-mod" id="VariantMatrixTable_@settings.ProductId"> 2660 @if (groupCount == 1) 2661 { 2662 <tbody> 2663 @foreach (VariantOption firstVariantOption in firstDimension) 2664 { 2665 var variantId = firstVariantOption.Id; 2666 <tr> 2667 <td class="u-bold"> 2668 @firstVariantOption.Name 2669 </td> 2670 <td> 2671 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2672 </td> 2673 </tr> 2674 productLoopCounter++; 2675 } 2676 2677 <tr> 2678 <td>&nbsp;</td> 2679 <td> 2680 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2681 </td> 2682 </tr> 2683 </tbody> 2684 } 2685 @if (groupCount == 2) 2686 { 2687 <thead> 2688 <tr> 2689 <td>&nbsp;</td> 2690 @foreach (VariantOption variant in secondDimension) 2691 { 2692 <td>@variant.Name</td> 2693 } 2694 </tr> 2695 </thead> 2696 <tbody> 2697 @foreach (VariantOption firstVariantOption in firstDimension) 2698 { 2699 string variantId = ""; 2700 columnCount = 0; 2701 2702 <tr> 2703 <td class="u-min-w120px">@firstVariantOption.Name</td> 2704 2705 @foreach (VariantOption secondVariantOption in secondDimension) 2706 { 2707 variantId = firstVariantOption.Id + "." + secondVariantOption.Id; 2708 <td> 2709 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2710 </td> 2711 2712 columnCount++; 2713 2714 productLoopCounter++; 2715 } 2716 2717 <td> 2718 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2719 </td> 2720 </tr> 2721 2722 rowCount++; 2723 } 2724 2725 @{ 2726 columnCount = 0; 2727 } 2728 2729 <tr> 2730 <td>&nbsp;</td> 2731 @foreach (VariantOption secondVariantOption in secondDimension) 2732 { 2733 <td> 2734 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2735 </td> 2736 2737 columnCount++; 2738 } 2739 <td>&nbsp;</td> 2740 </tr> 2741 </tbody> 2742 } 2743 @if (groupCount == 3) 2744 { 2745 <thead> 2746 <tr> 2747 <td>&nbsp;</td> 2748 @foreach (VariantOption thirdVariantOption in thirdDimension) 2749 { 2750 <td>@thirdVariantOption.Name</td> 2751 } 2752 </tr> 2753 </thead> 2754 <tbody> 2755 @foreach (VariantOption firstVariantOption in firstDimension) 2756 { 2757 int colspan = (thirdDimension.Count + 1); 2758 2759 <tr> 2760 <td colspan="@colspan" class="u-color-light-gray--bg u-bold">@firstVariantOption.Name</td> 2761 </tr> 2762 2763 foreach (VariantOption secondVariantOption in secondDimension) 2764 { 2765 string variantId = ""; 2766 columnCount = 0; 2767 2768 <tr> 2769 <td class="u-min-w120px">@secondVariantOption.Name</td> 2770 2771 @foreach (VariantOption thirdVariantOption in thirdDimension) 2772 { 2773 variantId = firstVariantOption.Id + "." + secondVariantOption.Id + "." + thirdVariantOption.Id; 2774 2775 <td> 2776 @RenderVariantMatrixQuantityField(variantId, settings, productLoopCounter, rowCount, columnCount) 2777 </td> 2778 2779 columnCount++; 2780 productLoopCounter++; 2781 } 2782 2783 <td> 2784 <div class="qty-field js-total-qty-row-@rowCount dw-mod">0</div> 2785 </td> 2786 </tr> 2787 rowCount++; 2788 } 2789 } 2790 2791 @{ 2792 columnCount = 0; 2793 } 2794 2795 <tr> 2796 <td>&nbsp;</td> 2797 @foreach (VariantOption thirdVariantOption in thirdDimension) 2798 { 2799 <td> 2800 <div class="qty-field js-total-qty-column-@columnCount dw-mod">0</div> 2801 </td> 2802 2803 columnCount++; 2804 } 2805 <td>&nbsp;</td> 2806 </tr> 2807 </tbody> 2808 } 2809 </table> 2810 2811 <script> 2812 document.addEventListener("DOMContentLoaded", function (event) { 2813 MatrixUpdateQuantity("@settings.ProductId"); 2814 }); 2815 2816 MatrixUpdateQuantity = function (productId) { 2817 var currentMatrix = document.getElementById("VariantMatrixTable_" + productId); 2818 var allQtyFields = currentMatrix.getElementsByClassName("js-qty"); 2819 2820 var qtyRowArr = []; 2821 var qtyColumnArr = []; 2822 2823 var totalQty = 0; 2824 2825 for (var i = 0; i < allQtyFields.length; i++) { 2826 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] = 0; 2827 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] = 0; 2828 } 2829 2830 for (var i = 0; i < allQtyFields.length; i++) { 2831 qtyRowArr[allQtyFields[i].getAttribute("data-qty-row-group")] += parseFloat(allQtyFields[i].value); 2832 qtyColumnArr[allQtyFields[i].getAttribute("data-qty-column-group")] += parseFloat(allQtyFields[i].value); 2833 totalQty += parseFloat(allQtyFields[i].value); 2834 } 2835 2836 //Update row counters 2837 for (var i = 0; i < qtyRowArr.length; i++) { 2838 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2839 2840 if (qtyRowArr[i] != undefined && qtyCounter != null) { 2841 var currentCount = qtyCounter.innerHTML; 2842 qtyCounter.innerHTML = qtyRowArr[i]; 2843 2844 if (currentCount != qtyCounter.innerHTML) { 2845 qtyCounter.classList.add("qty-field--active"); 2846 } 2847 } 2848 2849 } 2850 2851 //Update column counters 2852 for (var i = 0; i < qtyColumnArr.length; i++) { 2853 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2854 2855 if (qtyColumnArr[i] != undefined && qtyCounter != null) { 2856 var currentCount = qtyCounter.innerHTML; 2857 qtyCounter.innerHTML = qtyColumnArr[i]; 2858 2859 if (currentCount != qtyCounter.innerHTML) { 2860 qtyCounter.classList.add("qty-field--active"); 2861 } 2862 } 2863 } 2864 2865 if (document.getElementById("TotalQtyCount_" + productId)) { 2866 document.getElementById("TotalQtyCount_" + productId).innerHTML = totalQty; 2867 } 2868 2869 //Clean up animations 2870 setTimeout(function () { 2871 for (var i = 0; i < qtyRowArr.length; i++) { 2872 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-row-" + i)[0]; 2873 if (qtyCounter != null) { 2874 qtyCounter.classList.remove("qty-field--active"); 2875 } 2876 } 2877 for (var i = 0; i < qtyColumnArr.length; i++) { 2878 var qtyCounter = currentMatrix.getElementsByClassName("js-total-qty-column-" + i)[0]; 2879 if (qtyCounter != null) { 2880 qtyCounter.classList.remove("qty-field--active"); 2881 } 2882 } 2883 }, 1000); 2884 } 2885 </script> 2886 } 2887 } 2888 2889 @helper RenderVariantMatrixQuantityField(string variantId, VariantMatrix settings, int productLoopCounter, int rowCount, int columnCount) 2890 { 2891 string loopCount = productLoopCounter.ToString(); 2892 2893 bool combinationFound = false; 2894 double stock = 0; 2895 double quantityValue = 0; 2896 string note = ""; 2897 2898 VariantProduct variantProduct = null; 2899 2900 if (settings.GetVariantProducts().TryGetValue(variantId, out variantProduct)) 2901 { 2902 stock = variantProduct.Stock; 2903 quantityValue = variantProduct.Quantity; 2904 combinationFound = true; 2905 } 2906 2907 if (combinationFound) 2908 { 2909 <input type="hidden" name="ProductLoopCounter@(loopCount)" value="@loopCount" /> 2910 <input type="hidden" name="ProductID@(loopCount)" value="@settings.ProductId" /> 2911 <input type="hidden" name="VariantID@(loopCount)" value="@variantId" /> 2912 <input type="hidden" name="CurrentNote@(loopCount)" id="CurrentNote_@(settings.ProductId)_@variantId" value="@note" /> 2913 <input type="number" name="Quantity@(loopCount)" id="Quantity_@(settings.ProductId)_@variantId" value="@quantityValue" min="0" class="js-qty u-no-margin u-full-max-width" style="width: 100%; max-width: 100%" onkeyup="MatrixUpdateQuantity('@settings.ProductId')" onmouseup="MatrixUpdateQuantity('@settings.ProductId')" data-qty-row-group="@rowCount" data-qty-column-group="@columnCount"> 2914 2915 if (stock != 0) 2916 { 2917 <small>@Translate("Stock") @stock</small> 2918 } 2919 2920 <script> 2921 var variants = '{ "ProductId" :' + '"@settings.ProductId"' + ', "VariantId": ' + '"@variantId"' +'}'; 2922 variantsCollection.push(variants); 2923 document.getElementById("Quantity_@(settings.ProductId)_@variantId").closest(".js-variants-matrix").setAttribute("data-variants-collection", "[" + variantsCollection + "]" ); 2924 </script> 2925 } 2926 else 2927 { 2928 <div class="use-btn-height" style="background-color: #a8a8a8"></div> 2929 } 2930 } 2931 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2932 2933 @* Component *@ 2934 2935 @helper RenderAddToCart(AddToCart settings) 2936 { 2937 //set Id for quantity selector to get it's value from button 2938 if (settings.QuantitySelector != null) 2939 { 2940 if (string.IsNullOrEmpty(settings.QuantitySelector.Id)) 2941 { 2942 settings.QuantitySelector.Id = Guid.NewGuid().ToString("N"); 2943 } 2944 2945 settings.AddButton.QuantitySelectorId = settings.QuantitySelector.Id; 2946 2947 if (settings.Disabled) 2948 { 2949 settings.QuantitySelector.Disabled = true; 2950 } 2951 2952 if (string.IsNullOrEmpty(settings.QuantitySelector.Name)) 2953 { 2954 settings.QuantitySelector.Name = settings.QuantitySelector.Id; 2955 } 2956 } 2957 2958 if (settings.Disabled) 2959 { 2960 settings.AddButton.Disabled = true; 2961 } 2962 2963 settings.AddButton.CssClass += " btn--condensed"; 2964 2965 //unitsSelector 2966 if (settings.UnitSelector != null) 2967 { 2968 if (settings.Disabled) 2969 { 2970 settings.QuantitySelector.Disabled = true; 2971 } 2972 } 2973 2974 if (Pageview.Device.ToString() == "Mobile") { 2975 if (settings.UnitSelector != null) 2976 { 2977 <div class="margin-sm margin-position-bottom"> 2978 @Render(settings.UnitSelector) 2979 </div> 2980 } 2981 } 2982 2983 <div class="buttons-collection @settings.WrapperCssClass" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2984 @if (Pageview.Device.ToString() != "Mobile") { 2985 if (settings.UnitSelector != null) 2986 { 2987 @Render(settings.UnitSelector) 2988 } 2989 } 2990 @if (settings.QuantitySelector != null) 2991 { 2992 @Render(settings.QuantitySelector) 2993 } 2994 @Render(settings.AddButton) 2995 </div> 2996 } 2997 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 2998 2999 @* Component *@ 3000 3001 @helper RenderAddToCartButton(AddToCartButton settings) 3002 { 3003 if (!settings.HideTitle) 3004 { 3005 if (string.IsNullOrEmpty(settings.Title)) 3006 { 3007 if (settings.BuyForPoints) 3008 { 3009 settings.Title = Translate("Buy with points"); 3010 } 3011 else 3012 { 3013 settings.Title = Translate("Add to cart"); 3014 } 3015 } 3016 } 3017 else 3018 { 3019 settings.Title = ""; 3020 } 3021 3022 if (settings.Icon == null) 3023 { 3024 settings.Icon = new Icon(); 3025 settings.Icon.LabelPosition = Dynamicweb.Rapido.Blocks.Components.General.IconLabelPosition.After; 3026 } 3027 3028 if (string.IsNullOrEmpty(settings.Icon.Name)) 3029 { 3030 settings.Icon.Name = Pageview.AreaSettings.GetItem("Layout").GetItem("Icons").GetList("CartIcon").SelectedValue; 3031 } 3032 3033 settings.OnClick = "Cart.AddToCart(event, { " + 3034 "id: '" + settings.ProductId + "'," + 3035 (!string.IsNullOrEmpty(settings.VariantId) ? "variantId: '" + settings.VariantId + "'," : "") + 3036 (!string.IsNullOrEmpty(settings.UnitId) ? "unitId: '" + settings.UnitId + "'," : "") + 3037 (settings.BuyForPoints ? "buyForPoints: true," : "") + 3038 (!string.IsNullOrEmpty(settings.ProductInfo) ? "productInfo: " + settings.ProductInfo + "," : "") + 3039 "quantity: " + (string.IsNullOrEmpty(settings.QuantitySelectorId) ? "1" : "parseFloat(document.getElementById('" + settings.QuantitySelectorId + "').value)") + 3040 "});" + settings.OnClick; 3041 3042 @RenderButton(settings) 3043 } 3044 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3045 3046 @* Component *@ 3047 3048 @helper RenderUnitSelector(UnitSelector settings) 3049 { 3050 if (string.IsNullOrEmpty(settings.Id)) 3051 { 3052 settings.Id = Guid.NewGuid().ToString("N"); 3053 } 3054 var disabledClass = settings.Disabled ? "disabled" : ""; 3055 3056 <input type="checkbox" id="@settings.Id" class="dropdown-trigger" /> 3057 <div class="dropdown unit-selector @settings.CssClass @disabledClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 3058 <label class="dropdown__header dropdown__btn dropdown__btn--unit-selector dw-mod" for="@settings.Id">@settings.SelectedOption</label> 3059 <div class="dropdown__content dw-mod"> 3060 @settings.OptionsContent 3061 </div> 3062 <label class="dropdown-trigger-off" for="@settings.Id"></label> 3063 </div> 3064 } 3065 @using System.Reflection 3066 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3067 3068 @* Component *@ 3069 3070 @helper RenderQuantitySelector(QuantitySelector settings) 3071 { 3072 var attributes = new Dictionary<string, string>(); 3073 3074 /*base settings*/ 3075 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 3076 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 3077 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 3078 if (settings.Disabled) { attributes.Add("disabled", "true"); } 3079 if (settings.Required) { attributes.Add("required", "true"); } 3080 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 3081 /*end*/ 3082 3083 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 3084 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 3085 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 3086 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 3087 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 3088 if (settings.Min == null) { settings.Min = 1; } 3089 attributes.Add("min", settings.Min.ToString()); 3090 if (settings.Step != null && !string.IsNullOrEmpty(settings.Step.ToString())) { attributes.Add("step", settings.Step.ToString()); } 3091 if (settings.Value == null) { settings.Value = 1; } 3092 attributes.Add("value", settings.Value.ToString()); 3093 attributes.Add("type", "number"); 3094 3095 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 3096 3097 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 3098 } 3099 @using Dynamicweb.Rapido.Blocks.Components 3100 3101 @using Dynamicweb.Frontend 3102 @using Dynamicweb.Frontend.Devices 3103 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 3104 @using Dynamicweb.Rapido.Blocks.Components.General 3105 @using System.Collections.Generic; 3106 3107 @* Component *@ 3108 3109 @helper RenderCustomerCenterList(CustomerCenterList settings) 3110 { 3111 bool isTouchDevice = Pageview.Device.ToString() == "Mobile" || Pageview.Device.ToString() == "Tablet" ? true : false; 3112 string hideActions = isTouchDevice ? "u-block" : ""; 3113 3114 <table class="table data-list dw-mod"> 3115 @if (settings.GetHeaders().Length > 0) { 3116 <thead> 3117 <tr class="u-bold"> 3118 @foreach (CustomerCenterListHeaderItem header in settings.GetHeaders()) 3119 { 3120 var attributes = new Dictionary<string, string>(); 3121 if (!string.IsNullOrEmpty(header.Id)) { attributes.Add("id", header.Id); } 3122 if (!string.IsNullOrEmpty(header.CssClass)) { attributes.Add("class", header.CssClass); } 3123 attributes.Add("align", header.Align.ToString()); 3124 attributes = attributes.Concat(header.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 3125 3126 <td @ComponentMethods.AddAttributes(attributes)>@header.Title</td> 3127 } 3128 </tr> 3129 </thead> 3130 } 3131 @foreach (CustomerCenterListItem listItem in settings.GetItems()) 3132 { 3133 int columnCount = 0; 3134 int totalColumns = listItem.GetInfoItems().Length; 3135 string rowHasActions = listItem.GetActions().Length > 0 ? "data-list__item--has-actions" : ""; 3136 listItem.Id = !string.IsNullOrEmpty(listItem.Id) ? listItem.Id : Guid.NewGuid().ToString("N"); 3137 3138 var attributes = new Dictionary<string, string>(); 3139 if (!string.IsNullOrEmpty(listItem.Title)) { attributes.Add("title", listItem.Title); }; 3140 3141 attributes = attributes.Concat(listItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 3142 <tbody class="data-list__item @rowHasActions @listItem.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes)> 3143 <tr> 3144 @if (!string.IsNullOrEmpty(listItem.Title) || !string.IsNullOrEmpty(listItem.Description)) { 3145 string onClick = !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 3146 3147 <td rowspan="2" @onClick class="data-list__main-item dw-mod"> 3148 @if (!string.IsNullOrEmpty(listItem.Title)) { 3149 <div class="u-bold">@listItem.Title</div> 3150 } 3151 @if (!string.IsNullOrEmpty(listItem.Description)) { 3152 <div>@listItem.Description</div> 3153 } 3154 </td> 3155 } 3156 3157 @foreach (CustomerCenterListInfoItem infoItem in listItem.GetInfoItems()) 3158 { 3159 var infoAttributes = new Dictionary<string, string>(); 3160 if (!string.IsNullOrEmpty(infoItem.Id)) { infoAttributes.Add("id", infoItem.Id); }; 3161 if (!string.IsNullOrEmpty(infoItem.OnClick)) { infoAttributes.Add("onclick", infoItem.OnClick); }; 3162 infoAttributes.Add("align", infoItem.Align.ToString()); 3163 3164 infoAttributes = infoAttributes.Concat(infoItem.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 3165 string columnClick = columnCount < (totalColumns-1) && !string.IsNullOrEmpty(listItem.OnClick) ? "onclick=\"" + listItem.OnClick + "\"" : ""; 3166 3167 <td @ComponentMethods.AddAttributes(infoAttributes) @columnClick class="data-list__info-item dw-mod"> 3168 @if (!string.IsNullOrEmpty(infoItem.Title)) { 3169 <div>@infoItem.Title</div> 3170 } 3171 @if (!string.IsNullOrEmpty(infoItem.Subtitle)) { 3172 <div><small>@infoItem.Subtitle</small></div> 3173 } 3174 </td> 3175 3176 columnCount++; 3177 } 3178 </tr> 3179 <tr> 3180 <td colspan="7" align="right" class="u-va-bottom u-no-border"> 3181 <div class="data-list__actions @hideActions dw-mod" id="ActionsMenu_@listItem.Id"> 3182 @foreach (ButtonBase action in listItem.GetActions()) 3183 { 3184 action.ButtonLayout = ButtonLayout.LinkClean; 3185 action.Icon.CssClass += " u-full-height"; 3186 action.CssClass += " data-list__action-button link"; 3187 3188 @Render(action) 3189 } 3190 </div> 3191 </td> 3192 </tr> 3193 </tbody> 3194 } 3195 </table> 3196 } 3197 3198 3199 3200 3201 3202