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_07729f1cb700489aaed7af6d5f791cc7.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 @using Dynamicweb.Rapido.Blocks.Components.General 1466 @using Dynamicweb.Rapido.Blocks.Components 1467 1468 1469 @* Component *@ 1470 1471 @helper RenderLeftNavigation(LeftNavigation settings) { 1472 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 1473 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 1474 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 1475 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 1476 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 1477 1478 <div class="grid__cell"> 1479 @RenderNavigation(settings) 1480 </div> 1481 } 1482 @using System.Reflection 1483 @using Dynamicweb.Rapido.Blocks.Components.General 1484 @using Dynamicweb.Core 1485 1486 @* Component *@ 1487 1488 @helper RenderHeading(Heading settings) 1489 { 1490 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 1491 { 1492 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 1493 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 1494 1495 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 1496 if (!string.IsNullOrEmpty(settings.Link)) 1497 { 1498 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 1499 } 1500 else 1501 { 1502 if (settings.Icon == null) 1503 { 1504 settings.Icon = new Icon(); 1505 } 1506 settings.Icon.Label = settings.Title; 1507 @Render(settings.Icon) 1508 } 1509 @("</" + tagName + ">"); 1510 } 1511 } 1512 @using Dynamicweb.Rapido.Blocks.Components 1513 @using Dynamicweb.Rapido.Blocks.Components.General 1514 @using Dynamicweb.Rapido.Blocks 1515 1516 1517 @* Component *@ 1518 1519 @helper RenderImage(Image settings) 1520 { 1521 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 1522 { 1523 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1524 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 1525 1526 if (settings.Caption != null) 1527 { 1528 @:<div> 1529 } 1530 1531 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 1532 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 1533 1534 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 1535 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 1536 @if (settings.Link != null) 1537 { 1538 <a href="@settings.Link"> 1539 @RenderTheImage(settings) 1540 </a> 1541 } 1542 else 1543 { 1544 @RenderTheImage(settings) 1545 } 1546 </div> 1547 </div> 1548 1549 if (settings.Caption != null) 1550 { 1551 <span class="image-caption dw-mod">@settings.Caption</span> 1552 @:</div> 1553 } 1554 } 1555 else 1556 { 1557 if (settings.Caption != null) 1558 { 1559 @:<div> 1560 } 1561 if (!string.IsNullOrEmpty(settings.Link)) 1562 { 1563 <a href="@settings.Link"> 1564 @RenderTheImage(settings) 1565 </a> 1566 } 1567 else 1568 { 1569 @RenderTheImage(settings) 1570 } 1571 1572 if (settings.Caption != null) 1573 { 1574 <span class="image-caption dw-mod">@settings.Caption</span> 1575 @:</div> 1576 } 1577 } 1578 } 1579 1580 @helper RenderTheImage(Image settings) 1581 { 1582 if (settings != null) 1583 { 1584 string placeholderImage = "/Files/Images/placeholder.gif"; 1585 string imageEngine = "/Admin/Public/GetImage.ashx?"; 1586 1587 string imageStyle = ""; 1588 1589 switch (settings.Style) 1590 { 1591 case ImageStyle.Ball: 1592 imageStyle = "grid__cell-img--ball"; 1593 break; 1594 } 1595 1596 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 1597 { 1598 if (settings.ImageDefault != null) 1599 { 1600 settings.ImageDefault.Height = settings.ImageDefault.Width; 1601 } 1602 if (settings.ImageMedium != null) 1603 { 1604 settings.ImageMedium.Height = settings.ImageMedium.Width; 1605 } 1606 if (settings.ImageSmall != null) 1607 { 1608 settings.ImageSmall.Height = settings.ImageSmall.Width; 1609 } 1610 } 1611 1612 string defaultImage = imageEngine; 1613 string imageSmall = ""; 1614 string imageMedium = ""; 1615 1616 string SVGimg = settings.Path.ToString(); 1617 1618 if(SVGimg.EndsWith(".svg&")){ 1619 settings.Path=SVGimg.Substring(0,SVGimg.Length-1); 1620 } 1621 1622 if (settings.DisableImageEngine || settings.Path.ToString().EndsWith(".svg")) 1623 { 1624 defaultImage = settings.Path.ToString(); 1625 } 1626 else 1627 { 1628 if (settings.ImageDefault != null) 1629 { 1630 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 1631 1632 if (settings.Path.GetType() != typeof(string)) 1633 { 1634 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1635 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1636 } 1637 else 1638 { 1639 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 1640 } 1641 } 1642 1643 if (settings.ImageSmall != null) 1644 { 1645 imageSmall = "data-src-small=\"" + imageEngine; 1646 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 1647 1648 if (settings.Path.GetType() != typeof(string)) 1649 { 1650 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1651 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1652 } 1653 else 1654 { 1655 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 1656 } 1657 1658 imageSmall += "\""; 1659 } 1660 1661 if (settings.ImageMedium != null) 1662 { 1663 imageMedium = "data-src-medium=\"" + imageEngine; 1664 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 1665 1666 if (settings.Path.GetType() != typeof(string)) 1667 { 1668 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 1669 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 1670 } 1671 else 1672 { 1673 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 1674 } 1675 1676 imageMedium += "\""; 1677 } 1678 } 1679 1680 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1681 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 1682 if (!string.IsNullOrEmpty(settings.Title)) 1683 { 1684 optionalAttributes.Add("alt", settings.Title); 1685 optionalAttributes.Add("title", settings.Title); 1686 } 1687 1688 if (settings.DisableLazyLoad) 1689 { 1690 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 1691 } 1692 else 1693 { 1694 <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) /> 1695 } 1696 } 1697 } 1698 @using System.Reflection 1699 @using Dynamicweb.Rapido.Blocks.Components.General 1700 @using Dynamicweb.Rapido.Blocks.Components 1701 1702 @* Component *@ 1703 1704 @helper RenderFileField(FileField settings) 1705 { 1706 var attributes = new Dictionary<string, string>(); 1707 if (string.IsNullOrEmpty(settings.Id)) 1708 { 1709 settings.Id = Guid.NewGuid().ToString("N"); 1710 } 1711 1712 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1713 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1714 if (settings.Required) { attributes.Add("required", "true"); } 1715 if (settings.Multiple) { attributes.Add("multiple", "true"); } 1716 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1717 if (string.IsNullOrEmpty(settings.ChooseFileText)) 1718 { 1719 settings.ChooseFileText = Translate("Choose file"); 1720 } 1721 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 1722 { 1723 settings.NoFilesChosenText = Translate("No files chosen..."); 1724 } 1725 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1726 1727 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 1728 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 1729 1730 attributes.Add("type", "file"); 1731 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1732 settings.CssClass = "u-full-width " + settings.CssClass; 1733 1734 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1735 1736 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1737 @if (!string.IsNullOrEmpty(settings.Label)) 1738 { 1739 <label for="@settings.Id">@settings.Label</label> 1740 } 1741 @if (!string.IsNullOrEmpty(settings.HelpText)) 1742 { 1743 <small class="form__help-text">@settings.HelpText</small> 1744 } 1745 1746 <div class="form__field-combi file-input u-no-margin dw-mod"> 1747 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 1748 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 1749 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 1750 @if (settings.UploadButton != null) 1751 { 1752 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 1753 @Render(settings.UploadButton) 1754 } 1755 </div> 1756 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1757 </div> 1758 } 1759 @using System.Reflection 1760 @using Dynamicweb.Rapido.Blocks.Components.General 1761 @using Dynamicweb.Rapido.Blocks.Components 1762 @using Dynamicweb.Core 1763 @using System.Linq 1764 1765 @* Component *@ 1766 1767 @helper RenderDateTimeField(DateTimeField settings) 1768 { 1769 if (string.IsNullOrEmpty(settings.Id)) 1770 { 1771 settings.Id = Guid.NewGuid().ToString("N"); 1772 } 1773 1774 var textField = new TextField { 1775 Name = settings.Name, 1776 Id = settings.Id, 1777 Label = settings.Label, 1778 HelpText = settings.HelpText, 1779 Value = settings.Value, 1780 Disabled = settings.Disabled, 1781 Required = settings.Required, 1782 ErrorMessage = settings.ErrorMessage, 1783 CssClass = settings.CssClass, 1784 WrapperCssClass = settings.WrapperCssClass, 1785 OnChange = settings.OnChange, 1786 OnClick = settings.OnClick, 1787 ExtraAttributes = settings.ExtraAttributes, 1788 // 1789 Placeholder = settings.Placeholder 1790 }; 1791 1792 @Render(textField) 1793 1794 List<string> jsAttributes = new List<string>(); 1795 1796 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 1797 1798 if (!string.IsNullOrEmpty(settings.DateFormat)) 1799 { 1800 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 1801 } 1802 if (!string.IsNullOrEmpty(settings.MinDate)) 1803 { 1804 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 1805 } 1806 if (!string.IsNullOrEmpty(settings.MaxDate)) 1807 { 1808 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 1809 } 1810 if (settings.IsInline) 1811 { 1812 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 1813 } 1814 if (settings.EnableTime) 1815 { 1816 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 1817 } 1818 if (settings.EnableWeekNumbers) 1819 { 1820 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 1821 } 1822 1823 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 1824 1825 <script> 1826 document.addEventListener("DOMContentLoaded", function () { 1827 flatpickr("#@textField.Id", { 1828 @string.Join(",", jsAttributes) 1829 }); 1830 }); 1831 </script> 1832 } 1833 @using System.Reflection 1834 @using Dynamicweb.Rapido.Blocks.Components.General 1835 @using Dynamicweb.Rapido.Blocks.Components 1836 1837 @* Component *@ 1838 1839 @helper RenderTextField(TextField settings) 1840 { 1841 var attributes = new Dictionary<string, string>(); 1842 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1843 { 1844 settings.Id = Guid.NewGuid().ToString("N"); 1845 } 1846 1847 /*base settings*/ 1848 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1849 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1850 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1851 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1852 if (settings.Required) { attributes.Add("required", "true"); } 1853 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1854 /*end*/ 1855 1856 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1857 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1858 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1859 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1860 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1861 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1862 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1863 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1864 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1865 settings.CssClass = "u-full-width " + settings.CssClass; 1866 1867 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1868 1869 string noMargin = "u-no-margin"; 1870 if (!settings.ReadOnly) { 1871 noMargin = ""; 1872 } 1873 if (settings.Id == "EcomOrderCustomerEAN") { 1874 noMargin = ""; 1875 } 1876 1877 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1878 @if (!string.IsNullOrEmpty(settings.Label)) 1879 { 1880 <label for="@settings.Id">@settings.Label</label> 1881 } 1882 @if (!string.IsNullOrEmpty(settings.HelpText)) 1883 { 1884 <small class="form__help-text">@settings.HelpText</small> 1885 } 1886 1887 @if (settings.ActionButton != null) 1888 { 1889 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1890 <div class="form__field-combi u-no-margin dw-mod"> 1891 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1892 @Render(settings.ActionButton) 1893 </div> 1894 } 1895 else 1896 { 1897 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1898 } 1899 1900 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1901 </div> 1902 } 1903 @using System.Reflection 1904 @using Dynamicweb.Rapido.Blocks.Components.General 1905 @using Dynamicweb.Rapido.Blocks.Components 1906 1907 @* Component *@ 1908 1909 @helper RenderNumberField(NumberField settings) 1910 { 1911 var attributes = new Dictionary<string, string>(); 1912 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1913 { 1914 settings.Id = Guid.NewGuid().ToString("N"); 1915 } 1916 1917 /*base settings*/ 1918 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1919 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1920 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1921 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1922 if (settings.Required) { attributes.Add("required", "true"); } 1923 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1924 /*end*/ 1925 1926 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1927 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1928 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1929 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1930 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1931 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1932 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1933 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1934 attributes.Add("type", "number"); 1935 1936 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1937 1938 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1939 @if (!string.IsNullOrEmpty(settings.Label)) 1940 { 1941 <label for="@settings.Id">@settings.Label</label> 1942 } 1943 @if (!string.IsNullOrEmpty(settings.HelpText)) 1944 { 1945 <small class="form__help-text">@settings.HelpText</small> 1946 } 1947 1948 @if (settings.ActionButton != null) 1949 { 1950 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1951 <div class="form__field-combi u-no-margin dw-mod"> 1952 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1953 @Render(settings.ActionButton) 1954 </div> 1955 } 1956 else 1957 { 1958 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1959 } 1960 1961 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1962 </div> 1963 } 1964 @using System.Reflection 1965 @using Dynamicweb.Rapido.Blocks.Components.General 1966 @using Dynamicweb.Rapido.Blocks.Components 1967 1968 1969 @* Component *@ 1970 1971 @helper RenderTextareaField(TextareaField settings) 1972 { 1973 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1974 string id = settings.Id; 1975 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1976 { 1977 id = Guid.NewGuid().ToString("N"); 1978 } 1979 1980 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1981 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1982 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1983 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1984 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1985 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1986 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1987 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1988 if (settings.Required) { attributes.Add("required", "true"); } 1989 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1990 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1991 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1992 attributes.Add("name", settings.Name); 1993 1994 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1995 @if (!string.IsNullOrEmpty(settings.Label)) 1996 { 1997 <label for="@id">@settings.Label</label> 1998 } 1999 @if (!string.IsNullOrEmpty(settings.HelpText)) 2000 { 2001 <small class="form__help-text">@settings.HelpText</small> 2002 } 2003 2004 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 2005 2006 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2007 </div> 2008 } 2009 @using System.Reflection 2010 @using Dynamicweb.Rapido.Blocks.Components.General 2011 @using Dynamicweb.Rapido.Blocks.Components 2012 2013 2014 @* Component *@ 2015 2016 @helper RenderHiddenField(HiddenField settings) { 2017 var attributes = new Dictionary<string, string>(); 2018 attributes.Add("type", "hidden"); 2019 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2020 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2021 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2022 2023 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 2024 } 2025 @using System.Reflection 2026 @using Dynamicweb.Rapido.Blocks.Components.General 2027 @using Dynamicweb.Rapido.Blocks.Components 2028 2029 @* Component *@ 2030 2031 @helper RenderCheckboxField(CheckboxField settings) 2032 { 2033 var attributes = new Dictionary<string, string>(); 2034 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2035 { 2036 settings.Id = Guid.NewGuid().ToString("N"); 2037 } 2038 2039 /*base settings*/ 2040 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2041 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2042 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2043 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2044 if (settings.Required) { attributes.Add("required", "true"); } 2045 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2046 /*end*/ 2047 2048 attributes.Add("type", "checkbox"); 2049 if (settings.Checked) { attributes.Add("checked", "true"); } 2050 settings.CssClass = "form__control " + settings.CssClass; 2051 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2052 2053 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2054 2055 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2056 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2057 @if (!string.IsNullOrEmpty(settings.Label)) 2058 { 2059 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2060 } 2061 @if (!string.IsNullOrEmpty(settings.HelpText)) 2062 { 2063 <small class="form__help-text">@settings.HelpText</small> 2064 } 2065 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2066 </div> 2067 } 2068 @using System.Reflection 2069 @using Dynamicweb.Rapido.Blocks.Components.General 2070 @using Dynamicweb.Rapido.Blocks.Components 2071 2072 2073 @* Component *@ 2074 2075 @helper RenderCheckboxListField(CheckboxListField settings) 2076 { 2077 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2078 @if (!string.IsNullOrEmpty(settings.Label)) 2079 { 2080 <label>@settings.Label</label> 2081 } 2082 @if (!string.IsNullOrEmpty(settings.HelpText)) 2083 { 2084 <small class="form__help-text">@settings.HelpText</small> 2085 } 2086 2087 @foreach (var item in settings.Options) 2088 { 2089 if (settings.Required) 2090 { 2091 item.Required = true; 2092 } 2093 if (settings.Disabled) 2094 { 2095 item.Disabled = true; 2096 } 2097 if (!string.IsNullOrEmpty(settings.Name)) 2098 { 2099 item.Name = settings.Name; 2100 } 2101 if (!string.IsNullOrEmpty(settings.CssClass)) 2102 { 2103 item.CssClass += settings.CssClass; 2104 } 2105 2106 /* value is not supported */ 2107 2108 if (!string.IsNullOrEmpty(settings.OnClick)) 2109 { 2110 item.OnClick += settings.OnClick; 2111 } 2112 if (!string.IsNullOrEmpty(settings.OnChange)) 2113 { 2114 item.OnChange += settings.OnChange; 2115 } 2116 @Render(item) 2117 } 2118 2119 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2120 </div> 2121 } 2122 @using System.Reflection 2123 @using Dynamicweb.Rapido.Blocks.Components.General 2124 @using Dynamicweb.Rapido.Blocks.Components 2125 2126 2127 @* Component *@ 2128 2129 @helper RenderSelectField(SelectField settings) 2130 { 2131 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2132 { 2133 settings.Id = Guid.NewGuid().ToString("N"); 2134 } 2135 2136 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 2137 @if (!string.IsNullOrEmpty(settings.Label)) 2138 { 2139 <label for="@settings.Id">@settings.Label</label> 2140 } 2141 @if (!string.IsNullOrEmpty(settings.HelpText)) 2142 { 2143 <small class="form__help-text">@settings.HelpText</small> 2144 } 2145 2146 @if (settings.ActionButton != null) 2147 { 2148 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 2149 <div class="form__field-combi u-no-margin dw-mod"> 2150 @RenderSelectBase(settings) 2151 @Render(settings.ActionButton) 2152 </div> 2153 } 2154 else 2155 { 2156 @RenderSelectBase(settings) 2157 } 2158 2159 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2160 </div> 2161 } 2162 2163 @helper RenderSelectBase(SelectField settings) 2164 { 2165 var attributes = new Dictionary<string, string>(); 2166 2167 /*base settings*/ 2168 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2169 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2170 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2171 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2172 if (settings.Required) { attributes.Add("required", "true"); } 2173 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2174 /*end*/ 2175 2176 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2177 2178 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 2179 @if (settings.Default != null) 2180 { 2181 @Render(settings.Default) 2182 } 2183 2184 @foreach (var item in settings.Options) 2185 { 2186 if (!string.IsNullOrEmpty(settings.Value)) { 2187 item.Checked = item.Value == settings.Value; 2188 } 2189 @Render(item) 2190 } 2191 </select> 2192 } 2193 @using System.Reflection 2194 @using Dynamicweb.Rapido.Blocks.Components.General 2195 @using Dynamicweb.Rapido.Blocks.Components 2196 2197 @* Component *@ 2198 2199 @helper RenderRadioButtonField(RadioButtonField settings) 2200 { 2201 var attributes = new Dictionary<string, string>(); 2202 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 2203 { 2204 settings.Id = Guid.NewGuid().ToString("N"); 2205 } 2206 2207 /*base settings*/ 2208 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2209 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 2210 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 2211 if (settings.Disabled) { attributes.Add("disabled", "true"); } 2212 if (settings.Required) { attributes.Add("required", "true"); } 2213 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 2214 /*end*/ 2215 2216 attributes.Add("type", "radio"); 2217 if (settings.Checked) { attributes.Add("checked", "true"); } 2218 settings.CssClass = "form__control " + settings.CssClass; 2219 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 2220 2221 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 2222 2223 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 2224 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 2225 @if (!string.IsNullOrEmpty(settings.Label)) 2226 { 2227 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 2228 } 2229 @if (!string.IsNullOrEmpty(settings.HelpText)) 2230 { 2231 <small class="form__help-text">@settings.HelpText</small> 2232 } 2233 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2234 </div> 2235 } 2236 @using System.Reflection 2237 @using Dynamicweb.Rapido.Blocks.Components.General 2238 @using Dynamicweb.Rapido.Blocks.Components 2239 2240 2241 @* Component *@ 2242 2243 @helper RenderRadioButtonListField(RadioButtonListField settings) 2244 { 2245 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2246 @if (!string.IsNullOrEmpty(settings.Label)) 2247 { 2248 <label>@settings.Label</label> 2249 } 2250 @if (!string.IsNullOrEmpty(settings.HelpText)) 2251 { 2252 <small class="form__help-text">@settings.HelpText</small> 2253 } 2254 2255 @foreach (var item in settings.Options) 2256 { 2257 if (settings.Required) 2258 { 2259 item.Required = true; 2260 } 2261 if (settings.Disabled) 2262 { 2263 item.Disabled = true; 2264 } 2265 if (!string.IsNullOrEmpty(settings.Name)) 2266 { 2267 item.Name = settings.Name; 2268 } 2269 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 2270 { 2271 item.Checked = true; 2272 } 2273 if (!string.IsNullOrEmpty(settings.OnClick)) 2274 { 2275 item.OnClick += settings.OnClick; 2276 } 2277 if (!string.IsNullOrEmpty(settings.OnChange)) 2278 { 2279 item.OnChange += settings.OnChange; 2280 } 2281 if (!string.IsNullOrEmpty(settings.CssClass)) 2282 { 2283 item.CssClass += settings.CssClass; 2284 } 2285 @Render(item) 2286 } 2287 2288 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 2289 </div> 2290 } 2291 @using System.Reflection 2292 @using Dynamicweb.Rapido.Blocks.Components.General 2293 @using Dynamicweb.Rapido.Blocks.Components 2294 2295 2296 @* Component *@ 2297 2298 @helper RenderNotificationMessage(NotificationMessage settings) 2299 { 2300 if (!string.IsNullOrEmpty(settings.Message)) 2301 { 2302 var attributes = new Dictionary<string, string>(); 2303 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2304 2305 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 2306 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 2307 } 2308 } 2309 @using Dynamicweb.Rapido.Blocks.Components.General 2310 2311 2312 @* Component *@ 2313 2314 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 2315 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 2316 2317 <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> 2318 @if (settings.SubBlocks != null) { 2319 @RenderBlockList(settings.SubBlocks) 2320 } 2321 </div> 2322 } 2323 @using System.Reflection 2324 @using Dynamicweb.Rapido.Blocks.Components.General 2325 @using Dynamicweb.Rapido.Blocks.Components 2326 @using System.Text.RegularExpressions 2327 2328 2329 @* Component *@ 2330 2331 @helper RenderSticker(Sticker settings) { 2332 if (!String.IsNullOrEmpty(settings.Title)) { 2333 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 2334 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 2335 2336 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 2337 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 2338 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 2339 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 2340 optionalAttributes.Add("style", styleTag); 2341 } 2342 2343 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 2344 } 2345 } 2346 2347 @using System.Reflection 2348 @using Dynamicweb.Rapido.Blocks.Components.General 2349 @using Dynamicweb.Rapido.Blocks.Components 2350 2351 2352 @* Component *@ 2353 2354 @helper RenderStickersCollection(StickersCollection settings) 2355 { 2356 if (settings.Stickers.Count > 0) 2357 { 2358 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 2359 2360 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2361 @foreach (Sticker sticker in settings.Stickers) 2362 { 2363 @Render(sticker) 2364 } 2365 </div> 2366 } 2367 } 2368 2369 @using Dynamicweb.Rapido.Blocks.Components.General 2370 2371 2372 @* Component *@ 2373 2374 @helper RenderForm(Form settings) { 2375 if (settings != null) 2376 { 2377 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 2378 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 2379 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 2380 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 2381 var enctypes = new Dictionary<string, string> 2382 { 2383 { "multipart", "multipart/form-data" }, 2384 { "text", "text/plain" }, 2385 { "application", "application/x-www-form-urlencoded" } 2386 }; 2387 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 2388 optionalAttributes.Add("method", settings.Method.ToString()); 2389 2390 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 2391 { 2392 @settings.FormStartMarkup 2393 } 2394 else 2395 { 2396 @:<form name="@settings.Name" class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 2397 } 2398 2399 foreach (var field in settings.GetFields()) 2400 { 2401 @Render(field) 2402 } 2403 2404 @:</form> 2405 } 2406 } 2407 @using System.Reflection 2408 @using Dynamicweb.Rapido.Blocks.Components.General 2409 @using Dynamicweb.Rapido.Blocks.Components 2410 2411 2412 @* Component *@ 2413 2414 @helper RenderText(Text settings) 2415 { 2416 @settings.Content 2417 } 2418 @using System.Reflection 2419 @using Dynamicweb.Rapido.Blocks.Components.General 2420 @using Dynamicweb.Rapido.Blocks.Components 2421 2422 2423 @* Component *@ 2424 2425 @helper RenderContentModule(ContentModule settings) { 2426 if (!string.IsNullOrEmpty(settings.Content)) 2427 { 2428 @settings.Content 2429 } 2430 } 2431 @using System.Reflection 2432 @using Dynamicweb.Rapido.Blocks.Components.General 2433 @using Dynamicweb.Rapido.Blocks.Components 2434 2435 2436 @* Component *@ 2437 2438 @helper RenderModal(Modal settings) { 2439 if (settings != null) 2440 { 2441 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 2442 2443 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 2444 2445 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 2446 2447 <div class="modal-container"> 2448 @if (!settings.DisableDarkOverlay) 2449 { 2450 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 2451 } 2452 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 2453 @if (settings.Heading != null) 2454 { 2455 if (!string.IsNullOrEmpty(settings.Heading.Title)) 2456 { 2457 <div class="modal__header"> 2458 @Render(settings.Heading) 2459 </div> 2460 } 2461 } 2462 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 2463 @if (!string.IsNullOrEmpty(settings.BodyText)) 2464 { 2465 @settings.BodyText 2466 } 2467 @if (settings.BodyTemplate != null) 2468 { 2469 @settings.BodyTemplate 2470 } 2471 @{ 2472 var actions = settings.GetActions(); 2473 } 2474 </div> 2475 @if (actions.Length > 0) 2476 { 2477 <div class="modal__footer"> 2478 @foreach (var action in actions) 2479 { 2480 action.CssClass += " u-no-margin"; 2481 @Render(action) 2482 } 2483 </div> 2484 } 2485 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 2486 </div> 2487 </div> 2488 } 2489 } 2490 @using Dynamicweb.Rapido.Blocks.Components.General 2491 2492 @* Component *@ 2493 2494 @helper RenderMediaListItem(MediaListItem settings) 2495 { 2496 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 2497 @if (!string.IsNullOrEmpty(settings.Label)) 2498 { 2499 if (!string.IsNullOrEmpty(settings.Link)) 2500 { 2501 @Render(new Link 2502 { 2503 Href = settings.Link, 2504 CssClass = "media-list-item__sticker dw-mod", 2505 ButtonLayout = ButtonLayout.None, 2506 Title = settings.Label, 2507 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2508 }) 2509 } 2510 else if (!string.IsNullOrEmpty(settings.OnClick)) 2511 { 2512 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 2513 <span class="u-uppercase">@settings.Label</span> 2514 </span> 2515 } 2516 else 2517 { 2518 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 2519 <span class="u-uppercase">@settings.Label</span> 2520 </span> 2521 } 2522 } 2523 <div class="media-list-item__wrap"> 2524 <div class="media-list-item__info dw-mod"> 2525 <div class="media-list-item__header dw-mod"> 2526 @if (!string.IsNullOrEmpty(settings.Title)) 2527 { 2528 if (!string.IsNullOrEmpty(settings.Link)) 2529 { 2530 @Render(new Link 2531 { 2532 Href = settings.Link, 2533 CssClass = "media-list-item__name dw-mod", 2534 ButtonLayout = ButtonLayout.None, 2535 Title = settings.Title, 2536 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 2537 }) 2538 } 2539 else if (!string.IsNullOrEmpty(settings.OnClick)) 2540 { 2541 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 2542 } 2543 else 2544 { 2545 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 2546 } 2547 } 2548 2549 @if (!string.IsNullOrEmpty(settings.Status)) 2550 { 2551 <div class="media-list-item__state dw-mod">@settings.Status</div> 2552 } 2553 </div> 2554 @{ 2555 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 2556 } 2557 2558 @Render(settings.InfoTable) 2559 </div> 2560 <div class="media-list-item__actions dw-mod"> 2561 <div class="media-list-item__actions-list dw-mod"> 2562 @{ 2563 var actions = settings.GetActions(); 2564 2565 foreach (ButtonBase action in actions) 2566 { 2567 action.ButtonLayout = ButtonLayout.None; 2568 action.CssClass += " media-list-item__action link"; 2569 2570 @Render(action) 2571 } 2572 } 2573 </div> 2574 2575 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 2576 { 2577 settings.SelectButton.CssClass += " u-no-margin"; 2578 2579 <div class="media-list-item__action-button"> 2580 @Render(settings.SelectButton) 2581 </div> 2582 } 2583 </div> 2584 </div> 2585 </div> 2586 } 2587 @using Dynamicweb.Rapido.Blocks.Components.General 2588 @using Dynamicweb.Rapido.Blocks.Components 2589 2590 @helper RenderTable(Table settings) 2591 { 2592 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2593 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2594 2595 var enumToClasses = new Dictionary<TableDesign, string> 2596 { 2597 { TableDesign.Clean, "table--clean" }, 2598 { TableDesign.Bordered, "table--bordered" }, 2599 { TableDesign.Striped, "table--striped" }, 2600 { TableDesign.Hover, "table--hover" }, 2601 { TableDesign.Compact, "table--compact" }, 2602 { TableDesign.Condensed, "table--condensed" }, 2603 { TableDesign.NoTopBorder, "table--no-top-border" } 2604 }; 2605 string tableDesignClass = ""; 2606 if (settings.Design != TableDesign.None) 2607 { 2608 tableDesignClass = enumToClasses[settings.Design]; 2609 } 2610 2611 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 2612 2613 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2614 2615 <table @ComponentMethods.AddAttributes(resultAttributes)> 2616 @if (settings.Header != null) 2617 { 2618 <thead> 2619 @Render(settings.Header) 2620 </thead> 2621 } 2622 <tbody> 2623 @foreach (var row in settings.Rows) 2624 { 2625 @Render(row) 2626 } 2627 </tbody> 2628 @if (settings.Footer != null) 2629 { 2630 <tfoot> 2631 @Render(settings.Footer) 2632 </tfoot> 2633 } 2634 </table> 2635 } 2636 @using Dynamicweb.Rapido.Blocks.Components.General 2637 @using Dynamicweb.Rapido.Blocks.Components 2638 2639 @helper RenderTableRow(TableRow settings) 2640 { 2641 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2642 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2643 2644 var enumToClasses = new Dictionary<TableRowDesign, string> 2645 { 2646 { TableRowDesign.NoBorder, "table__row--no-border" }, 2647 { TableRowDesign.Border, "table__row--border" }, 2648 { TableRowDesign.TopBorder, "table__row--top-line" }, 2649 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 2650 { TableRowDesign.Solid, "table__row--solid" } 2651 }; 2652 2653 string tableRowDesignClass = ""; 2654 if (settings.Design != TableRowDesign.None) 2655 { 2656 tableRowDesignClass = enumToClasses[settings.Design]; 2657 } 2658 2659 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 2660 2661 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2662 2663 <tr @ComponentMethods.AddAttributes(resultAttributes)> 2664 @foreach (var cell in settings.Cells) 2665 { 2666 if (settings.IsHeaderRow) 2667 { 2668 cell.IsHeader = true; 2669 } 2670 @Render(cell) 2671 } 2672 </tr> 2673 } 2674 @using Dynamicweb.Rapido.Blocks.Components.General 2675 @using Dynamicweb.Rapido.Blocks.Components 2676 @using Dynamicweb.Core 2677 2678 @helper RenderTableCell(TableCell settings) 2679 { 2680 Dictionary<string, string> attributes = new Dictionary<string, string>(); 2681 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 2682 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 2683 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 2684 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 2685 2686 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 2687 2688 string tagName = settings.IsHeader ? "th" : "td"; 2689 2690 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + ">") 2691 @settings.Content 2692 @("</" + tagName + ">"); 2693 } 2694 @using System.Linq 2695 @using Dynamicweb.Rapido.Blocks.Components.General 2696 2697 @* Component *@ 2698 2699 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 2700 { 2701 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 2702 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 2703 2704 if (settings.NumberOfPages > 1) 2705 { 2706 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 2707 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 2708 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 2709 2710 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 2711 @if (settings.ShowPagingInfo) 2712 { 2713 <div class="pager__info dw-mod"> 2714 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 2715 </div> 2716 } 2717 <ul class="pager__list dw-mod"> 2718 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 2719 { 2720 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 2721 } 2722 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 2723 { 2724 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 2725 } 2726 @if (settings.GetPages().Any()) 2727 { 2728 foreach (var page in settings.GetPages()) 2729 { 2730 @Render(page) 2731 } 2732 } 2733 else 2734 { 2735 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 2736 { 2737 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 2738 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 2739 } 2740 } 2741 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 2742 { 2743 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 2744 } 2745 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 2746 { 2747 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 2748 } 2749 </ul> 2750 </div> 2751 } 2752 } 2753 2754 @helper RenderPaginationItem(PaginationItem settings) 2755 { 2756 if (settings.Icon == null) 2757 { 2758 settings.Icon = new Icon(); 2759 } 2760 2761 settings.Icon.Label = settings.Label; 2762 <li class="pager__btn dw-mod"> 2763 @if (settings.IsActive) 2764 { 2765 <span class="pager__num pager__num--current dw-mod"> 2766 @Render(settings.Icon) 2767 </span> 2768 } 2769 else 2770 { 2771 <a href="@settings.Link" class="pager__num dw-mod"> 2772 @Render(settings.Icon) 2773 </a> 2774 } 2775 </li> 2776 } 2777 2778 2779 @using Dynamicweb.Rapido.Blocks.Components.General 2780 2781 2782 2783 2784 @RenderBlockList(filesPage.BlocksRoot.BlocksList) 2785 2786 @helper RenderPageContainer() 2787 { 2788 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 2789 string pageUrl = GetGlobalValue("Global:Pageview.Url.Raw"); 2790 string feedPageUrl = new Regex("([?&]ID)=[^?&]+").Replace(pageUrl, "?ID=" + feedPageId); 2791 2792 <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> 2793 } 2794 2795 @helper RenderFilesContainerScript() 2796 { 2797 List<Block> subBlocks = this.filesPage.GetBlockListById("FilesContainerScript").OrderBy(item => item.SortId).ToList(); 2798 2799 <script id="FilesContainerScript" type="text/x-template"> 2800 {{#each .}} 2801 @RenderBlockList(subBlocks) 2802 {{else}} 2803 <div class="grid__col-12"> 2804 @Render(new Heading { Level = 2, Title = Translate("Your search gave 0 results"), CssClass = "u-ta-center" }) 2805 </div> 2806 {{/each}} 2807 </script> 2808 } 2809 2810 @helper RenderFiles() 2811 { 2812 <div id="Files" data-template="{{listTemplate}}" class="grid product-list grid--external-bleed-x dw-mod" data-save-cookie="true"> 2813 {{#Files}} 2814 {{> (lookup . 'template') }} 2815 {{/Files}} 2816 </div> 2817 } 2818 2819 @helper RenderLoadMore() 2820 { 2821 int feedPageId = GetPageIdByNavigationTag("FilesFeed"); 2822 2823 Button loadMore = new Button 2824 { 2825 Title = Translate("Load") + " {{pageSize}} " + Translate("more"), 2826 OnClick = "LoadMore.Next(this)", 2827 ButtonLayout = ButtonLayout.Primary, 2828 CssClass = "btn--full {{nextdisabled}}", 2829 Disabled = !String.IsNullOrEmpty("{{nextdisabled}}") ? false : true 2830 }; 2831 loadMore.ExtraAttributes.Add("data-current", "{{currentPage}}"); 2832 loadMore.ExtraAttributes.Add("data-page-size", "{{pageSize}}"); 2833 loadMore.ExtraAttributes.Add("data-total", "{{totalPages}}"); 2834 loadMore.ExtraAttributes.Add("data-container", "Files"); 2835 loadMore.ExtraAttributes.Add("data-feed-url", "/Default.aspx?ID=" + feedPageId); 2836 2837 @Render(loadMore) 2838 @Render(new Button { Title = Translate("Return to top"), ButtonLayout = ButtonLayout.Clean, OnClick = "window.scroll(0, 0)" }) 2839 } 2840 2841 @helper RenderPreRenderTemplate() 2842 { 2843 <script id="FilesPreRenderContainer" type="text/x-template"> 2844 <div class="grid__col-3"> 2845 <div class="pre-render-element pre-render-element--xs"></div> 2846 <div class="pre-render-element pre-render-element--md"></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> 2850 <div class="grid__col-auto"> 2851 <div class="pre-render-element pre-render-element--xs"></div> 2852 <div class="pre-render-element pre-render-element--xs"></div> 2853 <div class="pre-render-element pre-render-element--lg"></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> 2858 </script> 2859 } 2860 2861 @helper RenderJavascript() 2862 { 2863 int filesFeedPageId = GetPageIdByNavigationTag("FilesFeed"); 2864 2865 <script> 2866 document.addEventListener("DOMContentLoaded", function (event) { 2867 2868 document.getElementById("FilesListContainer").addEventListener('contentLoaded', function (e) { 2869 if (getTarget(e).id === "FilesListContainer") { 2870 Search.Init(); 2871 Facets.Init("selectedFacets", "FilesListContainer"); 2872 } 2873 }, false); 2874 }); 2875 2876 function addFileToDownloads(path) { 2877 document.getElementById('assetPath').value = path; 2878 document.getElementById('DownloadModalTrigger').checked = true; 2879 } 2880 </script> 2881 }