From 5e5104dc7a4fce40365c6006063883195da23af8 Mon Sep 17 00:00:00 2001 From: Oleg Zhuk Date: Thu, 14 Nov 2024 16:01:51 +0200 Subject: [PATCH] VCST-2186: context menu won't disappear after deletion (#756) fix: Resolve the issue of the context menu not disappearing after deletion for product assets. (#756) feat: Added confirmation dialog before deleting operation for product assets. (#756) feat: Added confirmation dialog before deleting operation for product images. (#756) --- .../Scripts/blades/images.js | 33 +++++++++++++---- .../Scripts/blades/item-asset-list.js | 35 +++++++++++++++---- 2 files changed, 54 insertions(+), 14 deletions(-) diff --git a/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/images.js b/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/images.js index 993952984..3e43c6cc5 100644 --- a/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/images.js +++ b/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/images.js @@ -46,7 +46,17 @@ angular.module('virtoCommerce.catalogModule') $scope.removeItem = function(image) { var idx = blade.currentEntities.indexOf(image); if (idx >= 0) { - blade.currentEntities.splice(idx, 1); + var dialog = { + id: "confirmDeleteItem", + title: "platform.dialogs.folders-delete.title", + message: "platform.dialogs.folders-delete.message", + callback: function (remove) { + if (remove) { + blade.currentEntities.splice(idx, 1); + } + } + } + dialogService.showConfirmationDialog(dialog); } }; @@ -70,13 +80,22 @@ angular.module('virtoCommerce.catalogModule') selectedImages = $scope.gridApi.selection.getSelectedRows(); } - angular.forEach(selectedImages, - function(image) { - var idx = blade.currentEntities.indexOf(image); - if (idx >= 0) { - blade.currentEntities.splice(idx, 1); + var dialog = { + id: "confirmDeleteItem", + title: "platform.dialogs.folders-delete.title", + message: "platform.dialogs.folders-delete.message", + callback: function (remove) { + if (remove) { + angular.forEach(selectedImages, function (image) { + var idx = blade.currentEntities.indexOf(image); + if (idx >= 0) { + blade.currentEntities.splice(idx, 1); + } + }); } - }); + } + } + dialogService.showConfirmationDialog(dialog); }; $scope.edit = function(entity) { diff --git a/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/item-asset-list.js b/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/item-asset-list.js index 7f3b01bcd..3f18bc1d2 100644 --- a/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/item-asset-list.js +++ b/src/VirtoCommerce.CatalogModule.Web/Scripts/blades/item-asset-list.js @@ -1,5 +1,6 @@ angular.module('virtoCommerce.catalogModule') - .controller('virtoCommerce.catalogModule.itemAssetController', ['$scope', '$translate', 'platformWebApp.bladeNavigationService', '$filter', 'platformWebApp.uiGridHelper', '$timeout', 'platformWebApp.settings', function ($scope, $translate, bladeNavigationService, $filter, uiGridHelper, $timeout, settings) { + .controller('virtoCommerce.catalogModule.itemAssetController', ['$scope', '$translate', 'platformWebApp.bladeNavigationService', '$filter', 'platformWebApp.uiGridHelper', '$timeout', 'platformWebApp.settings', 'platformWebApp.dialogService', + function ($scope, $translate, bladeNavigationService, $filter, uiGridHelper, $timeout, settings, dialogService) { var blade = $scope.blade; blade.headIcon = 'fa fa-chain'; @@ -158,7 +159,17 @@ angular.module('virtoCommerce.catalogModule') $scope.removeItem = function (image) { var idx = blade.currentEntities.indexOf(image); if (idx >= 0) { - blade.currentEntities.splice(idx, 1); + var dialog = { + id: "confirmDeleteItem", + title: "platform.dialogs.folders-delete.title", + message: "platform.dialogs.folders-delete.message", + callback: function (remove) { + if (remove) { + blade.currentEntities.splice(idx, 1); + } + } + } + dialogService.showConfirmationDialog(dialog); } }; @@ -172,12 +183,22 @@ angular.module('virtoCommerce.catalogModule') selectedImages = $scope.gridApi.selection.getSelectedRows(); } - angular.forEach(selectedImages, function (image) { - var idx = blade.currentEntities.indexOf(image); - if (idx >= 0) { - blade.currentEntities.splice(idx, 1); + var dialog = { + id: "confirmDeleteItem", + title: "platform.dialogs.folders-delete.title", + message: "platform.dialogs.folders-delete.message", + callback: function (remove) { + if (remove) { + angular.forEach(selectedImages, function (image) { + var idx = blade.currentEntities.indexOf(image); + if (idx >= 0) { + blade.currentEntities.splice(idx, 1); + } + }); + } } - }); + } + dialogService.showConfirmationDialog(dialog); }; initialize(blade.item);