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();
});
};
- 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
);
};