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