From c65b16042260c4bedb372b1ad9f92c01ef8514ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 22 Sep 2020 15:18:53 +0300 Subject: [PATCH] Fix duplicated init for widgets. --- .../jquery/widget-manager.js | 28 +++++++++++++------ .../CmsKitWebUnifiedModule.cs | 2 ++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js index 55b6162e78..3e3e24dc7a 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/jquery/widget-manager.js @@ -52,8 +52,12 @@ } function init($widgets) { - if(!$widgets){ - $widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper'); + if (!$widgets) { + if (opts.wrapper.hasClass('abp-widget-wrapper')) { + $widgets = opts.wrapper; + } else { + $widgets = opts.wrapper.find('.abp-widget-wrapper'); + } } $widgets.each(function () { @@ -72,8 +76,12 @@ } function refresh($widgets) { - if(!$widgets){ - $widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper'); + if (!$widgets) { + if (opts.wrapper.hasClass('abp-widget-wrapper')) { + $widgets = opts.wrapper; + } else { + $widgets = opts.wrapper.findWithSelf('.abp-widget-wrapper'); + } } $widgets.each(function () { @@ -90,7 +98,9 @@ }).then(function (result) { var $result = $(result); $widget.replaceWith($result); - init($result); + if($widget.attr('data-widget-auto-init') !== "true"){ + init($result); + } }); } else { var widgetApi = $widget.data('abp-widget-api'); @@ -115,9 +125,9 @@ return publicApi; }; - function autoInitWidgets($wrapper){ + function autoInitWidgets($wrapper) { $wrapper.findWithSelf('.abp-widget-wrapper[data-widget-auto-init="true"]') - .each(function(){ + .each(function () { var widgetManager = new abp.WidgetManager({ wrapper: $(this), }); @@ -126,11 +136,11 @@ }); } - abp.dom.onNodeAdded(function(args){ + abp.dom.onNodeAdded(function (args) { autoInitWidgets(args.$el); }) - $(function(){ + $(function () { autoInitWidgets($('body')); }); diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index e5d9f23c05..fa084c3432 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -83,6 +83,8 @@ namespace Volo.CmsKit { Configure(options => { + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}..{0}..{0}framework/src{0}Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared", Path.DirectorySeparatorChar))); + options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain.Shared", Path.DirectorySeparatorChar))); options.FileSets.ReplaceEmbeddedByPhysical(Path.Combine(hostingEnvironment.ContentRootPath, string.Format("..{0}..{0}src{0}Volo.CmsKit.Domain", Path.DirectorySeparatorChar)));