Error executing template "/Designs/Rapido/Paragraph/PIMFiles.cshtml"
System.ArgumentException: The requested block ID can not be found
Parameter name: TopNavigation
   at Dynamicweb.Rapido.Blocks.BlocksPage.GetBlockListById(String childId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_f327af8279e04b4ea15da649634ecf33.Execute() in D:\Dynamicweb.net\Solutions\FlexMedia\granzow.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\Paragraph\PIMFiles.cshtml:line 383
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Frontend.Devices 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using System 7 @using System.IO 8 @using System.Web 9 @using System.Collections.Generic; 10 @using System.Linq 11 @using System.Text.RegularExpressions 12 @using Dynamicweb.Rapido.Blocks 13 @using Dynamicweb.Rapido.Blocks.Components.General 14 15 @functions { 16 BlocksPage filesPage = BlocksPage.GetBlockPage("FilesList"); 17 } 18 19 @{ 20 Block pageContainer = new Block() 21 { 22 Id = "PageContainer", 23 Template = RenderPageContainer(), 24 SortId = 20 25 }; 26 27 filesPage.Add(pageContainer); 28 29 30 Block filesScript = new Block() 31 { 32 Id = "ScriptTemplates", 33 SortId = 30, 34 BlocksList = new List<Block> 35 { 36 new Block() 37 { 38 Id = "FilesContainerScript", 39 SortId = 10, 40 Template = RenderFilesContainerScript(), 41 SkipRenderBlocksList = true, 42 BlocksList = new List<Block> { 43 new Block() 44 { 45 Id = "LeftNavigation", 46 SortId = 10, 47 Design = new Design 48 { 49 RenderType = RenderType.Column, 50 Size = "3" 51 } 52 }, 53 new Block() 54 { 55 Id = "FilesList", 56 SortId = 20, 57 Design = new Design 58 { 59 RenderType = RenderType.Column, 60 Size = "auto" 61 }, 62 BlocksList = new List<Block> { 63 new Block() 64 { 65 Id = "Top", 66 SortId = 10 67 }, 68 new Block() 69 { 70 Id = "Files", 71 SortId = 20, 72 Template = RenderFiles() 73 }, 74 new Block() 75 { 76 Id = "LoadMoreRow", 77 SortId = 30, 78 Design = new Design 79 { 80 RenderType = RenderType.Row 81 }, 82 BlocksList = new List<Block> 83 { 84 new Block() 85 { 86 Id = "LoadMore", 87 SortId = 10, 88 Design = new Design 89 { 90 RenderType = RenderType.Column, 91 Size = "12" 92 }, 93 Template = RenderLoadMore() 94 } 95 } 96 } 97 } 98 } 99 } 100 }, 101 new Block() 102 { 103 Id = "preRenderTemplate", 104 Template = RenderPreRenderTemplate() 105 }, 106 new Block() 107 { 108 Id = "PIMJavascript", 109 Template = RenderJavascript() 110 } 111 } 112 }; 113 114 filesPage.Add(filesScript); 115 } 116 117 @using Dynamicweb.Rapido.Blocks; 118 @using Dynamicweb.Rapido.Blocks.Components.General; 119 120 @functions { 121 BlocksPage downloadModalPage = BlocksPage.GetBlockPage("FilesList"); 122 } 123 124 @{ 125 Block downloadModal = new Block() 126 { 127 Id = "DownloadModal", 128 Component = new Modal 129 { 130 Id = "Download", 131 Width = ModalWidth.Sm, 132 Heading = new Heading { Title = Translate("Download"), Level = 2 }, 133 BodyTemplate = RenderDownloadModal() 134 } 135 }; 136 137 downloadModalPage.Add(downloadModal); 138 139 } 140 141 @helper RenderDownloadModal() 142 { 143 int exportPageId = GetPageIdByNavigationTag("PIMAssetExport"); 144 145 Form downloadForm = new Form 146 { 147 Action = "/Default.aspx?ID=" + exportPageId, 148 Method = FormMethod.Post, 149 CssClass = "u-no-margin" 150 }; 151 152 downloadForm.Add(new HiddenField { Id = "assetPath", Name = "assetPath" }); 153 downloadForm.Add(new HiddenField { Id = "siteUrl", Name = "siteUrl", Value = string.Format("{0}://{1}", GetGlobalValue("Global:Request.Scheme"), GetGlobalValue("Global:Request.Host")) }); 154 155 SelectField purposeSelect = new SelectField 156 { 157 Id = "purpose", 158 Name = "purpose", 159 Label = Translate("Purpose"), 160 CssClass = "u-full-width", 161 Options = new List<SelectFieldOption> { 162 new SelectFieldOption { 163 Value = "Office", 164 Label = Translate("Office") 165 }, 166 new SelectFieldOption { 167 Value = "Original", 168 Label = Translate("Original") 169 }, 170 new SelectFieldOption { 171 Value = "Print", 172 Label = Translate("Print") 173 }, 174 new SelectFieldOption { 175 Value = "Web", 176 Label = Translate("Web") 177 } 178 } 179 }; 180 downloadForm.Add(purposeSelect); 181 downloadForm.Add(new Button { ButtonType = ButtonType.Submit, Title = Translate("Export asset"), CssClass = "u-pull--right" }); 182 183 @Render(downloadForm) 184 } 185 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 186 @using Dynamicweb.Rapido.Blocks 187 @using Dynamicweb.Rapido.Blocks.Components.General 188 189 @functions { 190 BlocksPage imageModalPage = BlocksPage.GetBlockPage("FilesList"); 191 } 192 193 @{ 194 Block imageModal = new Block() 195 { 196 Id = "ImageModal", 197 Template = RenderImageModal() 198 }; 199 200 imageModalPage.Add(imageModal); 201 202 Block imageModalTemplates = new Block() 203 { 204 Id = "imageModalTemplates", 205 Template = RenderImageModalTemplates() 206 }; 207 208 imageModalPage.Add("ScriptTemplates", imageModalTemplates); 209 210 Block imageModalScripts = new Block() 211 { 212 Id = "imageModalScripts", 213 Template = RenderImageModalScripts() 214 }; 215 216 imageModalPage.Add("ScriptTemplates", imageModalScripts); 217 } 218 219 @helper RenderImageModal() 220 { 221 <!-- Trigger for the gallery modal --> 222 <input type="checkbox" id="PreviewModalTrigger" class="modal-trigger" /> 223 224 <!-- Gallery modal --> 225 <div class="modal-container"> 226 <label for="PreviewModalTrigger" id="PreviewModalOverlay" class="modal-overlay"></label> 227 <div class="modal modal--full-width" id="PreviewModal"> 228 <div class="modal__body modal__body--file-preview"> 229 <div class="grid"> 230 <div class="grid__col-md-6 grid--align-center"> 231 @Render(new Image { Id = "PreviewImage", CssClass = "js-gallery-image modal__image--file-preview", DisableLazyLoad = true, Path = "" }) 232 </div> 233 <div class="grid__col-md-6"> 234 <div id="ImageMetadataContainer" data-template="FileInformationTemplate"></div> 235 </div> 236 </div> 237 <label class="modal__close-btn" for="PreviewModalTrigger"></label> 238 </div> 239 </div> 240 </div> 241 } 242 243 @helper RenderImageModalTemplates() 244 { 245 <script id="ImageMetadataItemTemplate" type="text/x-template"> 246 {{#.}} 247 <tr> 248 <th>{{Key}}</th> 249 <td class="u-ta-left"><span id="Value">{{Value}}</span></td> 250 </tr> 251 {{/.}} 252 </script> 253 254 <script id="FileInformationTemplate" type="text/x-template"> 255 <div class="tabs dw-mod"> 256 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="FileInformation" checked=""> 257 {{#if IPTC.length}} 258 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="IPTC"> 259 {{/if}} 260 {{#if XMP.length}} 261 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="XMP"> 262 {{/if}} 263 {{#if EXIF.length}} 264 <input type="radio" class="tabs__trigger" name="imageInfoTabs" id="EXIF"> 265 {{/if}} 266 <div class="tabs__list dw-mod"> 267 <label for="FileInformation" class="tabs__label dw-mod">File information</label> 268 {{#if IPTC.length}} 269 <label for="IPTC" class="tabs__label dw-mod">IPTC</label> 270 {{/if}} 271 {{#if XMP.length}} 272 <label for="XMP" class="tabs__label dw-mod">XMP</label> 273 {{/if}} 274 {{#if EXIF.length}} 275 <label for="EXIF" class="tabs__label dw-mod">EXIF</label> 276 {{/if}} 277 </div> 278 279 <div class="tabs__blocks dw-mod"> 280 <div class="tabs__block dw-mod" data-title="File information"> 281 <div class="u-padding u-border-top"> 282 <table class="table table--clean table--compact"> 283 {{#ImageData}} 284 {{>ImageMetadataItemTemplate}} 285 {{/ImageData}} 286 </table> 287 288 {{#if DynamicwebMetadata.length}} 289 <h3>Custom metadata (Dynamicweb metadata)</h3> 290 <table class="table table--clean table--compact"> 291 {{#DynamicwebMetadata}} 292 {{>ImageMetadataItemTemplate}} 293 {{/DynamicwebMetadata}} 294 </table> 295 {{/if}} 296 </div> 297 </div> 298 {{#if IPTC.length}} 299 <div class="tabs__block dw-mod" data-title="IPTC"> 300 <div class="u-padding u-border-top"> 301 <table class="table table--clean table--compact"> 302 {{#IPTC}} 303 {{>ImageMetadataItemTemplate}} 304 {{/IPTC}} 305 </table> 306 </div> 307 </div> 308 {{/if}} 309 {{#if XMP.length}} 310 <div class="tabs__block dw-mod" data-title="XMP"> 311 <div class="u-padding u-border-top"> 312 <table class="table table--clean table--compact"> 313 {{#XMP}} 314 {{>ImageMetadataItemTemplate}} 315 {{/XMP}} 316 </table> 317 </div> 318 </div> 319 {{/if}} 320 {{#if EXIF.length}} 321 <div class="tabs__block dw-mod" data-title="EXIF"> 322 <div class="u-padding u-border-top"> 323 <table class="table table--clean table--compact"> 324 {{#EXIF}} 325 {{>ImageMetadataItemTemplate}} 326 {{/EXIF}} 327 </table> 328 </div> 329 </div> 330 {{/if}} 331 </div> 332 </div> 333 </script> 334 } 335 336 @helper RenderImageModalScripts() 337 { 338 <script> 339 function getPreview(fileId) { 340 let file = handlebarsBoltCache.Files.find((file) => (file.id == fileId)); 341 var previewImage = document.getElementById("PreviewImage"); 342 previewImage.classList.remove('u-w220px'); 343 if (file.icon) { 344 previewImage.src = file.icon; 345 previewImage.classList.add('u-w220px'); 346 } else { 347 previewImage.src = "/Admin/Public/GetImage.ashx?Width=900&Compression=75&image=/" + file.path; 348 } 349 previewImage.alt = file.name; 350 HandlebarsBolt.CreateItemsFromJson(JSON.parse(file.fileInfo), 'ImageMetadataContainer'); 351 } 352 </script> 353 } 354 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 355 @using Dynamicweb.Rapido.Blocks 356 @using Dynamicweb.Rapido.Blocks.Components.General 357 358 @functions { 359 BlocksPage facetsPage = BlocksPage.GetBlockPage("FilesList"); 360 } 361 362 @{ 363 string facetsBlockViewMode = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode")) ? Pageview.AreaSettings.GetItem("ProductList").GetString("FacetsViewMode").ToLower() : "left"; 364 365 Block leftFacets = new Block() 366 { 367 Id = "LeftFacets", 368 Template = RenderLeftFacets() 369 }; 370 371 Block topFacets = new Block() 372 { 373 Id = "TopFacets", 374 Template = RenderTopFacets() 375 }; 376 377 if (facetsBlockViewMode == "left") 378 { 379 facetsPage.GetBlockListById("LeftNavigation").Add(leftFacets); 380 } 381 else 382 { 383 facetsPage.GetBlockListById("TopNavigation").Add(topFacets); 384 } 385 386 Block facetSelection = new Block() 387 { 388 Id = "FacetSelection", 389 Template = RenderFacetSelection() 390 }; 391 392 facetsPage.GetBlockListById("Top").Add(facetSelection); 393 394 Block facetSelectionTemplates = new Block() 395 { 396 Id = "FacetSelectionTemplates", 397 Template = RenderFacetSelectionTemplates() 398 }; 399 400 facetSelection.SortId = 30; 401 facetsPage.Add("ScriptTemplates", facetSelectionTemplates); 402 } 403 404 @helper RenderLeftFacets() 405 { 406 <div class="u-margin-bottom--lg"> 407 @Render(new Heading { Level = 2, Title = Translate("Filters"), CssClass = "u-no-margin" }) 408 </div> 409 410 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 411 <div class="facets-container facets-container--left expandable--collapsed dw-mod" data-trigger="CheckFacetGroups"> 412 {{#FacetGroups}} 413 <input type="checkbox" id="OptionsGroup_{{name}}" class="expand-trigger js-remember-state" {{defaultState}} /> 414 415 <div class="expand-container facets-container__box dw-mod js-filter"> 416 <label class="expand-container__btn facets-container__header dw-mod" for="OptionsGroup_{{name}}">{{name}}</label> 417 <div class="expand-container__content dw-mod"> 418 <div class="u-margin {{showFilter}}"> 419 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 420 </div> 421 <div class="facets-container__list dw-mod"> 422 {{#FacetOptions}} 423 {{#ifCond template "===" "Checkboxes"}} 424 {{>Checkboxes}} 425 {{/ifCond}} 426 {{#ifCond template "===" "Range"}} 427 {{>Checkboxes}} 428 {{/ifCond}} 429 {{#ifCond template "===" "Weight"}} 430 {{>Checkboxes}} 431 {{/ifCond}} 432 {{#ifCond template "===" "Tags"}} 433 {{>Tags}} 434 {{/ifCond}} 435 {{#ifCond template "===" "Colors"}} 436 {{>Colors}} 437 {{/ifCond}} 438 {{/FacetOptions}} 439 <div class="u-hidden js-filter-not-found"> 440 @Translate("Your search gave 0 results") 441 </div> 442 </div> 443 </div> 444 </div> 445 {{/FacetGroups}} 446 </div> 447 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 448 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 449 } 450 451 @helper RenderTopFacets() 452 { 453 <input type="checkbox" id="CheckFacetGroups" class="js-remember-state u-hidden" data-expand="CheckFacetGroups" /> 454 <div class="grid grid--external-bleed-x dw-mod expandable--collapsed facets-container facets-container--top" data-trigger="CheckFacetGroups"> 455 {{#FacetGroups}} 456 <div class="grid__col-lg-3 grid__col-md-3 grid__col-sm-4 grid__col-xs-12"> 457 <input type="checkbox" id="OptionsGroup_{{counter}}" class="dropdown-trigger" /> 458 <div class="dropdown dw-mod js-filter"> 459 <label class="dropdown__header dropdown__btn dw-mod" for="OptionsGroup_{{counter}}">{{name}}</label> 460 <div class="dropdown__content dropdown__content--padding dw-mod"> 461 <div class="u-margin-bottom {{showFilter}}"> 462 <input type="text" class="u-full-width u-no-margin" onkeyup="Filter.FilterItems(event)" placeholder="@Translate("Search")" /> 463 </div> 464 {{#FacetOptions}} 465 {{#ifCond template "===" "Checkboxes"}} 466 {{>Checkboxes}} 467 {{/ifCond}} 468 {{#ifCond template "===" "Range"}} 469 {{>Checkboxes}} 470 {{/ifCond}} 471 {{#ifCond template "===" "Weight"}} 472 {{>Checkboxes}} 473 {{/ifCond}} 474 {{#ifCond template "===" "Tags"}} 475 {{>Tags}} 476 {{/ifCond}} 477 {{#ifCond template "===" "Colors"}} 478 {{>Colors}} 479 {{/ifCond}} 480 {{/FacetOptions}} 481 <div class="u-hidden js-filter-not-found"> 482 @Translate("Your search gave 0 results") 483 </div> 484 </div> 485 <label class="dropdown-trigger-off" for="OptionsGroup_{{counter}}"></label> 486 </div> 487 </div> 488 {{/FacetGroups}} 489 </div> 490 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod js-expand-hide facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Select filters")</label> 491 <label for="CheckFacetGroups" class="btn btn--primary btn--full dw-mod expandable--collapsed facets-container-trigger" data-trigger="CheckFacetGroups">@Translate("Close filters")</label> 492 } 493 494 @helper RenderFacetSelection() 495 { 496 <text> 497 {{#if FacetSelections}} 498 <div class="buttons-collection u-margin-bottom" id="selectedFacets"> 499 {{#FacetSelections}} 500 {{>(lookup . 'template')}} 501 {{/FacetSelections}} 502 </div> 503 {{/if}} 504 </text> 505 } 506 507 @helper RenderFacetSelectionTemplates() 508 { 509 @*Facets*@ 510 <script id="Checkboxes" type="text/x-template"> 511 <input type="checkbox" class="{{selected}} checkbox-facet__checkbox form__control dw-mod" onclick="Facets.UpdateFacets(this);" id="{{queryParameter}}{{value}}" name="{{queryParameter}}" value="[{{value}}]" {{selected}} {{disabled}}> 512 <label class="{{disabled}} checkbox-facet dw-mod" data-filter-value="{{label}}" for="{{queryParameter}}{{value}}"> 513 <span class="checkbox-facet__label dw-mod">{{label}}</span> 514 <span class="checkbox-facet__count dw-mod">({{count}})</span> 515 </label> 516 </script> 517 518 <script id="Tags" type="text/x-template"> 519 <button type="button" class="btn btn--tag {{selected}} {{disabled}}" data-filter-value="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}> 520 {{label}} <span class="facets-group__counter">({{count}})</span> 521 </button> 522 </script> 523 524 <script id="Colors" type="text/x-template"> 525 <button type="button" class="btn btn--colorbox u-margin-right {{selected}} {{disabled}}" data-filter-value="{{label}}" style="background-color: {{value}}" title="{{label}}" data-check="{{selected}}" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" {{disabled}}></button> 526 </script> 527 528 @*Facet selections*@ 529 <script id="SelectedFilter" type="text/x-template"> 530 <button type="button" class="btn btn--tag" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 531 {{group}}: {{label}} <i class="fas fa-times"></i> 532 </button> 533 </script> 534 535 <script id="SelectedColorFilter" type="text/x-template"> 536 <button type="button" class="btn btn--tag" data-check="checked" onclick="Facets.UpdateFacets(this);" name="{{queryParameter}}" value="[{{value}}]" title="@Translate("Remove filter")"> 537 {{group}}: <div class="btn__colorbox" style="background-color: {{label}}"></div> <i class="fas fa-times"></i> 538 </button> 539 </script> 540 541 <script id="ResetFilters" type="text/x-template"> 542 <button type="button" class="btn btn--tag" onclick="Facets.ResetFacets();"> 543 @Translate("Reset all filters") <i class="fas fa-redo"></i> 544 </button> 545 </script> 546 } 547 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 548 @using Dynamicweb.Rapido.Blocks 549 @using Dynamicweb.Rapido.Blocks.Components.General 550 551 @functions { 552 553 BlocksPage topNavigationPage = BlocksPage.GetBlockPage("FilesList"); 554 } 555 556 @{ 557 Block topNavigation = new Block() 558 { 559 Id = "TopNavigation", 560 SortId = 10, 561 Template = RenderTopNavigation() 562 }; 563 564 topNavigationPage.GetBlockListById("Top").Add(topNavigation); 565 566 Block listViewSelectListener = new Block() 567 { 568 Id = "ListViewSelectListener", 569 Template = RenderListViewSelectListener() 570 }; 571 572 topNavigationPage.Add("ScriptTemplates", listViewSelectListener); 573 574 Block searchTemplates = new Block() 575 { 576 Id = "SearchTemplates", 577 Template = RenderSearchTemplates() 578 }; 579 580 topNavigationPage.Add("ScriptTemplates", searchTemplates); 581 } 582 583 @helper RenderTopNavigation() 584 { 585 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 586 587 <div class="grid__cell"> 588 <div class="u-pull--left"> 589 <div class="u-margin-bottom--lg"> 590 @Render(new Heading { Level = 2, Title = Translate("Files found") + ": {{filesCount}}", CssClass = "u-no-margin" }) 591 </div> 592 </div> 593 <div class="grid__col--bleed grid__col-6 u-pull--right"> 594 <div class="grid__cell"> 595 <div class="collection u-no-margin u-pull--right"> 596 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileItemContainer" name="ViewBtnGroup"> 597 <label for="ListViewBtn_FileItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileItemContainer')"><i class="fas fa-th-list"></i></label> 598 599 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileGridItemContainer" name="ViewBtnGroup"> 600 <label for="ListViewBtn_FileGridItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileGridItemContainer')"><i class="fas fa-th"></i></label> 601 602 <input type="radio" class="tag-btn-trigger" id="ListViewBtn_FileDetailsItemContainer" name="ViewBtnGroup"> 603 <label for="ListViewBtn_FileDetailsItemContainer" class="btn btn--tag btn--sm u-no-margin" onclick="HandlebarsBolt.UpdateTemplate('Files', 'FileDetailsItemContainer')"><i class="fas fa-list"></i></label> 604 </div> 605 @RenderSearch() 606 </div> 607 </div> 608 </div> 609 } 610 611 @helper RenderSearch() 612 { 613 int filesFeedPageId = GetPageIdByNavigationTag("FilesFeed"); 614 string filesSearchPageId = filesFeedPageId + "&LayoutTemplate=Json.cshtml&DisableStatistics=True"; 615 string filesPageId = GetGlobalValue("Global:Page.ID"); 616 string searchPlaceholder = Translate("Search files"); 617 string searchValue = HttpContext.Current.Request.QueryString.Get("Search") ?? ""; 618 619 <div class="typeahead u-color-inherit js-typeahead u-margin-bottom u-pull--right u-w220px u-margin-right" data-page-size="10" id="FilesSearch" data-search-feed-id="@filesSearchPageId" data-result-page-id="@filesPageId"> 620 <input type="text" class="typeahead-search-field u-no-margin u-full-width js-typeahead-search-field" placeholder="@searchPlaceholder" value="@searchValue"> 621 <ul class="dropdown dropdown--absolute-position u-full-width js-handlebars-root js-typeahead-search-content u-min-w220px u-full-width dw-mod" id="FilesSearchContent" data-template="SearchContentTemplate" data-json-feed="/Default.aspx?ID=@filesSearchPageId" data-init-onload="false" data-preloader="minimal"></ul> 622 <button type="button" class="btn btn--condensed btn--primary u-no-margin dw-mod js-typeahead-enter-btn"><i class="fas fa-search"></i></button> 623 </div> 624 } 625 626 @helper RenderSearchTemplates() 627 { 628 @* Templates for Typeahead *@ 629 <script id="SearchGroupsTemplate" type="text/x-template"> 630 {{#.}} 631 <li class="dropdown__item dw-mod" onclick="Search.UpdateGroupSelection(this)" data-group-id="{{id}}">{{name}}</li> 632 {{/.}} 633 </script> 634 635 <script id="SearchContentTemplate" type="text/x-template"> 636 {{#.}} 637 {{#ifCond template "!==" "SearchMore"}} 638 <li class="dropdown__item dw-mod"> 639 <div onclick="getPreview('{{id}}'); document.getElementById('PreviewModalTrigger').checked=true"> 640 <div class="u-margin-right u-pull--left u-hidden-xs u-hidden-xxs"> 641 <img src="/Admin/Public/GetImage.ashx?width=45&height=38&crop=1&Compression=75&image={{path}}" alt="{{name}}"> 642 </div> 643 <div class="u-pull--left"> 644 <div class="u-bold u-max-w220px u-truncate-text js-typeahead-name">{{name}}</div> 645 <div class="item-number u-max-w300px dw-mod">{{path}}</div> 646 </div> 647 </div> 648 <div class="u-margin-left u-pull--right"> 649 <button type="button" class="btn btn--primary btn--condensed u-pull--right dw-mod u-no-margin js-ignore-click-outside" 650 onclick="addFileToDownloads('{{path}}');"> 651 <i class="fas fa-upload"></i> 652 </button> 653 </div> 654 </li> 655 {{/ifCond}} 656 {{#ifCond template "===" "SearchMore"}} 657 {{>SearchMore}} 658 {{/ifCond}} 659 {{/.}} 660 {{^.}} 661 <li class="dropdown__item dropdown__item--seperator dropdown__item--not-selectable js-no-result dw-mod"> 662 @Translate("Your search gave 0 results") 663 </li> 664 {{/.}} 665 </script> 666 667 <script id="SearchMore" type="text/x-template"> 668 <li class="dropdown__item dropdown__item--not-selectable dw-mod"> 669 <a href="/Default.aspx?ID=@GetGlobalValue("Global:Page.ID")&Search={{searchParameter}}" class="btn btn--primary btn--full u-no-margin dw-mod js-typeahead-link"> 670 @Translate("View all") 671 </a> 672 </li> 673 </script> 674 675 <script id="SearchEmpty" type="text/x-template"> 676 <li class="u-margin u-padding-left"> 677 @Translate("Your search gave 0 results") 678 </li> 679 </script> 680 } 681 682 @helper RenderListViewSelectListener() 683 { 684 <script> 685 let defaultTemplate = 'FileItemContainer'; 686 let container = 'FilesListContainer'; 687 let cookieName = 'FilesTemplate'; 688 689 document.addEventListener('DOMContentLoaded', function (event) { 690 document.getElementById(container).addEventListener('contentLoaded', function () { 691 let selectedMode = RememberState.GetCookie(cookieName); 692 let element = document.getElementById('ListViewBtn_' + (selectedMode != null ? selectedMode : defaultTemplate)); 693 if (element != null) { 694 element.checked = true; 695 } 696 }, false); 697 }); 698 </script> 699 } 700 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 701 @using Dynamicweb.Rapido.Blocks 702 @using Dynamicweb.Rapido.Blocks.Components.General 703 704 @functions { 705 BlocksPage viewGridPage = BlocksPage.GetBlockPage("FilesList"); 706 } 707 708 @{ 709 Block gridViewTemplate = new Block() 710 { 711 Id = "GridViewTemplate", 712 Template = RenderGridViewTemplate() 713 }; 714 715 viewGridPage.Add("ScriptTemplates", gridViewTemplate); 716 } 717 718 @helper RenderGridViewTemplate() 719 { 720 @* Grid view *@ 721 <script id="FileGridItemContainer" type="text/x-template"> 722 {{#.}} 723 <div id="File{{id}}" class="grid__col-lg-4 grid__col-md-4 grid__col-sm-4 grid__col-xs-6 product-list__grid-item dw-mod"> 724 <div class="grid__cell product-list__grid-item__image dw-mod"> 725 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')" {{#if icon}}class="u-padding--lg"{{/if}}> 726 {{#if icon}} 727 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding--lg" }) 728 {{else}} 729 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding", ImageDefault = new ImageSettings { Width = 300, Height = 300, Crop = 5, FillCanvas = true } }) 730 {{/if}} 731 </label> 732 </div> 733 734 <div class="grid__cell product-list__grid-item__price-info dw-mod"> 735 <h6 class="u-condensed-text"> 736 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 737 </h6> 738 <div class="item-number u-margin-bottom dw-mod">{{path}}</div> 739 </div> 740 741 @if (Pageview.User != null) 742 { 743 <div class="product-list__grid-item__footer dw-mod"> 744 @Render(new Button 745 { 746 ButtonType = ButtonType.Button, 747 ButtonLayout = ButtonLayout.Primary, 748 OnClick = "addFileToDownloads('{{path}}');", 749 CssClass = "u-no-margin btn--condensed u-no-margin u-pull--right", 750 Icon = new Icon 751 { 752 Prefix = "fas", 753 Name = "fa-download", 754 LabelPosition = IconLabelPosition.After 755 } 756 }) 757 </div> 758 } 759 </div> 760 {{/.}} 761 </script> 762 } 763 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 764 @using Dynamicweb.Rapido.Blocks 765 @using Dynamicweb.Rapido.Blocks.Components.General 766 767 @functions { 768 BlocksPage viewDetailsPage = BlocksPage.GetBlockPage("FilesList"); 769 } 770 771 @{ 772 Block detailsViewTemplate = new Block() 773 { 774 Id = "DetailsViewTemplate", 775 Template = RenderDetailsViewTemplate() 776 }; 777 778 viewDetailsPage.Add("ScriptTemplates", detailsViewTemplate); 779 } 780 781 @helper RenderDetailsViewTemplate() 782 { 783 @* Details view *@ 784 785 <script id="FileDetailsItemContainer" type="text/x-template"> 786 {{#.}} 787 <div id="File{{id}}" class="grid__col-12 u-no-padding-y"> 788 <div class="product-list__details-item grid__col-12 grid--direction-row grid--align-center dw-mod"> 789 <div class="product-list__details-item__left grid__cell dw-mod"> 790 791 <div class="lightbox u-hidden-xxs"> 792 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')"> 793 {{#if icon}} 794 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "u-w50px u-margin-right" }) 795 {{else}} 796 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "lightbox__image", ImageDefault = new ImageSettings { Width = 220, Height = 222, Crop = 5, FillCanvas = true }, DisableLazyLoad = true }) 797 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "u-margin-right", ImageDefault = new ImageSettings { Width = 50, Height = 50, Crop = 5, FillCanvas = true } }) 798 {{/if}} 799 </label> 800 </div> 801 802 <div class="u-margin-left u-margin-right"> 803 <h6 class="u-no-margin"> 804 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 805 </h6> 806 <div class="item-number dw-mod">{{path}}</div> 807 </div> 808 </div> 809 <div class="product-list__details-item__right grid__cell dw-mod"> 810 @if (Pageview.User != null) 811 { 812 @Render(new Button { 813 ButtonType = ButtonType.Button, 814 ButtonLayout = ButtonLayout.Primary, 815 OnClick = "addFileToDownloads('{{path}}');", 816 CssClass = "u-no-margin btn--condensed u-margin-left u-margin-right", 817 Icon = new Icon { 818 Prefix = "fas", 819 Name = "fa-download", 820 LabelPosition = IconLabelPosition.After 821 } 822 }) 823 } 824 </div> 825 </div> 826 </div> 827 {{/.}} 828 </script> 829 } 830 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 831 @using Dynamicweb.Rapido.Blocks 832 @using Dynamicweb.Rapido.Blocks.Components.General 833 834 @functions { 835 BlocksPage viewListPage = BlocksPage.GetBlockPage("FilesList"); 836 } 837 838 @{ 839 Block listViewTemplate = new Block() 840 { 841 Id = "ListViewTemplate", 842 Template = RenderListViewTemplate() 843 }; 844 845 viewListPage.Add("ScriptTemplates", listViewTemplate); 846 } 847 848 @helper RenderListViewTemplate() 849 { 850 @* List view *@ 851 <script id="FileItemContainer" type="text/x-template"> 852 {{#.}} 853 <div id="File{{id}}" class="grid__col-12 dw-mod"> 854 <div class="grid product-list__list-item dw-mod"> 855 <div class="grid__col-md-4 {{noImage}} product-list__list-item__left u-no-padding u-color-light--bg dw-mod"> 856 <div class="grid__cell"> 857 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')" class="u-flex u-full-height"> 858 {{#if icon}} 859 @Render(new Image { Path = "{{icon}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding--lg" }) 860 {{else}} 861 @Render(new Image { Path = "{{path}}", Title = "{{name}}", CssClass = "grid__cell-img--centered u-padding", ImageDefault = new ImageSettings { Width = 300, Height = 300, Crop = 5, FillCanvas = true } }) 862 {{/if}} 863 </label> 864 </div> 865 </div> 866 <div class="grid__col-md-auto product-list__list-item__right dw-mod"> 867 <div class="grid__cell"> 868 <h2 class="u-no-margin"> 869 <label for="PreviewModalTrigger" onclick="getPreview('{{id}}')">{{name}}</label> 870 </h2> 871 <div class="item-number dw-mod">{{path}}</div> 872 <ul class="list list--clean u-margin-top dw-mod"> 873 <li><strong>@Translate("Updated"):</strong> {{lastWriteTime}}</li> 874 <li><strong>@Translate("File size"):</strong> {{size}} KB</li> 875 <li><strong>@Translate("File type"):</strong> {{extension}}</li> 876 {{#if dimension}} 877 <li><strong>@Translate("Dimension"):</strong> {{dimension}}</li> 878 {{/if}} 879 {{#if colors}} 880 <li><strong>@Translate("Colors"):</strong> {{colors}}</li> 881 {{/if}} 882 </ul> 883 </div> 884 885 @if (Pageview.User != null) 886 { 887 <div class="grid__cell-footer"> 888 <div class="grid__cell"> 889 @Render(new Button 890 { 891 ButtonType = ButtonType.Button, 892 ButtonLayout = ButtonLayout.Primary, 893 OnClick = "addFileToDownloads('{{path}}');", 894 CssClass = "u-no-margin btn--condensed u-no-margin u-pull--right", 895 Icon = new Icon 896 { 897 Prefix = "fas", 898 Name = "fa-download", 899 LabelPosition = IconLabelPosition.After 900 } 901 }) 902 </div> 903 </div> 904 } 905 </div> 906 </div> 907 </div> 908 {{/.}} 909 </script> 910 } 911 912 913 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 914 @using System.Text.RegularExpressions 915 @using System.Collections.Generic 916 @using System.Reflection 917 @using System.Web 918 @using System.Web.UI.HtmlControls 919 @using Dynamicweb.Rapido.Blocks.Components 920 @using Dynamicweb.Rapido.Blocks.Components.Articles 921 @using Dynamicweb.Rapido.Blocks.Components.Documentation 922 @using Dynamicweb.Rapido.Blocks 923 924 925 @*--- START: Base block renderers ---*@ 926 927 @helper RenderBlockList(List<Block> blocks) 928 { 929 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 930 blocks = blocks.OrderBy(item => item.SortId).ToList(); 931 932 foreach (Block item in blocks) 933 { 934 if (debug) { 935 <!-- Block START: @item.Id --> 936 } 937 938 if (item.Design == null) 939 { 940 @RenderBlock(item) 941 } 942 else if (item.Design.RenderType == RenderType.None) { 943 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 944 945 <div class="@cssClass dw-mod"> 946 @RenderBlock(item) 947 </div> 948 } 949 else if (item.Design.RenderType != RenderType.Hide) 950 { 951 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 952 953 if (!item.SkipRenderBlocksList) { 954 if (item.Design.RenderType == RenderType.Row) 955 { 956 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 957 @RenderBlock(item) 958 </div> 959 } 960 961 if (item.Design.RenderType == RenderType.Column) 962 { 963 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 964 string size = item.Design.Size ?? "12"; 965 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 966 967 <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"> 968 @RenderBlock(item) 969 </div> 970 } 971 972 if (item.Design.RenderType == RenderType.Table) 973 { 974 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 975 @RenderBlock(item) 976 </table> 977 } 978 979 if (item.Design.RenderType == RenderType.TableRow) 980 { 981 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 982 @RenderBlock(item) 983 </tr> 984 } 985 986 if (item.Design.RenderType == RenderType.TableColumn) 987 { 988 <td class="@cssClass dw-mod" id="Block__@item.Id"> 989 @RenderBlock(item) 990 </td> 991 } 992 993 if (item.Design.RenderType == RenderType.CardHeader) 994 { 995 <div class="card-header @cssClass dw-mod"> 996 @RenderBlock(item) 997 </div> 998 } 999 1000 if (item.Design.RenderType == RenderType.CardBody) 1001 { 1002 <div class="card @cssClass dw-mod"> 1003 @RenderBlock(item) 1004 </div> 1005 } 1006 1007 if (item.Design.RenderType == RenderType.CardFooter) 1008 { 1009 <div class="card-footer @cssClass dw-mod"> 1010 @RenderBlock(item) 1011 </div> 1012 } 1013 } 1014 else 1015 { 1016 @RenderBlock(item) 1017 } 1018 } 1019 1020 if (debug) { 1021 <!-- Block END: @item.Id --> 1022 } 1023 } 1024 } 1025 1026 @helper RenderBlock(Block item) 1027 { 1028 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 1029 1030 if (item.Template != null) 1031 { 1032 @BlocksPage.RenderTemplate(item.Template) 1033 } 1034 1035 if (item.Component != null) 1036 { 1037 string customSufix = "Custom"; 1038 string methodName = item.Component.HelperName; 1039 1040 ComponentBase[] methodParameters = new ComponentBase[1]; 1041 methodParameters[0] = item.Component; 1042 Type methodType = this.GetType(); 1043 1044 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 1045 MethodInfo generalMethod = methodType.GetMethod(methodName); 1046 1047 try { 1048 if (debug) { 1049 <!-- Component: @methodName.Replace("Render", "") --> 1050 } 1051 @customMethod.Invoke(this, methodParameters).ToString(); 1052 } catch { 1053 try { 1054 @generalMethod.Invoke(this, methodParameters).ToString(); 1055 } catch(Exception ex) { 1056 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 1057 } 1058 } 1059 } 1060 1061 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 1062 { 1063 @RenderBlockList(item.BlocksList) 1064 } 1065 } 1066 1067 @*--- END: Base block renderers ---*@ 1068 1069 @* Include the components *@ 1070 @using Dynamicweb.Rapido.Blocks.Components 1071 @using Dynamicweb.Rapido.Blocks.Components.General 1072 @using Dynamicweb.Rapido.Blocks 1073 @using System.IO 1074 1075 @* Required *@ 1076 @using Dynamicweb.Rapido.Blocks.Components 1077 @using Dynamicweb.Rapido.Blocks.Components.General 1078 @using Dynamicweb.Rapido.Blocks 1079 1080 1081 @helper Render(ComponentBase component) 1082 { 1083 if (component != null) 1084 { 1085 @component.Render(this) 1086 } 1087 } 1088 1089 1090 @* Components *@ 1091 @using System.Reflection 1092 @using Dynamicweb.Rapido.Blocks.Components.General 1093 1094 1095 @* Component *@ 1096 1097 @helper RenderIcon(Icon settings) 1098 { 1099 if (settings != null) 1100 { 1101 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1102 1103 if (settings.Name != null) 1104 { 1105 if (string.IsNullOrEmpty(settings.Label)) 1106 { 1107 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 1108 } 1109 else 1110 { 1111 if (settings.LabelPosition == IconLabelPosition.Before) 1112 { 1113 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 1114 } 1115 else 1116 { 1117 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 1118 } 1119 } 1120 } 1121 else if (!string.IsNullOrEmpty(settings.Label)) 1122 { 1123 @settings.Label 1124 } 1125 } 1126 } 1127 @using System.Reflection 1128 @using Dynamicweb.Rapido.Blocks.Components.General 1129 @using Dynamicweb.Rapido.Blocks.Components 1130 @using Dynamicweb.Core 1131 1132 @* Component *@ 1133 1134 @helper RenderButton(Button settings) 1135 { 1136 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 1137 { 1138 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1139 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 1140 if (settings.Disabled) { 1141 attributes.Add("disabled", "true"); 1142 classList.Add("disabled"); 1143 } 1144 1145 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 1146 { 1147 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1148 @RenderConfirmDialog(settings); 1149 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 1150 } 1151 1152 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1153 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1154 if (!string.IsNullOrEmpty(settings.AltText)) 1155 { 1156 attributes.Add("title", settings.AltText); 1157 } 1158 else if (!string.IsNullOrEmpty(settings.Title)) 1159 { 1160 attributes.Add("title", settings.Title); 1161 } 1162 1163 var onClickEvents = new List<string>(); 1164 if (!string.IsNullOrEmpty(settings.OnClick)) 1165 { 1166 onClickEvents.Add(settings.OnClick); 1167 } 1168 if (!string.IsNullOrEmpty(settings.Href)) 1169 { 1170 onClickEvents.Add("location.href='" + settings.Href + "'"); 1171 } 1172 if (onClickEvents.Count > 0) 1173 { 1174 attributes.Add("onClick", string.Join(";", onClickEvents)); 1175 } 1176 1177 if (settings.ButtonLayout != ButtonLayout.None) 1178 { 1179 classList.Add("btn"); 1180 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 1181 if (btnLayout == "linkclean") 1182 { 1183 btnLayout = "link-clean"; //fix 1184 } 1185 classList.Add("btn--" + btnLayout); 1186 } 1187 1188 if (settings.Icon == null) 1189 { 1190 settings.Icon = new Icon(); 1191 } 1192 settings.Icon.Label = settings.Title; 1193 1194 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 1195 1196 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 1197 } 1198 } 1199 1200 @helper RenderConfirmDialog(Button settings) 1201 { 1202 Modal confirmDialog = new Modal { 1203 Id = settings.Id, 1204 Width = ModalWidth.Sm, 1205 Heading = new Heading 1206 { 1207 Level = 2, 1208 Title = settings.ConfirmTitle 1209 }, 1210 BodyText = settings.ConfirmText 1211 }; 1212 1213 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 1214 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 1215 1216 @Render(confirmDialog) 1217 } 1218 @using Dynamicweb.Rapido.Blocks.Components.General 1219 @using Dynamicweb.Rapido.Blocks.Components 1220 @using Dynamicweb.Core 1221 1222 @helper RenderDashboard(Dashboard settings) 1223 { 1224 var widgets = settings.GetWidgets(); 1225 1226 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 1227 { 1228 //set bg color for them 1229 1230 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 1231 int r = Convert.ToInt16(color.R); 1232 int g = Convert.ToInt16(color.G); 1233 int b = Convert.ToInt16(color.B); 1234 1235 var count = widgets.Length; 1236 var max = Math.Max(r, Math.Max(g, b)); 1237 double step = 255.0 / (max * count); 1238 var i = 0; 1239 foreach (var widget in widgets) 1240 { 1241 i++; 1242 1243 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 1244 widget.BackgroundColor = shade; 1245 } 1246 } 1247 1248 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1249 @foreach (var widget in widgets) 1250 { 1251 <div class="dashboard__widget"> 1252 @Render(widget) 1253 </div> 1254 } 1255 </div> 1256 } 1257 @using Dynamicweb.Rapido.Blocks.Components.General 1258 @using Dynamicweb.Rapido.Blocks.Components 1259 1260 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 1261 { 1262 if (!string.IsNullOrEmpty(settings.Link)) 1263 { 1264 var backgroundStyles = ""; 1265 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 1266 { 1267 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 1268 } 1269 1270 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1271 <div class="u-center-middle u-color-light"> 1272 @if (settings.Icon != null) 1273 { 1274 settings.Icon.CssClass += "widget__icon"; 1275 @Render(settings.Icon) 1276 } 1277 <div class="widget__title">@settings.Title</div> 1278 </div> 1279 </a> 1280 } 1281 } 1282 @using Dynamicweb.Rapido.Blocks.Components.General 1283 @using Dynamicweb.Rapido.Blocks.Components 1284 1285 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 1286 { 1287 var backgroundStyles = ""; 1288 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 1289 { 1290 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 1291 } 1292 1293 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1294 <div class="u-center-middle u-color-light"> 1295 @if (settings.Icon != null) 1296 { 1297 settings.Icon.CssClass += "widget__icon"; 1298 @Render(settings.Icon) 1299 } 1300 <div class="widget__counter">@settings.Count</div> 1301 <div class="widget__title">@settings.Title</div> 1302 </div> 1303 </div> 1304 } 1305 @using System.Reflection 1306 @using Dynamicweb.Rapido.Blocks.Components.General 1307 @using Dynamicweb.Rapido.Blocks.Components 1308 @using Dynamicweb.Core 1309 1310 @* Component *@ 1311 1312 @helper RenderLink(Link settings) 1313 { 1314 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 1315 { 1316 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1317 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 1318 if (settings.Disabled) 1319 { 1320 attributes.Add("disabled", "true"); 1321 classList.Add("disabled"); 1322 } 1323 1324 if (!string.IsNullOrEmpty(settings.AltText)) 1325 { 1326 attributes.Add("title", settings.AltText); 1327 } 1328 else if (!string.IsNullOrEmpty(settings.Title)) 1329 { 1330 attributes.Add("title", settings.Title); 1331 } 1332 1333 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1334 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1335 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 1336 attributes.Add("href", settings.Href); 1337 1338 if (settings.ButtonLayout != ButtonLayout.None) 1339 { 1340 classList.Add("btn"); 1341 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 1342 if (btnLayout == "linkclean") 1343 { 1344 btnLayout = "link-clean"; //fix 1345 } 1346 classList.Add("btn--" + btnLayout); 1347 } 1348 1349 if (settings.Icon == null) 1350 { 1351 settings.Icon = new Icon(); 1352 } 1353 settings.Icon.Label = settings.Title; 1354 1355 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 1356 { 1357 settings.Rel = LinkRelType.Noopener; 1358 } 1359 if (settings.Target != LinkTargetType.None) 1360 { 1361 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 1362 } 1363 if (settings.Download) 1364 { 1365 attributes.Add("download", "true"); 1366 } 1367 if (settings.Rel != LinkRelType.None) 1368 { 1369 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 1370 } 1371 1372 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 1373 } 1374 } 1375 @using System.Reflection 1376 @using Dynamicweb.Rapido.Blocks.Components 1377 @using Dynamicweb.Rapido.Blocks.Components.General 1378 @using Dynamicweb.Rapido.Blocks 1379 1380 1381 @* Component *@ 1382 1383 @helper RenderRating(Rating settings) 1384 { 1385 if (settings.Score > 0) 1386 { 1387 int rating = settings.Score; 1388 string iconType = "fa-star"; 1389 1390 switch (settings.Type.ToString()) { 1391 case "Stars": 1392 iconType = "fa-star"; 1393 break; 1394 case "Hearts": 1395 iconType = "fa-heart"; 1396 break; 1397 case "Lemons": 1398 iconType = "fa-lemon"; 1399 break; 1400 case "Bombs": 1401 iconType = "fa-bomb"; 1402 break; 1403 } 1404 1405 <div class="u-ta-right"> 1406 @for (int i = 0; i < settings.OutOf; i++) 1407 { 1408 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 1409 } 1410 </div> 1411 } 1412 } 1413 @using System.Reflection 1414 @using Dynamicweb.Rapido.Blocks.Components.General 1415 @using Dynamicweb.Rapido.Blocks.Components 1416 1417 1418 @* Component *@ 1419 1420 @helper RenderSelectFieldOption(SelectFieldOption settings) 1421 { 1422 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1423 if (settings.Checked) { attributes.Add("selected", "true"); } 1424 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1425 if (settings.Value != null) { attributes.Add("value", settings.Value); } 1426 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1427 1428 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 1429 } 1430 @using System.Reflection 1431 @using Dynamicweb.Rapido.Blocks.Components.General 1432 @using Dynamicweb.Rapido.Blocks.Components 1433 1434 1435 @* Component *@ 1436 1437 @helper RenderNavigation(Navigation settings) { 1438 @RenderNavigation(new 1439 { 1440 id = settings.Id, 1441 cssclass = settings.CssClass, 1442 startLevel = settings.StartLevel, 1443 endlevel = settings.EndLevel, 1444 expandmode = settings.Expandmode, 1445 sitemapmode = settings.SitemapMode, 1446 template = settings.Template 1447 }) 1448 } 1449 @using Dynamicweb.Rapido.Blocks.Components.General 1450 @using Dynamicweb.Rapido.Blocks.Components 1451 1452 1453 @* Component *@ 1454 1455 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 1456 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 1457 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 1458 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 1459 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 1460 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 1461 settings.SitemapMode = false; 1462 1463 @RenderNavigation(settings) 1464 } 1465 1466 @using Dynamicweb.Rapido.Blocks.Components.General 1467 @using Dynamicweb.Rapido.Blocks.Components 1468 1469 1470 @* Component *@ 1471 1472 @helper RenderLeftNavigation(LeftNavigation settings) { 1473 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 1474 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 1475 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 1476 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 1477 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 1478 1479 <div class="grid__cell"> 1480 @RenderNavigation(settings) 1481 </div> 1482 } 1483 @using System.Reflection 1484 @using Dynamicweb.Rapido.Blocks.Components.General 1485 @using Dynamicweb.Core 1486 1487 @* Component *@ 1488 1489 @helper RenderHeading(Heading settings) 1490 { 1491 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 1492 { 1493 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1494 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 1495 1496 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 1497 if (!string.IsNullOrEmpty(settings.Link)) 1498 { 1499 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 1500 } 1501 else 1502 { 1503 if (settings.Icon == null) 1504 { 1505 settings.Icon = new Icon(); 1506 } 1507 settings.Icon.Label = settings.Title; 1508 @Render(settings.Icon) 1509 } 1510 @("</" + tagName + ">"); 1511 } 1512 } 1513 @using Dynamicweb.Rapido.Blocks.Components 1514 @using Dynamicweb.Rapido.Blocks.Components.General 1515 @using Dynamicweb.Rapido.Blocks 1516 1517 1518 @* Component *@ 1519 1520 @helper RenderImage(Image settings) 1521 { 1522 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 1523 { 1524 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1525 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 1526 1527 if (settings.Caption != null) 1528 { 1529 @:<div> 1530 } 1531 1532 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 1533 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 1534 1535 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 1536 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 1537 @if (settings.Link != null) 1538 { 1539 <a href="@settings.Link"> 1540 @RenderTheImage(settings) 1541 </a> 1542 } 1543 else 1544 { 1545 @RenderTheImage(settings) 1546 } 1547 </div> 1548 </div> 1549 1550 if (settings.Caption != null) 1551 { 1552 <span class="image-caption dw-mod">@settings.Caption</span> 1553 @:</div> 1554 } 1555 } 1556 else 1557 { 1558 if (settings.Caption != null) 1559 { 1560 @:<div> 1561 } 1562 if (!string.IsNullOrEmpty(settings.Link)) 1563 { 1564 <a href="@settings.Link"> 1565 @RenderTheImage(settings) 1566 </a> 1567 } 1568 else 1569 { 1570 @RenderTheImage(settings) 1571 } 1572 1573 if (settings.Caption != null) 1574 { 1575 <span class="image-caption dw-mod">@settings.Caption</span> 1576 @:</div> 1577 } 1578 } 1579 } 1580 1581 @helper RenderTheImage(Image settings) 1582 { 1583 if (settings != null) 1584 { 1585 string placeholderImage = "/Files/Images/placeholder.gif"; 1586 string imageEngine = "/Admin/Public/GetImage.ashx?"; 1587 1588 string imageStyle = ""; 1589 1590 switch (settings.Style) 1591 { 1592 case ImageStyle.Ball: 1593 imageStyle = "grid__cell-img--ball"; 1594 break; 1595 } 1596 1597 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 1598 { 1599 if (settings.ImageDefault != null) 1600 { 1601 settings.ImageDefault.Height = settings.ImageDefault.Width; 1602 } 1603 if (settings.ImageMedium != null) 1604 { 1605 settings.ImageMedium.Height = settings.ImageMedium.Width; 1606 } 1607 if (settings.ImageSmall != null) 1608 { 1609 settings.ImageSmall.Height = settings.ImageSmall.Width; 1610 } 1611 } 1612 1613 string defaultImage = imageEngine; 1614 string imageSmall = ""; 1615 string imageMedium = ""; 1616 1617 string SVGimg = settings.Path.ToString(); 1618 1619 if(SVGimg.EndsWith(".svg&")){ 1620 settings.Path=SVGimg.Substring(0,SVGimg.Length-1); 1621 } 1622 1623 if (settings.DisableImageEngine || settings.Path.ToString().EndsWith(".svg")) 1624 { 1625 defaultImage = settings.Path.ToString(); 1626 } 1627 else 1628 { 1629 if (settings.ImageDefault != null) 1630 { 1631 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 1632 1633 if (settings.Path.GetType() != typeof(string)) 1634 { 1635 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1636 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1637 } 1638 else 1639 { 1640 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 1641 } 1642 } 1643 1644 if (settings.ImageSmall != null) 1645 { 1646 imageSmall = "data-src-small=\"" + imageEngine; 1647 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 1648 1649 if (settings.Path.GetType() != typeof(string)) 1650 { 1651 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1652 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1653 } 1654 else 1655 { 1656 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 1657 } 1658 1659 imageSmall += "\""; 1660 } 1661 1662 if (settings.ImageMedium != null) 1663 { 1664 imageMedium = "data-src-medium=\"" + imageEngine; 1665 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 1666 1667 if (settings.Path.GetType() != typeof(string)) 1668 { 1669 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1670 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1671 } 1672 else 1673 { 1674 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 1675 } 1676 1677 imageMedium += "\""; 1678 } 1679 } 1680 1681 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1682 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 1683 if (!string.IsNullOrEmpty(settings.Title)) 1684 { 1685 optionalAttributes.Add("alt", settings.Title); 1686 optionalAttributes.Add("title", settings.Title); 1687 } 1688 1689 if (settings.DisableLazyLoad) 1690 { 1691 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) alt="" /> 1692 } 1693 else 1694 { 1695 <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) alt="" /> 1696 } 1697 } 1698 } 1699 @using System.Reflection 1700 @using Dynamicweb.Rapido.Blocks.Components.General 1701 @using Dynamicweb.Rapido.Blocks.Components 1702 1703 @* Component *@ 1704 1705 @helper RenderFileField(FileField settings) 1706 { 1707 var attributes = new Dictionary<string, string>(); 1708 if (string.IsNullOrEmpty(settings.Id)) 1709 { 1710 settings.Id = Guid.NewGuid().ToString("N"); 1711 } 1712 1713 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1714 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1715 if (settings.Required) { attributes.Add("required", "true"); } 1716 if (settings.Multiple) { attributes.Add("multiple", "true"); } 1717 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1718 if (string.IsNullOrEmpty(settings.ChooseFileText)) 1719 { 1720 settings.ChooseFileText = Translate("Choose file"); 1721 } 1722 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 1723 { 1724 settings.NoFilesChosenText = Translate("No files chosen..."); 1725 } 1726 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1727 1728 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 1729 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 1730 1731 attributes.Add("type", "file"); 1732 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1733 settings.CssClass = "u-full-width " + settings.CssClass; 1734 1735 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1736 1737 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1738 @if (!string.IsNullOrEmpty(settings.Label)) 1739 { 1740 <label for="@settings.Id">@settings.Label</label> 1741 } 1742 @if (!string.IsNullOrEmpty(settings.HelpText)) 1743 { 1744 <small class="form__help-text">@settings.HelpText</small> 1745 } 1746 1747 <div class="form__field-combi file-input u-no-margin dw-mod"> 1748 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 1749 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 1750 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 1751 @if (settings.UploadButton != null) 1752 { 1753 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 1754 @Render(settings.UploadButton) 1755 } 1756 </div> 1757 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1758 </div> 1759 } 1760 @using System.Reflection 1761 @using Dynamicweb.Rapido.Blocks.Components.General 1762 @using Dynamicweb.Rapido.Blocks.Components 1763 @using Dynamicweb.Core 1764 @using System.Linq 1765 1766 @* Component *@ 1767 1768 @helper RenderDateTimeField(DateTimeField settings) 1769 { 1770 if (string.IsNullOrEmpty(settings.Id)) 1771 { 1772 settings.Id = Guid.NewGuid().ToString("N"); 1773 } 1774 1775 var textField = new TextField { 1776 Name = settings.Name, 1777 Id = settings.Id, 1778 Label = settings.Label, 1779 HelpText = settings.HelpText, 1780 Value = settings.Value, 1781 Disabled = settings.Disabled, 1782 Required = settings.Required, 1783 ErrorMessage = settings.ErrorMessage, 1784 CssClass = settings.CssClass, 1785 WrapperCssClass = settings.WrapperCssClass, 1786 OnChange = settings.OnChange, 1787 OnClick = settings.OnClick, 1788 ExtraAttributes = settings.ExtraAttributes, 1789 // 1790 Placeholder = settings.Placeholder 1791 }; 1792 1793 @Render(textField) 1794 1795 List<string> jsAttributes = new List<string>(); 1796 1797 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1798 1799 if (!string.IsNullOrEmpty(settings.DateFormat)) 1800 { 1801 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1802 } 1803 if (!string.IsNullOrEmpty(settings.MinDate)) 1804 { 1805 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1806 } 1807 if (!string.IsNullOrEmpty(settings.MaxDate)) 1808 { 1809 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1810 } 1811 if (settings.IsInline) 1812 { 1813 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1814 } 1815 if (settings.EnableTime) 1816 { 1817 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1818 } 1819 if (settings.EnableWeekNumbers) 1820 { 1821 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1822 } 1823 1824 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1825 1826 <script> 1827 document.addEventListener("DOMContentLoaded", function () { 1828 flatpickr("#@textField.Id", { 1829 @string.Join(",", jsAttributes) 1830 }); 1831 }); 1832 </script> 1833 } 1834 @using System.Reflection 1835 @using Dynamicweb.Rapido.Blocks.Components.General 1836 @using Dynamicweb.Rapido.Blocks.Components 1837 1838 @* Component *@ 1839 1840 @helper RenderTextField(TextField settings) 1841 { 1842 var attributes = new Dictionary<string, string>(); 1843 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1844 { 1845 settings.Id = Guid.NewGuid().ToString("N"); 1846 } 1847 1848 /*base settings*/ 1849 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1850 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1851 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1852 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1853 if (settings.Required) { attributes.Add("required", "true"); } 1854 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1855 /*end*/ 1856 1857 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1858 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1859 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1860 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1861 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1862 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1863 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1864 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1865 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1866 settings.CssClass = "u-full-width " + settings.CssClass; 1867 1868 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1869 1870 string noMargin = "u-no-margin"; 1871 if (!settings.ReadOnly) { 1872 noMargin = ""; 1873 } 1874 if (settings.Id == "EcomOrderCustomerEAN") { 1875 noMargin = ""; 1876 } 1877 1878 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1879 @if (!string.IsNullOrEmpty(settings.Label)) 1880 { 1881 <label for="@settings.Id">@settings.Label</label> 1882 } 1883 @if (!string.IsNullOrEmpty(settings.HelpText)) 1884 { 1885 <small class="form__help-text">@settings.HelpText</small> 1886 } 1887 1888 @if (settings.ActionButton != null) 1889 { 1890 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1891 <div class="form__field-combi u-no-margin dw-mod"> 1892 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1893 @Render(settings.ActionButton) 1894 </div> 1895 } 1896 else 1897 { 1898 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1899 } 1900 1901 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1902 </div> 1903 } 1904 @using System.Reflection 1905 @using Dynamicweb.Rapido.Blocks.Components.General 1906 @using Dynamicweb.Rapido.Blocks.Components 1907 1908 @* Component *@ 1909 1910 @helper RenderNumberField(NumberField settings) 1911 { 1912 var attributes = new Dictionary<string, string>(); 1913 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1914 { 1915 settings.Id = Guid.NewGuid().ToString("N"); 1916 } 1917 1918 /*base settings*/ 1919 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1920 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1921 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1922 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1923 if (settings.Required) { attributes.Add("required", "true"); } 1924 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1925 /*end*/ 1926 1927 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1928 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1929 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1930 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1931 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1932 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1933 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1934 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1935 attributes.Add("type", "number"); 1936 1937 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1938 1939 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1940 @if (!string.IsNullOrEmpty(settings.Label)) 1941 { 1942 <label for="@settings.Id">@settings.Label</label> 1943 } 1944 @if (!string.IsNullOrEmpty(settings.HelpText)) 1945 { 1946 <small class="form__help-text">@settings.HelpText</small> 1947 } 1948 1949 @if (settings.ActionButton != null) 1950 { 1951 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1952 <div class="form__field-combi u-no-margin dw-mod"> 1953 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1954 @Render(settings.ActionButton) 1955 </div> 1956 } 1957 else 1958 { 1959 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1960 } 1961 1962 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1963 </div> 1964 } 1965 @using System.Reflection 1966 @using Dynamicweb.Rapido.Blocks.Components.General 1967 @using Dynamicweb.Rapido.Blocks.Components 1968 1969 1970 @* Component *@ 1971 1972 @helper RenderTextareaField(TextareaField settings) 1973 { 1974 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1975 string id = settings.Id; 1976 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1977 { 1978 id = Guid.NewGuid().ToString("N"); 1979 } 1980 1981 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1982 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1983 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1984 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1985 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1986 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1987 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1988 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1989 if (settings.Required) { attributes.Add("required", "true"); } 1990 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1991 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1992 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1993 attributes.Add("name", settings.Name); 1994 1995 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1996 @if (!string.IsNullOrEmpty(settings.Label)) 1997 { 1998 <label for="@id">@settings.Label</label> 1999 } 2000 @if (!string.IsNullOrEmpty(settings.HelpText)) 2001 { 2002 <small class="form__help-text">@settings.HelpText</small> 2003 } 2004 2005 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 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 RenderHiddenField(HiddenField settings) { 2018 var attributes = new Dictionary<string, string>(); 2019 attributes.Add("type", "hidden"); 2020 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2021 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2022 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2023 2024 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 2025 } 2026 @using System.Reflection 2027 @using Dynamicweb.Rapido.Blocks.Components.General 2028 @using Dynamicweb.Rapido.Blocks.Components 2029 2030 @* Component *@ 2031 2032 @helper RenderCheckboxField(CheckboxField settings) 2033 { 2034 var attributes = new Dictionary<string, string>(); 2035 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2036 { 2037 settings.Id = Guid.NewGuid().ToString("N"); 2038 } 2039 2040 /*base settings*/ 2041 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2042 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2043 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2044 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2045 if (settings.Required) { attributes.Add("required", "true"); } 2046 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2047 /*end*/ 2048 2049 attributes.Add("type", "checkbox"); 2050 if (settings.Checked) { attributes.Add("checked", "true"); } 2051 settings.CssClass = "form__control " + settings.CssClass; 2052 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2053 2054 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2055 2056 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2057 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2058 @if (!string.IsNullOrEmpty(settings.Label)) 2059 { 2060 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2061 } 2062 @if (!string.IsNullOrEmpty(settings.HelpText)) 2063 { 2064 <small class="form__help-text">@settings.HelpText</small> 2065 } 2066 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2067 </div> 2068 } 2069 @using System.Reflection 2070 @using Dynamicweb.Rapido.Blocks.Components.General 2071 @using Dynamicweb.Rapido.Blocks.Components 2072 2073 2074 @* Component *@ 2075 2076 @helper RenderCheckboxListField(CheckboxListField settings) 2077 { 2078 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2079 @if (!string.IsNullOrEmpty(settings.Label)) 2080 { 2081 <label>@settings.Label</label> 2082 } 2083 @if (!string.IsNullOrEmpty(settings.HelpText)) 2084 { 2085 <small class="form__help-text">@settings.HelpText</small> 2086 } 2087 2088 @foreach (var item in settings.Options) 2089 { 2090 if (settings.Required) 2091 { 2092 item.Required = true; 2093 } 2094 if (settings.Disabled) 2095 { 2096 item.Disabled = true; 2097 } 2098 if (!string.IsNullOrEmpty(settings.Name)) 2099 { 2100 item.Name = settings.Name; 2101 } 2102 if (!string.IsNullOrEmpty(settings.CssClass)) 2103 { 2104 item.CssClass += settings.CssClass; 2105 } 2106 2107 /* value is not supported */ 2108 2109 if (!string.IsNullOrEmpty(settings.OnClick)) 2110 { 2111 item.OnClick += settings.OnClick; 2112 } 2113 if (!string.IsNullOrEmpty(settings.OnChange)) 2114 { 2115 item.OnChange += settings.OnChange; 2116 } 2117 @Render(item) 2118 } 2119 2120 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2121 </div> 2122 } 2123 @using System.Reflection 2124 @using Dynamicweb.Rapido.Blocks.Components.General 2125 @using Dynamicweb.Rapido.Blocks.Components 2126 2127 2128 @* Component *@ 2129 2130 @helper RenderSelectField(SelectField settings) 2131 { 2132 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2133 { 2134 settings.Id = Guid.NewGuid().ToString("N"); 2135 } 2136 2137 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 2138 @if (!string.IsNullOrEmpty(settings.Label)) 2139 { 2140 <label for="@settings.Id">@settings.Label</label> 2141 } 2142 @if (!string.IsNullOrEmpty(settings.HelpText)) 2143 { 2144 <small class="form__help-text">@settings.HelpText</small> 2145 } 2146 2147 @if (settings.ActionButton != null) 2148 { 2149 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 2150 <div class="form__field-combi u-no-margin dw-mod"> 2151 @RenderSelectBase(settings) 2152 @Render(settings.ActionButton) 2153 </div> 2154 } 2155 else 2156 { 2157 @RenderSelectBase(settings) 2158 } 2159 2160 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2161 </div> 2162 } 2163 2164 @helper RenderSelectBase(SelectField settings) 2165 { 2166 var attributes = new Dictionary<string, string>(); 2167 2168 /*base settings*/ 2169 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2170 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2171 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2172 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2173 if (settings.Required) { attributes.Add("required", "true"); } 2174 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2175 /*end*/ 2176 2177 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2178 2179 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 2180 @if (settings.Default != null) 2181 { 2182 @Render(settings.Default) 2183 } 2184 2185 @foreach (var item in settings.Options) 2186 { 2187 if (!string.IsNullOrEmpty(settings.Value)) { 2188 item.Checked = item.Value == settings.Value; 2189 } 2190 @Render(item) 2191 } 2192 </select> 2193 } 2194 @using System.Reflection 2195 @using Dynamicweb.Rapido.Blocks.Components.General 2196 @using Dynamicweb.Rapido.Blocks.Components 2197 2198 @* Component *@ 2199 2200 @helper RenderRadioButtonField(RadioButtonField settings) 2201 { 2202 var attributes = new Dictionary<string, string>(); 2203 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2204 { 2205 settings.Id = Guid.NewGuid().ToString("N"); 2206 } 2207 2208 /*base settings*/ 2209 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2210 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2211 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2212 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2213 if (settings.Required) { attributes.Add("required", "true"); } 2214 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2215 /*end*/ 2216 2217 attributes.Add("type", "radio"); 2218 if (settings.Checked) { attributes.Add("checked", "true"); } 2219 settings.CssClass = "form__control " + settings.CssClass; 2220 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2221 2222 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2223 2224 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2225 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2226 @if (!string.IsNullOrEmpty(settings.Label)) 2227 { 2228 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2229 } 2230 @if (!string.IsNullOrEmpty(settings.HelpText)) 2231 { 2232 <small class="form__help-text">@settings.HelpText</small> 2233 } 2234 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2235 </div> 2236 } 2237 @using System.Reflection 2238 @using Dynamicweb.Rapido.Blocks.Components.General 2239 @using Dynamicweb.Rapido.Blocks.Components 2240 2241 2242 @* Component *@ 2243 2244 @helper RenderRadioButtonListField(RadioButtonListField settings) 2245 { 2246 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2247 @if (!string.IsNullOrEmpty(settings.Label)) 2248 { 2249 <label>@settings.Label</label> 2250 } 2251 @if (!string.IsNullOrEmpty(settings.HelpText)) 2252 { 2253 <small class="form__help-text">@settings.HelpText</small> 2254 } 2255 2256 @foreach (var item in settings.Options) 2257 { 2258 if (settings.Required) 2259 { 2260 item.Required = true; 2261 } 2262 if (settings.Disabled) 2263 { 2264 item.Disabled = true; 2265 } 2266 if (!string.IsNullOrEmpty(settings.Name)) 2267 { 2268 item.Name = settings.Name; 2269 } 2270 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 2271 { 2272 item.Checked = true; 2273 } 2274 if (!string.IsNullOrEmpty(settings.OnClick)) 2275 { 2276 item.OnClick += settings.OnClick; 2277 } 2278 if (!string.IsNullOrEmpty(settings.OnChange)) 2279 { 2280 item.OnChange += settings.OnChange; 2281 } 2282 if (!string.IsNullOrEmpty(settings.CssClass)) 2283 { 2284 item.CssClass += settings.CssClass; 2285 } 2286 @Render(item) 2287 } 2288 2289 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2290 </div> 2291 } 2292 @using System.Reflection 2293 @using Dynamicweb.Rapido.Blocks.Components.General 2294 @using Dynamicweb.Rapido.Blocks.Components 2295 2296 2297 @* Component *@ 2298 2299 @helper RenderNotificationMessage(NotificationMessage settings) 2300 { 2301 if (!string.IsNullOrEmpty(settings.Message)) 2302 { 2303 var attributes = new Dictionary<string, string>(); 2304 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2305 2306 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 2307 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 2308 } 2309 } 2310 @using Dynamicweb.Rapido.Blocks.Components.General 2311 2312 2313 @* Component *@ 2314 2315 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 2316 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 2317 2318 <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> 2319 @if (settings.SubBlocks != null) { 2320 @RenderBlockList(settings.SubBlocks) 2321 } 2322 </div> 2323 } 2324 @using System.Reflection 2325 @using Dynamicweb.Rapido.Blocks.Components.General 2326 @using Dynamicweb.Rapido.Blocks.Components 2327 @using System.Text.RegularExpressions 2328 2329 2330 @* Component *@ 2331 2332 @helper RenderSticker(Sticker settings) { 2333 if (!String.IsNullOrEmpty(settings.Title)) { 2334 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 2335 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 2336 2337 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 2338 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 2339 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 2340 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 2341 optionalAttributes.Add("style", styleTag); 2342 } 2343 2344 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 2345 } 2346 } 2347 2348 @using System.Reflection 2349 @using Dynamicweb.Rapido.Blocks.Components.General 2350 @using Dynamicweb.Rapido.Blocks.Components 2351 2352 2353 @* Component *@ 2354 2355 @helper RenderStickersCollection(StickersCollection settings) 2356 { 2357 if (settings.Stickers.Count > 0) 2358 { 2359 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 2360 2361 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2362 @foreach (Sticker sticker in settings.Stickers) 2363 { 2364 @Render(sticker) 2365 } 2366 </div> 2367 } 2368 } 2369 2370 @using Dynamicweb.Rapido.Blocks.Components.General 2371 2372 2373 @* Component *@ 2374 2375 @helper RenderForm(Form settings) { 2376 if (settings != null) 2377 { 2378 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2379 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 2380 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 2381 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 2382 var enctypes = new Dictionary<string, string> 2383 { 2384 { "multipart", "multipart/form-data" }, 2385 { "text", "text/plain" }, 2386 { "application", "application/x-www-form-urlencoded" } 2387 }; 2388 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 2389 optionalAttributes.Add("method", settings.Method.ToString()); 2390 2391 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 2392 { 2393 @settings.FormStartMarkup 2394 } 2395 else 2396 { 2397 @:<form name="@settings.Name" class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2398 } 2399 2400 foreach (var field in settings.GetFields()) 2401 { 2402 @Render(field) 2403 } 2404 2405 @:</form> 2406 } 2407 } 2408 @using System.Reflection 2409 @using Dynamicweb.Rapido.Blocks.Components.General 2410 @using Dynamicweb.Rapido.Blocks.Components 2411 2412 2413 @* Component *@ 2414 2415 @helper RenderText(Text settings) 2416 { 2417 @settings.Content 2418 } 2419 @using System.Reflection 2420 @using Dynamicweb.Rapido.Blocks.Components.General 2421 @using Dynamicweb.Rapido.Blocks.Components 2422 2423 2424 @* Component *@ 2425 2426 @helper RenderContentModule(ContentModule settings) { 2427 if (!string.IsNullOrEmpty(settings.Content)) 2428 { 2429 @settings.Content 2430 } 2431 } 2432 @using System.Reflection 2433 @using Dynamicweb.Rapido.Blocks.Components.General 2434 @using Dynamicweb.Rapido.Blocks.Components 2435 2436 2437 @* Component *@ 2438 2439 @helper RenderModal(Modal settings) { 2440 if (settings != null) 2441 { 2442 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 2443 2444 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 2445 2446 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 2447 2448 <div class="modal-container"> 2449 @if (!settings.DisableDarkOverlay) 2450 { 2451 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 2452 } 2453 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 2454 @if (settings.Heading != null) 2455 { 2456 if (!string.IsNullOrEmpty(settings.Heading.Title)) 2457 { 2458 <div class="modal__header"> 2459 @Render(settings.Heading) 2460 </div> 2461 } 2462 } 2463 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 2464 @if (!string.IsNullOrEmpty(settings.BodyText)) 2465 { 2466 @settings.BodyText 2467 } 2468 @if (settings.BodyTemplate != null) 2469 { 2470 @settings.BodyTemplate 2471 } 2472 @{ 2473 var actions = settings.GetActions(); 2474 } 2475 </div> 2476 @if (actions.Length > 0) 2477 { 2478 <div class="modal__footer"> 2479 @foreach (var action in actions) 2480 { 2481 action.CssClass += " u-no-margin"; 2482 @Render(action) 2483 } 2484 </div> 2485 } 2486 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 2487 </div> 2488 </div> 2489 } 2490 } 2491 @using Dynamicweb.Rapido.Blocks.Components.General 2492 2493 @* Component *@ 2494 2495 @helper RenderMediaListItem(MediaListItem settings) 2496 { 2497 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 2498 @if (!string.IsNullOrEmpty(settings.Label)) 2499 { 2500 if (!string.IsNullOrEmpty(settings.Link)) 2501 { 2502 @Render(new Link 2503 { 2504 Href = settings.Link, 2505 CssClass = "media-list-item__sticker dw-mod", 2506 ButtonLayout = ButtonLayout.None, 2507 Title = settings.Label, 2508 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2509 }) 2510 } 2511 else if (!string.IsNullOrEmpty(settings.OnClick)) 2512 { 2513 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 2514 <span class="u-uppercase">@settings.Label</span> 2515 </span> 2516 } 2517 else 2518 { 2519 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 2520 <span class="u-uppercase">@settings.Label</span> 2521 </span> 2522 } 2523 } 2524 <div class="media-list-item__wrap"> 2525 <div class="media-list-item__info dw-mod"> 2526 <div class="media-list-item__header dw-mod"> 2527 @if (!string.IsNullOrEmpty(settings.Title)) 2528 { 2529 if (!string.IsNullOrEmpty(settings.Link)) 2530 { 2531 @Render(new Link 2532 { 2533 Href = settings.Link, 2534 CssClass = "media-list-item__name dw-mod", 2535 ButtonLayout = ButtonLayout.None, 2536 Title = settings.Title, 2537 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2538 }) 2539 } 2540 else if (!string.IsNullOrEmpty(settings.OnClick)) 2541 { 2542 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 2543 } 2544 else 2545 { 2546 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 2547 } 2548 } 2549 2550 @if (!string.IsNullOrEmpty(settings.Status)) 2551 { 2552 <div class="media-list-item__state dw-mod">@settings.Status</div> 2553 } 2554 </div> 2555 @{ 2556 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 2557 } 2558 2559 @Render(settings.InfoTable) 2560 </div> 2561 <div class="media-list-item__actions dw-mod"> 2562 <div class="media-list-item__actions-list dw-mod"> 2563 @{ 2564 var actions = settings.GetActions(); 2565 2566 foreach (ButtonBase action in actions) 2567 { 2568 action.ButtonLayout = ButtonLayout.None; 2569 action.CssClass += " media-list-item__action link"; 2570 2571 @Render(action) 2572 } 2573 } 2574 </div> 2575 2576 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2577 { 2578 settings.SelectButton.CssClass += " u-no-margin"; 2579 2580 <div class="media-list-item__action-button"> 2581 @Render(settings.SelectButton) 2582 </div> 2583 } 2584 </div> 2585 </div> 2586 </div> 2587 } 2588 @using Dynamicweb.Rapido.Blocks.Components.General 2589 @using Dynamicweb.Rapido.Blocks.Components 2590 2591 @helper RenderTable(Table settings) 2592 { 2593 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2594 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2595 2596 var enumToClasses = new Dictionary<TableDesign, string> 2597 { 2598 { TableDesign.Clean, "table--clean" }, 2599 { TableDesign.Bordered, "table--bordered" }, 2600 { TableDesign.Striped, "table--striped" }, 2601 { TableDesign.Hover, "table--hover" }, 2602 { TableDesign.Compact, "table--compact" }, 2603 { TableDesign.Condensed, "table--condensed" }, 2604 { TableDesign.NoTopBorder, "table--no-top-border" } 2605 }; 2606 string tableDesignClass = ""; 2607 if (settings.Design != TableDesign.None) 2608 { 2609 tableDesignClass = enumToClasses[settings.Design]; 2610 } 2611 2612 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2613 2614 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2615 2616 <table @ComponentMethods.AddAttributes(resultAttributes)> 2617 @if (settings.Header != null) 2618 { 2619 <thead> 2620 @Render(settings.Header) 2621 </thead> 2622 } 2623 <tbody> 2624 @foreach (var row in settings.Rows) 2625 { 2626 @Render(row) 2627 } 2628 </tbody> 2629 @if (settings.Footer != null) 2630 { 2631 <tfoot> 2632 @Render(settings.Footer) 2633 </tfoot> 2634 } 2635 </table> 2636 } 2637 @using Dynamicweb.Rapido.Blocks.Components.General 2638 @using Dynamicweb.Rapido.Blocks.Components 2639 2640 @helper RenderTableRow(TableRow settings) 2641 { 2642 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2643 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2644 2645 var enumToClasses = new Dictionary<TableRowDesign, string> 2646 { 2647 { TableRowDesign.NoBorder, "table__row--no-border" }, 2648 { TableRowDesign.Border, "table__row--border" }, 2649 { TableRowDesign.TopBorder, "table__row--top-line" }, 2650 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2651 { TableRowDesign.Solid, "table__row--solid" } 2652 }; 2653 2654 string tableRowDesignClass = ""; 2655 if (settings.Design != TableRowDesign.None) 2656 { 2657 tableRowDesignClass = enumToClasses[settings.Design]; 2658 } 2659 2660 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2661 2662 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2663 2664 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2665 @foreach (var cell in settings.Cells) 2666 { 2667 if (settings.IsHeaderRow) 2668 { 2669 cell.IsHeader = true; 2670 } 2671 @Render(cell) 2672 } 2673 </tr> 2674 } 2675 @using Dynamicweb.Rapido.Blocks.Components.General 2676 @using Dynamicweb.Rapido.Blocks.Components 2677 @using Dynamicweb.Core 2678 2679 @helper RenderTableCell(TableCell settings) 2680 { 2681 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2682 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2683 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2684 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2685 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2686 2687 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2688 2689 string tagName = settings.IsHeader ? "th" : "td"; 2690 2691 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2692 @settings.Content 2693 @("</" + tagName + ">"); 2694 } 2695 @using System.Linq 2696 @using Dynamicweb.Rapido.Blocks.Components.General 2697 2698 @* Component *@ 2699 2700 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2701 { 2702 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2703 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2704 2705 if (settings.NumberOfPages > 1) 2706 { 2707 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2708 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2709 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2710 2711 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2712 @if (settings.ShowPagingInfo) 2713 { 2714 <div class="pager__info dw-mod"> 2715 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2716 </div> 2717 } 2718 <ul class="pager__list dw-mod"> 2719 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2720 { 2721 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2722 } 2723 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2724 { 2725 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2726 } 2727 @if (settings.GetPages().Any()) 2728 { 2729 foreach (var page in settings.GetPages()) 2730 { 2731 @Render(page) 2732 } 2733 } 2734 else 2735 { 2736 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2737 { 2738 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2739 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2740 } 2741 } 2742 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2743 { 2744 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2745 } 2746 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2747 { 2748 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2749 } 2750 </ul> 2751 </div> 2752 } 2753 } 2754 2755 @helper RenderPaginationItem(PaginationItem settings) 2756 { 2757 if (settings.Icon == null) 2758 { 2759 settings.Icon = new Icon(); 2760 } 2761 2762 settings.Icon.Label = settings.Label; 2763 <li class="pager__btn dw-mod"> 2764 @if (settings.IsActive) 2765 { 2766 <span class="pager__num pager__num--current dw-mod"> 2767 @Render(settings.Icon) 2768 </span> 2769 } 2770 else 2771 { 2772 <a href="@settings.Link" class="pager__num dw-mod"> 2773 @Render(settings.Icon) 2774 </a> 2775 } 2776 </li> 2777 } 2778 2779 2780 @using Dynamicweb.Rapido.Blocks.Components.General 2781 2782 2783 2784 2785 @RenderBlockList(filesPage.BlocksRoot.BlocksList) 2786 2787 @helper RenderPageContainer() 2788 { 2789 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 2790 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 2791 string feedPageUrl = new Regex("([?&]ID)=[^?&]+").Replace(pageUrl, "?ID=" + feedPageId); 2792 2793 <div class="grid grid--align-content-start u-padding js-handlebars-root" id="FilesListContainer" data-template="FilesContainerScript" data-pre-render-template="FilesPreRenderContainer" data-json-feed="@feedPageUrl" data-save-cookie="true" data-preloader="overlay"></div> 2794 } 2795 2796 @helper RenderFilesContainerScript() 2797 { 2798 List<Block> subBlocks = this.filesPage.GetBlockListById("FilesContainerScript").OrderBy(item => item.SortId).ToList(); 2799 2800 <script id="FilesContainerScript" type="text/x-template"> 2801 {{#each .}} 2802 @RenderBlockList(subBlocks) 2803 {{else}} 2804 <div class="grid__col-12"> 2805 @Render(new Heading { Level = 2, Title = Translate("Your search gave 0 results"), CssClass = "u-ta-center" }) 2806 </div> 2807 {{/each}} 2808 </script> 2809 } 2810 2811 @helper RenderFiles() 2812 { 2813 <div id="Files" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod" data-save-cookie="true"> 2814 {{#Files}} 2815 {{> (lookup . 'template') }} 2816 {{/Files}} 2817 </div> 2818 } 2819 2820 @helper RenderLoadMore() 2821 { 2822 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 2823 2824 Button loadMore = new Button 2825 { 2826 Title = Translate("Load") + " {{pageSize}} " + Translate("more"), 2827 OnClick = "LoadMore.Next(this)", 2828 ButtonLayout = ButtonLayout.Primary, 2829 CssClass = "btn--full {{nextdisabled}}", 2830 Disabled = !String.IsNullOrEmpty("{{nextdisabled}}") ? false : true 2831 }; 2832 loadMore.ExtraAttributes.Add("data-current", "{{currentPage}}"); 2833 loadMore.ExtraAttributes.Add("data-page-size", "{{pageSize}}"); 2834 loadMore.ExtraAttributes.Add("data-total", "{{totalPages}}"); 2835 loadMore.ExtraAttributes.Add("data-container", "Files"); 2836 loadMore.ExtraAttributes.Add("data-feed-url", "/Default.aspx?ID=" + feedPageId); 2837 2838 @Render(loadMore) 2839 @Render(new Button { Title = Translate("Return to top"), ButtonLayout = ButtonLayout.Clean, OnClick = "window.scroll(0, 0)" }) 2840 } 2841 2842 @helper RenderPreRenderTemplate() 2843 { 2844 <script id="FilesPreRenderContainer" type="text/x-template"> 2845 <div class="grid__col-3"> 2846 <div class="pre-render-element pre-render-element--xs"></div> 2847 <div class="pre-render-element pre-render-element--md"></div> 2848 <div class="pre-render-element pre-render-element--md"></div> 2849 <div class="pre-render-element pre-render-element--md"></div> 2850 </div> 2851 <div class="grid__col-auto"> 2852 <div class="pre-render-element pre-render-element--xs"></div> 2853 <div class="pre-render-element pre-render-element--xs"></div> 2854 <div class="pre-render-element pre-render-element--lg"></div> 2855 <div class="pre-render-element pre-render-element--lg"></div> 2856 <div class="pre-render-element pre-render-element--lg"></div> 2857 <div class="pre-render-element pre-render-element--lg"></div> 2858 </div> 2859 </script> 2860 } 2861 2862 @helper RenderJavascript() 2863 { 2864 int filesFeedPageId = GetPageIdByNavigationTag("FilesFeed"); 2865 2866 <script> 2867 document.addEventListener("DOMContentLoaded", function (event) { 2868 2869 document.getElementById("FilesListContainer").addEventListener('contentLoaded', function (e) { 2870 if (getTarget(e).id === "FilesListContainer") { 2871 Search.Init(); 2872 Facets.Init("selectedFacets", "FilesListContainer"); 2873 } 2874 }, false); 2875 }); 2876 2877 function addFileToDownloads(path) { 2878 document.getElementById('assetPath').value = path; 2879 document.getElementById('DownloadModalTrigger').checked = true; 2880 } 2881 </script> 2882 }