From: Coleman Watts Date: Mon, 6 Dec 2021 03:06:49 +0000 (-0500) Subject: SearchKit - Faster delete/revert actions in search listing X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=de2f79f2028c7322a211b3f30057502ee24522b2;p=civicrm-core.git SearchKit - Faster delete/revert actions in search listing --- diff --git a/ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.component.js b/ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.component.js index 5b18b02ee0..dde44a4470 100644 --- a/ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.component.js +++ b/ext/search_kit/ang/crmSearchAdmin/searchListing/crmSearchAdminSearchListing.component.js @@ -129,7 +129,7 @@ message: getMessage(), }).on('crmConfirm:yes', function() { $scope.$apply(function() { - return revert ? ctrl.revertSearch(search) : ctrl.deleteSearch(search); + return revert ? ctrl.revertSearch(row) : ctrl.deleteSearch(row); }); }).block(); @@ -138,27 +138,25 @@ }); }; - this.deleteSearch = function(search) { - crmStatus({start: ts('Deleting...'), success: ts('Search Deleted')}, - crmApi4('SavedSearch', 'delete', {where: [['id', '=', search.id]]}).then(function() { - ctrl.rowCount = null; - ctrl.runSearch(); - }) + this.deleteSearch = function(row) { + ctrl.runSearch( + [['SavedSearch', 'delete', {where: [['id', '=', row.key]]}]], + {start: ts('Deleting...'), success: ts('Search Deleted')}, + row ); }; - this.revertSearch = function(search) { - crmStatus({start: ts('Reverting...'), success: ts('Search Reverted')}, - crmApi4('SavedSearch', 'revert', { - where: [['id', '=', search.id]], + this.revertSearch = function(row) { + ctrl.runSearch( + [['SavedSearch', 'revert', { + where: [['id', '=', row.key]], chain: { revertDisplays: ['SearchDisplay', 'revert', {'where': [['saved_search_id', '=', '$id'], ['has_base', '=', true]]}], deleteDisplays: ['SearchDisplay', 'delete', {'where': [['saved_search_id', '=', '$id'], ['has_base', '=', false]]}] } - }).then(function() { - ctrl.rowCount = null; - ctrl.runSearch(); - }) + }]], + {start: ts('Reverting...'), success: ts('Search Reverted')}, + row ); };