From 2502b87a2998e7301ab0f735065fc267af690424 Mon Sep 17 00:00:00 2001 From: Jadyn Date: Sat, 23 Dec 2023 23:28:59 +0800 Subject: [PATCH 1/3] Fix save event for custom groups on first navigation --- .../SettingManagement/SettingUi/Index.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js index a3310db..2a17a6c 100644 --- a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js +++ b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js @@ -46,18 +46,22 @@ }) } - $('#tabs-nav .nav-item .nav-link').click(function () { - var _this = $(this); - if (_this.attr('data-bs-target') !== undefined) { - return; - } + var bind_nav_event_fn = function (element) { var btn_set = setInterval(function () { - var _id = '#' + _this.data('id') + " "; + var _id = '#' + element.data('id') + " "; event_fn(_id); if ($(_id + " form").length > 0) { clearInterval(btn_set); } }, 200); + } + + $('#tabs-nav .nav-item .nav-link').click(function () { + var _this = $(this); + if (_this.attr('data-bs-target') !== undefined) { + return; + } + bind_nav_event_fn(_this) }); if (location.hash) { @@ -65,4 +69,7 @@ $("#SettingManagementWrapper li.nav-item > a.nav-link")[index].click(); history.replaceState(null, null, ' '); // remove hash from the location url } + + // The first nav will automatically click and loading before on this script. + bind_nav_event_fn($("#SettingManagementWrapper li.nav-item > a.nav-link").first()); })(jQuery); From 406e5549c5fe55c3de228439799b115686192535 Mon Sep 17 00:00:00 2001 From: Jadyn Date: Sat, 23 Dec 2023 23:59:56 +0800 Subject: [PATCH 2/3] Improve clear bind nav event interval --- .../Pages/SettingManagement/SettingUi/Index.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js index 2a17a6c..8efffa7 100644 --- a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js +++ b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js @@ -52,6 +52,11 @@ event_fn(_id); if ($(_id + " form").length > 0) { clearInterval(btn_set); + } else { + var target = element.attr('data-bs-target'); + if (target !== undefined && $(target).length > 0) { + clearInterval(btn_set); + } } }, 200); } From 7a04f751c816216d8e701764279f1ff656bd89ae Mon Sep 17 00:00:00 2001 From: Jadyn Date: Mon, 25 Dec 2023 16:09:02 +0800 Subject: [PATCH 3/3] Improve bind events --- .../Pages/Components/Default.cshtml | 2 +- .../SettingManagement/SettingUi/Index.js | 30 +++++++++---------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/EasyAbp.Abp.SettingUi.Web/Pages/Components/Default.cshtml b/src/EasyAbp.Abp.SettingUi.Web/Pages/Components/Default.cshtml index 3ad8147..91ca480 100644 --- a/src/EasyAbp.Abp.SettingUi.Web/Pages/Components/Default.cshtml +++ b/src/EasyAbp.Abp.SettingUi.Web/Pages/Components/Default.cshtml @@ -5,7 +5,7 @@ @foreach (var group in Model.GroupBy(sd => sd.Group2)) { -
+

@L[group.Key]

diff --git a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js index 8efffa7..3a7baad 100644 --- a/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js +++ b/src/EasyAbp.Abp.SettingUi.Web/Pages/SettingManagement/SettingUi/Index.js @@ -4,12 +4,8 @@ var l = abp.localization.getResource("EasyAbpAbpSettingUi"); var event_fn = function (id = '') { - $(id + "form").submit(function (e) { + $(id + " form.setting-ui").submit(function (e) { e.preventDefault(); - // Skip abp `EmailSettingsForm` - if (e.currentTarget.id == 'EmailSettingsForm') { - return; - } if (!$(e.currentTarget).valid()) { return; @@ -23,7 +19,7 @@ }); }); - $(id + ".reset").click(function (e) { + $(id + " form.setting-ui .reset").click(function (e) { var form = e.currentTarget.closest("form"); abp.message.confirm( l("ResetConfirm", $(form).find("h4").text()), @@ -48,15 +44,17 @@ var bind_nav_event_fn = function (element) { var btn_set = setInterval(function () { - var _id = '#' + element.data('id') + " "; - event_fn(_id); - if ($(_id + " form").length > 0) { + var _id = '#' + element.data('id').replace(/\./g, '-'); + if ($(_id + " form.setting-ui").length > 0) { + event_fn(_id); + clearInterval(btn_set); + return; + } + + // Rendering is done but not SettingUi. + var target = element.attr('data-bs-target'); + if (target !== undefined && $(target).length > 0) { clearInterval(btn_set); - } else { - var target = element.attr('data-bs-target'); - if (target !== undefined && $(target).length > 0) { - clearInterval(btn_set); - } } }, 200); } @@ -71,10 +69,10 @@ if (location.hash) { var index = location.hash.substring(1); - $("#SettingManagementWrapper li.nav-item > a.nav-link")[index].click(); + $("#tabs-nav .nav-item .nav-link")[index].click(); history.replaceState(null, null, ' '); // remove hash from the location url } // The first nav will automatically click and loading before on this script. - bind_nav_event_fn($("#SettingManagementWrapper li.nav-item > a.nav-link").first()); + bind_nav_event_fn($("#tabs-nav .nav-item .nav-link").first()); })(jQuery);