diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs index 8cb16f54d4..733331e28a 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalScriptContributor.cs @@ -1,29 +1,40 @@ using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNet; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNetBs4; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryForm; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryValidation; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryValidationUnobtrusive; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.SweetAlert; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Toastr; using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling { [DependsOn( - typeof(BootstrapScriptBundleContributor) + typeof(JQueryScriptContributor), + typeof(BootstrapScriptContributor), + typeof(JQueryValidationScriptContributor), + typeof(JQueryValidationUnobtrusiveScriptContributor), + typeof(JQueryFormScriptContributor), + typeof(DatatablesNetScriptContributor), + typeof(DatatablesNetBs4ScriptContributor), + typeof(SweetalertScriptContributor), + typeof(ToastrScriptBundleContributor) )] public class SharedThemeGlobalScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { context.Files.AddRange(new[] - { //TODO: Create seperated contributors! - "/libs/jquery-validation/jquery.validate.js", - "/libs/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js", - "/libs/jquery-form/jquery.form.min.js", - "/libs/datatables.net/js/jquery.dataTables.js", - "/libs/datatables.net-bs4/js/dataTables.bootstrap4.js", - "/libs/sweetalert/sweetalert.min.js", - "/libs/toastr/toastr.min.js", + { + //TODO: Move to their own contributors, but first consider to change abp.js a bit "/libs/abp/core/abp.js", "/libs/abp/jquery/abp.dom.js", "/libs/abp/jquery/abp.ajax.js", "/libs/abp/jquery/abp.resource-loader.js", + "/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery/jquery-extensions.js", "/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js", "/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js", diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs index bc7bc1355d..3bc2702144 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/Bundling/SharedThemeGlobalStyleContributor.cs @@ -8,10 +8,10 @@ using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Bundling { [DependsOn( - typeof(BootstrapStyleBundleContributor), - typeof(FontAwesomeStyleBundleContributor), + typeof(BootstrapStyleContributor), + typeof(FontAwesomeStyleContributor), typeof(ToastrStyleBundleContributor), - typeof(DatatablesNetBs4StyleBundleContributor) + typeof(DatatablesNetBs4StyleContributor) )] public class SharedThemeGlobalStyleContributor : BundleContributor { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleContributorCollection.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleContributorCollection.cs index 1877fe6ac3..923755309c 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleContributorCollection.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleContributorCollection.cs @@ -30,15 +30,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling public void Add([NotNull] Type contributorType) { Check.NotNull(contributorType, nameof(contributorType)); - if (!typeof(IBundleContributor).IsAssignableFrom(contributorType)) - { - throw new AbpException($"Given {nameof(contributorType)} ({contributorType.AssemblyQualifiedName}) should implement the {typeof(IBundleContributor).AssemblyQualifiedName} interface!"); - } - - if (IsAlreadyAdded(contributorType)) - { - throw new AbpException($"Given {nameof(contributorType)} ({contributorType.AssemblyQualifiedName}) is already added before! If you want to ensure that a contributor is added, create your own contributor and depend on the contributor you want to ensure that it's added."); - } AddWithDependencies(contributorType); } @@ -55,6 +46,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling private void AddWithDependencies(Type contributorType) { + if (IsAlreadyAdded(contributorType)) + { + return; + } + var dependsOnAttributes = contributorType .GetCustomAttributes(true) .OfType() @@ -65,11 +61,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling foreach (var dependedType in dependsOnAttribute.GetDependedTypes()) { AddWithDependencies(dependedType); //Recursive call - - if (!IsAlreadyAdded(dependedType)) - { - AddInstanceToContributors(dependedType); - } } } @@ -78,6 +69,11 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling private void AddInstanceToContributors(Type contributorType) { + if (!typeof(IBundleContributor).IsAssignableFrom(contributorType)) + { + throw new AbpException($"Given {nameof(contributorType)} ({contributorType.AssemblyQualifiedName}) should implement the {typeof(IBundleContributor).AssemblyQualifiedName} interface!"); + } + try { _contributors.Add((IBundleContributor)Activator.CreateInstance(contributorType)); diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleManager.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleManager.cs index 4341e8633f..2251d5d65d 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleManager.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/BundleManager.cs @@ -62,7 +62,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling using (var scope = _serviceProvider.CreateScope()) { - var context = new BundleConfigurationContext( new List(), _themeManager.CurrentTheme, diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptContributor.cs similarity index 73% rename from src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptBundleContributor.cs rename to src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptContributor.cs index b908274ec2..5b58d320e3 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptBundleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapScriptContributor.cs @@ -3,8 +3,8 @@ using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Bootstrap { - [DependsOn(typeof(JQueryScriptBundleContributor))] - public class BootstrapScriptBundleContributor : BundleContributor + [DependsOn(typeof(JQueryScriptContributor))] + public class BootstrapScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleContributor.cs similarity index 78% rename from src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleBundleContributor.cs rename to src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleContributor.cs index bb98f05deb..803a6dfb35 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleBundleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Bootstrap/BootstrapStyleContributor.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Bootstrap { - public class BootstrapStyleBundleContributor : BundleContributor + public class BootstrapStyleContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNet/DatatablesNetScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNet/DatatablesNetScriptContributor.cs new file mode 100644 index 0000000000..066d162b79 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNet/DatatablesNetScriptContributor.cs @@ -0,0 +1,14 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNet +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class DatatablesNetScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/datatables.net/js/jquery.dataTables.js"); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4ScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4ScriptContributor.cs new file mode 100644 index 0000000000..d24b3bc456 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4ScriptContributor.cs @@ -0,0 +1,16 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Bootstrap; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNet; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNetBs4 +{ + [DependsOn(typeof(DatatablesNetScriptContributor))] + [DependsOn(typeof(BootstrapScriptContributor))] + public class DatatablesNetBs4ScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/datatables.net-bs4/js/dataTables.bootstrap4.js"); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleContributor.cs similarity index 73% rename from src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleBundleContributor.cs rename to src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleContributor.cs index ecbcc77e73..d0f5726246 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleBundleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/DatatablesNetBs4/DatatablesNetBs4StyleContributor.cs @@ -3,8 +3,8 @@ using Volo.Abp.Modularity; namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.DatatablesNetBs4 { - [DependsOn(typeof(BootstrapStyleBundleContributor))] - public class DatatablesNetBs4StyleBundleContributor : BundleContributor + [DependsOn(typeof(BootstrapStyleContributor))] + public class DatatablesNetBs4StyleContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/FontAwesome/BootstrapStyleBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/FontAwesome/BootstrapStyleBundleContributor.cs index 0907b37141..b53ea96733 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/FontAwesome/BootstrapStyleBundleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/FontAwesome/BootstrapStyleBundleContributor.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.FontAwesome { - public class FontAwesomeStyleBundleContributor : BundleContributor + public class FontAwesomeStyleContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptContributor.cs similarity index 78% rename from src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptBundleContributor.cs rename to src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptContributor.cs index c6f555fff7..a8b85fa865 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptBundleContributor.cs +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQuery/JQueryScriptContributor.cs @@ -1,6 +1,6 @@ namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery { - public class JQueryScriptBundleContributor : BundleContributor + public class JQueryScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryForm/JQueryValidationScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryForm/JQueryValidationScriptContributor.cs new file mode 100644 index 0000000000..5c8ce4c6c2 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryForm/JQueryValidationScriptContributor.cs @@ -0,0 +1,14 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryForm +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class JQueryFormScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/jquery-form/jquery.form.min.js"); + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidation/JQueryValidationScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidation/JQueryValidationScriptContributor.cs new file mode 100644 index 0000000000..de93a5a32d --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidation/JQueryValidationScriptContributor.cs @@ -0,0 +1,14 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryValidation +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class JQueryValidationScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/jquery-validation/jquery.validate.js"); + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidationUnobtrusive/JQueryValidationUnobtrusiveScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidationUnobtrusive/JQueryValidationUnobtrusiveScriptContributor.cs new file mode 100644 index 0000000000..1d207a86a8 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/JQueryValidationUnobtrusive/JQueryValidationUnobtrusiveScriptContributor.cs @@ -0,0 +1,14 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryValidation; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQueryValidationUnobtrusive +{ + [DependsOn(typeof(JQueryValidationScriptContributor))] + public class JQueryValidationUnobtrusiveScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"); + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/SweetAlert/SweetalertScriptContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/SweetAlert/SweetalertScriptContributor.cs new file mode 100644 index 0000000000..9e36fc6bad --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/SweetAlert/SweetalertScriptContributor.cs @@ -0,0 +1,10 @@ +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.SweetAlert +{ + public class SweetalertScriptContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/sweetalert/sweetalert.min.js"); + } + } +} diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Toastr/ToastrScriptBundleContributor.cs b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Toastr/ToastrScriptBundleContributor.cs new file mode 100644 index 0000000000..5eda26aee8 --- /dev/null +++ b/src/Volo.Abp.AspNetCore.Mvc.UI/UI/Bundling/Libraries/Toastr/ToastrScriptBundleContributor.cs @@ -0,0 +1,14 @@ +using Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.JQuery; +using Volo.Abp.Modularity; + +namespace Volo.Abp.AspNetCore.Mvc.UI.Bundling.Libraries.Toastr +{ + [DependsOn(typeof(JQueryScriptContributor))] + public class ToastrScriptBundleContributor : BundleContributor + { + public override void ConfigureBundle(BundleConfigurationContext context) + { + context.Files.Add("/libs/toastr/toastr.min.js"); + } + } +} \ No newline at end of file