From 4db042ea68f8d384ccf589c1703159428710622e Mon Sep 17 00:00:00 2001 From: Alper Ebicoglu Date: Fri, 18 Oct 2019 11:13:23 +0300 Subject: [PATCH] add bootstrap-datepicker --- .../BootstrapDatepickerScriptContributor.cs | 43 +++++++++++++++++++ .../BootstrapDatepickerStyleContributor.cs | 13 ++++++ .../SharedThemeGlobalScriptContributor.cs | 3 +- .../SharedThemeGlobalStyleContributor.cs | 3 +- .../package.json | 3 +- .../abp.resourcemapping.js | 8 ++++ npm/packs/bootstrap-datepicker/package.json | 10 +++++ 7 files changed, 80 insertions(+), 3 deletions(-) create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs create mode 100644 framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerStyleContributor.cs create mode 100644 npm/packs/bootstrap-datepicker/abp.resourcemapping.js create mode 100644 npm/packs/bootstrap-datepicker/package.json diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs new file mode 100644 index 0000000000..241822facf --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerScriptContributor.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Globalization; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; +using Volo.Abp.AspNetCore.Mvc.UI.Packages.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Timeago +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class BootstrapDatepickerScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/libs/bootstrap-datepicker/bootstrap-datepicker.min.js"); + } + + public override void ConfigureDynamicResources(BundleConfigurationContext context) + { + var cultureName = CultureInfo.CurrentUICulture.DateTimeFormat.Calendar.AlgorithmType == + CalendarAlgorithmType.LunarCalendar + ? "en" + : CultureInfo.CurrentUICulture.Name; + + if (TryAddCultureFile(context, cultureName)) + { + return; + } + } + + protected virtual bool TryAddCultureFile(BundleConfigurationContext context, string cultureName) + { + var filePath = $"/libs/bootstrap-datepicker/locales/bootstrap-datepicker.{cultureName}.js"; + + if (!context.FileProvider.GetFileInfo(filePath).Exists) + { + return false; + } + + context.Files.AddIfNotContains(filePath); + return true; + } + } +} diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerStyleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerStyleContributor.cs new file mode 100644 index 0000000000..bc345e34b3 --- /dev/null +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/BootstrapDatepicker/BootstrapDatepickerStyleContributor.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Packages.Select2 +{ + public class BootstrapDatepickerStyleContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.AddIfNotContains("/libs/bootstrap-datepicker/bootstrap-datepicker.min.css"); + } + } +} \ No newline at end of file diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs index d067281978..0f4cc752c9 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs @@ -27,7 +27,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling typeof(ToastrScriptBundleContributor), typeof(MalihuCustomScrollbarPluginScriptBundleContributor), typeof(LuxonScriptContributor), - typeof(TimeagoScriptContributor) + typeof(TimeagoScriptContributor), + typeof(BootstrapDatepickerScriptContributor) )] public class SharedThemeGlobalScriptContributor : BundleContributor { diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs index 23107c2d3a..d1703113d0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs @@ -17,7 +17,8 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling typeof(ToastrStyleBundleContributor), typeof(Select2StyleContributor), typeof(MalihuCustomScrollbarPluginStyleBundleContributor), - typeof(DatatablesNetBs4StyleContributor) + typeof(DatatablesNetBs4StyleContributor), + typeof(BootstrapDatepickerStyleContributor) )] public class SharedThemeGlobalStyleContributor : BundleContributor { diff --git a/npm/packs/aspnetcore.mvc.ui.theme.shared/package.json b/npm/packs/aspnetcore.mvc.ui.theme.shared/package.json index f59f66fb49..3739a97963 100644 --- a/npm/packs/aspnetcore.mvc.ui.theme.shared/package.json +++ b/npm/packs/aspnetcore.mvc.ui.theme.shared/package.json @@ -17,7 +17,8 @@ "@abp/select2": "^0.9.0", "@abp/sweetalert": "^0.9.0", "@abp/timeago": "^0.9.0", - "@abp/toastr": "^0.9.0" + "@abp/toastr": "^0.9.0", + "@abp/bootstrap-datepicker": "^0.9.0" }, "gitHead": "4d6791834b7723d8ad78ba4d23ae3425f170fdeb" } diff --git a/npm/packs/bootstrap-datepicker/abp.resourcemapping.js b/npm/packs/bootstrap-datepicker/abp.resourcemapping.js new file mode 100644 index 0000000000..76b875f37f --- /dev/null +++ b/npm/packs/bootstrap-datepicker/abp.resourcemapping.js @@ -0,0 +1,8 @@ +module.exports = { + mappings: { + "@node_modules/bootstrap-datepicker/dist/js/bootstrap-datepicker.min.js": "@libs/bootstrap-datepicker/", + "@node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css": "@libs/bootstrap-datepicker/", + "@node_modules/bootstrap-datepicker/dist/css/bootstrap-datepicker.css.map": "@libs/bootstrap-datepicker/", + "@node_modules/bootstrap-datepicker/dist/locales/*.*": "@libs/bootstrap-datepicker/locales/" + } +} \ No newline at end of file diff --git a/npm/packs/bootstrap-datepicker/package.json b/npm/packs/bootstrap-datepicker/package.json new file mode 100644 index 0000000000..fbf28cc370 --- /dev/null +++ b/npm/packs/bootstrap-datepicker/package.json @@ -0,0 +1,10 @@ +{ + "version": "0.9.0", + "name": "@abp/bootstrap-datepicker", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "bootstrap-datepicker": "^1.9.0" + } +}