From 61b0bd6e7e5313fb888f0dd45fda60ee654842cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Mon, 7 Sep 2020 15:30:31 +0300 Subject: [PATCH] AbpComponentDemoSectionTagHelper updated --- .../AbpComponentDemoSectionTagHelper.cs | 82 ++++++++++++++----- .../wwwroot/libs/abp/luxon/abp.luxon.js | 46 +++++++++++ 2 files changed, 107 insertions(+), 21 deletions(-) create mode 100644 framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/wwwroot/libs/abp/luxon/abp.luxon.js diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs index 5b3bd7791a..bace14b124 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo/Views/Components/Themes/Shared/TagHelpers/AbpComponentDemoSectionTagHelper.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Razor.TagHelpers; using Microsoft.Extensions.FileProviders; using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; +using Volo.Abp.Guids; using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.Shared.TagHelpers @@ -17,10 +18,14 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.S public string Title { get; set; } private readonly IVirtualFileProvider _virtualFileProvider; + private readonly IGuidGenerator _guidGenerator; - public AbpComponentDemoSectionTagHelper(IVirtualFileProvider virtualFileProvider) + public AbpComponentDemoSectionTagHelper( + IVirtualFileProvider virtualFileProvider, + IGuidGenerator guidGenerator) { _virtualFileProvider = virtualFileProvider; + _guidGenerator = guidGenerator; } public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output) @@ -29,34 +34,69 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Demo.Views.Components.Themes.S var content = await output.GetChildContentAsync(); - output.PreContent.AppendHtml("
"); - output.PreContent.AppendHtml($"

{Title}

"); - output.PreContent.AppendHtml("
"); + var previewId = _guidGenerator.Create(); + var codeBlockId = _guidGenerator.Create(); + + var codeBlockTabId = _guidGenerator.Create(); + var tagHelperCodeBlockId = _guidGenerator.Create(); + var bootstrapCodeBlockId = _guidGenerator.Create(); + + output.PreContent.AppendHtml("
"); + output.PreContent.AppendHtml("
"); + output.PreContent.AppendHtml("
"); + output.PreContent.AppendHtml($"

{Title}

"); + output.PreContent.AppendHtml("
"); + output.PreContent.AppendHtml(""); + output.PreContent.AppendHtml("
"); // col-auto + output.PreContent.AppendHtml("
"); // row + output.PreContent.AppendHtml("
"); // card-header + output.PreContent.AppendHtml("
"); + output.PreContent.AppendHtml($"
"); + output.PreContent.AppendHtml($"
"); + /* component rendering here */ - output.PostContent.AppendHtml("
"); //abp-component-demo-section-body - AppendRawSource(output); - AppendBootstrapSource(output, content); - output.PostContent.AppendHtml("
"); //abp-component-demo-section - } - private static void AppendBootstrapSource(TagHelperOutput output, TagHelperContent content) - { - output.PostContent.AppendHtml("
"); - output.PostContent.AppendHtml("

Bootstrap

"); + output.PostContent.AppendHtml("
"); // tab-pane + output.PostContent.AppendHtml($"
"); + + /* CodeBlock tabs */ + + output.PostContent.AppendHtml($"
    "); + output.PostContent.AppendHtml("
  • "); + output.PostContent.AppendHtml($"Abp Tag Helper"); + output.PostContent.AppendHtml("
  • "); + output.PostContent.AppendHtml("
  • "); + output.PostContent.AppendHtml($"Bootstrap Render"); + output.PostContent.AppendHtml("
  • "); + output.PostContent.AppendHtml("
"); + output.PostContent.AppendHtml($"
"); + + output.PostContent.AppendHtml($"
"); output.PostContent.AppendHtml("
");
-            output.PostContent.Append(content.GetContent());
+            output.PostContent.AppendHtml("");
+            output.PostContent.Append(GetRawDemoSource());
+            output.PostContent.AppendHtml("");
             output.PostContent.AppendHtml("
"); output.PostContent.AppendHtml("
"); - } - - private void AppendRawSource(TagHelperOutput output) - { - output.PostContent.AppendHtml("
"); - output.PostContent.AppendHtml("

ABP Tag Helpers

"); + + output.PostContent.AppendHtml($"
"); output.PostContent.AppendHtml("
");
-            output.PostContent.Append(GetRawDemoSource());
+            output.PostContent.AppendHtml("");
+            output.PostContent.Append(content.GetContent());
+            output.PostContent.AppendHtml("");
             output.PostContent.AppendHtml("
"); output.PostContent.AppendHtml("
"); + + output.PostContent.AppendHtml("
"); // tab-content + output.PostContent.AppendHtml("
"); // tab-pane + output.PostContent.AppendHtml("
"); // tab-content + output.PostContent.AppendHtml("
"); // card-body + output.PostContent.AppendHtml("
"); // card } private string GetRawDemoSource() diff --git a/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/wwwroot/libs/abp/luxon/abp.luxon.js b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/wwwroot/libs/abp/luxon/abp.luxon.js new file mode 100644 index 0000000000..b04de7cadf --- /dev/null +++ b/framework/test/Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Demo/wwwroot/libs/abp/luxon/abp.luxon.js @@ -0,0 +1,46 @@ +var abp = abp || {}; +(function () { + + if (!luxon) { + throw "abp/luxon library requires the luxon library included to the page!"; + } + + /* TIMING *************************************************/ + + abp.timing = abp.timing || {}; + + var setObjectValue = function (obj, property, value) { + if (typeof property === "string") { + property = property.split('.'); + } + + if (property.length > 1) { + var p = property.shift(); + setObjectValue(obj[p], property, value); + } else { + obj[property[0]] = value; + } + } + + var getObjectValue = function (obj, property) { + return property.split('.').reduce((a, v) => a[v], obj) + } + + abp.timing.convertFieldsToIsoDate = function (form, fields) { + for (var field of fields) { + var dateTime = luxon.DateTime + .fromFormat( + getObjectValue(form, field), + abp.localization.currentCulture.dateTimeFormat.shortDatePattern, + {locale: abp.localization.currentCulture.cultureName} + ); + + if (!dateTime.invalid) { + setObjectValue(form, field, dateTime.toFormat("yyyy-MM-dd HH:mm:ss")) + } + } + + return form; + } + +})(jQuery);