From 48fda66c6f6d4220ce8b3c78b433383bc701e542 Mon Sep 17 00:00:00 2001 From: maliming Date: Mon, 18 Mar 2024 19:15:48 +0800 Subject: [PATCH 1/3] Update `datatables.net` to `2.0.2`. Resolve #19323 --- .../DatatablesNetScriptContributor.cs | 2 +- .../datatables/datatables-extensions.js | 25 ++++++------------- npm/packs/datatables.net-bs5/package.json | 2 +- .../datatables.net/abp.resourcemapping.js | 2 +- npm/packs/datatables.net/package.json | 2 +- 5 files changed, 11 insertions(+), 22 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs index daea15328f..b266f4f010 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs @@ -10,6 +10,6 @@ public class DatatablesNetScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { - context.Files.AddIfNotContains("/libs/datatables.net/js/jquery.dataTables.js"); + context.Files.AddIfNotContains("/libs/datatables.net/js/dataTables.min.js"); } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js index b4000d6cbc..c97d4300ea 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js @@ -11,10 +11,6 @@ var abp = abp || {}; * RECORD-ACTIONS extension for datatables * *************************************************************************/ (function () { - if (!$.fn.dataTableExt) { - return; - } - var getVisibilityValue = function (visibilityField, record, tableInstance) { if (visibilityField === undefined) { return true; @@ -238,10 +234,9 @@ var abp = abp || {}; var renderRowActions = function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) { var columns; - if (tableInstance.aoColumns) { - columns = tableInstance.aoColumns; - } else { - columns = tableInstance.fnSettings().aoColumns; + var settings = tableInstance.api().settings(); + if (settings.length === 1 && settings[0].aoColumns) { + columns = settings[0].aoColumns; } if (!columns) { @@ -271,16 +266,6 @@ var abp = abp || {}; } }; - var _existingApiRenderRowActionsFunction = $.fn.dataTableExt.oApi.renderRowActions; - $.fn.dataTableExt.oApi.renderRowActions = - function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) { - if (_existingApiRenderRowActionsFunction) { - _existingApiRenderRowActionsFunction(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull); - } - - renderRowActions(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull); - }; - if (!$.fn.dataTable) { return; } @@ -466,6 +451,10 @@ var abp = abp || {}; if (column.rowAction) { customizeRowActionColumn(column); } + + if (!column.type) { + column.type = "string"; + } } configuration.language = datatables.defaultConfigurations.language(); diff --git a/npm/packs/datatables.net-bs5/package.json b/npm/packs/datatables.net-bs5/package.json index 9de49bd594..578b302430 100644 --- a/npm/packs/datatables.net-bs5/package.json +++ b/npm/packs/datatables.net-bs5/package.json @@ -6,7 +6,7 @@ }, "dependencies": { "@abp/datatables.net": "~8.1.0-rc.2", - "datatables.net-bs5": "^1.11.4" + "datatables.net-bs5": "^2.0.2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431", "homepage": "https://abp.io", diff --git a/npm/packs/datatables.net/abp.resourcemapping.js b/npm/packs/datatables.net/abp.resourcemapping.js index 53561d1e3e..9539610811 100644 --- a/npm/packs/datatables.net/abp.resourcemapping.js +++ b/npm/packs/datatables.net/abp.resourcemapping.js @@ -1,5 +1,5 @@ module.exports = { mappings: { - "@node_modules/datatables.net/js/jquery.dataTables.js": "@libs/datatables.net/js/" + "@node_modules/datatables.net/js/dataTables.min.js": "@libs/datatables.net/js/" } } \ No newline at end of file diff --git a/npm/packs/datatables.net/package.json b/npm/packs/datatables.net/package.json index 1bebe6b51d..1afde0c6b9 100644 --- a/npm/packs/datatables.net/package.json +++ b/npm/packs/datatables.net/package.json @@ -11,7 +11,7 @@ }, "dependencies": { "@abp/jquery": "~8.1.0-rc.2", - "datatables.net": "^1.11.4" + "datatables.net": "^2.0.2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431", "homepage": "https://abp.io", From 06e4cfdff5833d9434c175e034501736800a4397 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 19 Mar 2024 10:02:17 +0800 Subject: [PATCH 2/3] Compatible with older `dataTables` versions. --- .../DatatablesNetScriptContributor.cs | 10 +++++- .../datatables/datatables-extensions.js | 34 +++++++++++++++---- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs index b266f4f010..026e8075ec 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs @@ -10,6 +10,14 @@ public class DatatablesNetScriptContributor : BundleContributor { public override void ConfigureBundle(BundleConfigurationContext context) { - context.Files.AddIfNotContains("/libs/datatables.net/js/dataTables.min.js"); + if (context.FileProvider.GetFileInfo("/libs/datatables.net/js/dataTables.min.js").Exists) + { + context.Files.AddIfNotContains("/libs/datatables.net/js/dataTables.min.js"); + } + else + { + //TODO: Compatibility code, Remove it after 8.2 rc1. + context.Files.AddIfNotContains("/libs/datatables.net/js/jquery.dataTables.js"); + } } } diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js index c97d4300ea..9b5b29d70b 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore-mvc-ui-theme-shared/datatables/datatables-extensions.js @@ -11,6 +11,10 @@ var abp = abp || {}; * RECORD-ACTIONS extension for datatables * *************************************************************************/ (function () { + if (!$.fn.dataTableExt) { + return; + } + var getVisibilityValue = function (visibilityField, record, tableInstance) { if (visibilityField === undefined) { return true; @@ -234,9 +238,17 @@ var abp = abp || {}; var renderRowActions = function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) { var columns; - var settings = tableInstance.api().settings(); - if (settings.length === 1 && settings[0].aoColumns) { - columns = settings[0].aoColumns; + if (tableInstance.aoColumns) { + columns = tableInstance.aoColumns; + } else if (abp.utils.isFunction(tableInstance.fnSettings)) { + columns = tableInstance.fnSettings().aoColumns; + } + + if (!columns && abp.utils.isFunction(tableInstance.api)) { + var settings = tableInstance.api().settings(); + if (settings.length === 1 && settings[0].aoColumns) { + columns = settings[0].aoColumns; + } } if (!columns) { @@ -266,6 +278,18 @@ var abp = abp || {}; } }; + if ($.fn.dataTableExt.oApi) { + var _existingApiRenderRowActionsFunction = $.fn.dataTableExt.oApi.renderRowActions; + $.fn.dataTableExt.oApi.renderRowActions = + function (tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull) { + if (_existingApiRenderRowActionsFunction) { + _existingApiRenderRowActionsFunction(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull); + } + + renderRowActions(tableInstance, nRow, aData, iDisplayIndex, iDisplayIndexFull); + }; + } + if (!$.fn.dataTable) { return; } @@ -451,10 +475,6 @@ var abp = abp || {}; if (column.rowAction) { customizeRowActionColumn(column); } - - if (!column.type) { - column.type = "string"; - } } configuration.language = datatables.defaultConfigurations.language(); From 78d11f284ad4a7d58205c5a791200737784a1004 Mon Sep 17 00:00:00 2001 From: maliming Date: Tue, 30 Apr 2024 13:54:26 +0800 Subject: [PATCH 3/3] Add `Compatible Code`. --- .../Packages/DatatablesNet/DatatablesNetScriptContributor.cs | 2 +- npm/packs/datatables.net/abp.resourcemapping.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs index 026e8075ec..2ad3bb2bdb 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc.UI.Packages/Volo/Abp/AspNetCore/Mvc/UI/Packages/DatatablesNet/DatatablesNetScriptContributor.cs @@ -16,7 +16,7 @@ public override void ConfigureBundle(BundleConfigurationContext context) } else { - //TODO: Compatibility code, Remove it after 8.2 rc1. + //TODO: Compatible code, Remove it after 8.3 rc1. context.Files.AddIfNotContains("/libs/datatables.net/js/jquery.dataTables.js"); } } diff --git a/npm/packs/datatables.net/abp.resourcemapping.js b/npm/packs/datatables.net/abp.resourcemapping.js index 9539610811..4c5147ec27 100644 --- a/npm/packs/datatables.net/abp.resourcemapping.js +++ b/npm/packs/datatables.net/abp.resourcemapping.js @@ -1,5 +1,6 @@ module.exports = { mappings: { - "@node_modules/datatables.net/js/dataTables.min.js": "@libs/datatables.net/js/" + "@node_modules/datatables.net/js/dataTables.min.js": "@libs/datatables.net/js/", + "@node_modules/datatables.net/js/jquery.dataTables.js": "@libs/datatables.net/js/" //TODO: Compatible code, Remove it after 8.3 rc1. } } \ No newline at end of file