From bb9719315acf7588004fb7a814e54bcb155174b8 Mon Sep 17 00:00:00 2001 From: Daniel Kelemen Date: Thu, 14 Jul 2022 18:13:19 +0200 Subject: [PATCH] feat(batch): delete historic batch entity feature related to CAM-14723 --- .../client/scripts/batches/components/batch.js | 11 +++++++++-- .../client/scripts/batches/components/delete.js | 3 ++- .../client/scripts/batches/controllers/modal-ctrl.js | 2 +- .../client/scripts/batches/controllers/view-ctrl.js | 1 + .../batches/templates/cam-cockpit-batch-view.html | 3 +-- .../scripts/batches/templates/delete-modal.html | 8 +++++--- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/webapps/ui/cockpit/client/scripts/batches/components/batch.js b/webapps/ui/cockpit/client/scripts/batches/components/batch.js index 95fa7b0c3c6..77cbed2c8eb 100644 --- a/webapps/ui/cockpit/client/scripts/batches/components/batch.js +++ b/webapps/ui/cockpit/client/scripts/batches/components/batch.js @@ -119,7 +119,8 @@ Batch.prototype._remove = function(params) { var obj = this._batches.selection; params.id = obj.data.id; var self = this; - return this._sdk.resource('batch').delete(params, function(err) { + + let cb = err => { self.deleteModal.instance && self.deleteModal.instance.close(); self.deleteModal.instance = null; @@ -132,7 +133,13 @@ Batch.prototype._remove = function(params) { obj.type = null; obj.data = {}; } - }); + }; + + if (obj.type === 'history') { + return this._sdk.resource('history').batchDelete(obj.data.id, cb); + } else { + return this._sdk.resource('batch').delete(params, cb); + } }; var handleRetryResponse = function(context) { diff --git a/webapps/ui/cockpit/client/scripts/batches/components/delete.js b/webapps/ui/cockpit/client/scripts/batches/components/delete.js index 39fd85aaee6..8aa73813823 100644 --- a/webapps/ui/cockpit/client/scripts/batches/components/delete.js +++ b/webapps/ui/cockpit/client/scripts/batches/components/delete.js @@ -19,9 +19,10 @@ var events = require('./events'); -var Delete = function() { +var Delete = function(type) { this.cascade = false; this.disable = false; + this.type = type; }; Delete.prototype.cancel = function() { diff --git a/webapps/ui/cockpit/client/scripts/batches/controllers/modal-ctrl.js b/webapps/ui/cockpit/client/scripts/batches/controllers/modal-ctrl.js index 59dbc4cb831..3b024cc6077 100644 --- a/webapps/ui/cockpit/client/scripts/batches/controllers/modal-ctrl.js +++ b/webapps/ui/cockpit/client/scripts/batches/controllers/modal-ctrl.js @@ -22,6 +22,6 @@ var Ctrl = require('../components/delete'); module.exports = [ '$scope', function($scope) { - $scope.ctrl = new Ctrl(); + $scope.ctrl = new Ctrl($scope.ctrl.getSelectionType()); } ]; diff --git a/webapps/ui/cockpit/client/scripts/batches/controllers/view-ctrl.js b/webapps/ui/cockpit/client/scripts/batches/controllers/view-ctrl.js index 74ee6d82083..cb2b3866de8 100644 --- a/webapps/ui/cockpit/client/scripts/batches/controllers/view-ctrl.js +++ b/webapps/ui/cockpit/client/scripts/batches/controllers/view-ctrl.js @@ -158,6 +158,7 @@ module.exports = [ events.on('deleteModal:open', function(deleteModal) { var modal = (deleteModal.instance = $modal.open({ + scope: $scope, template: deleteModalTemplate, controller: deleteModalCtrl })); diff --git a/webapps/ui/cockpit/client/scripts/batches/templates/cam-cockpit-batch-view.html b/webapps/ui/cockpit/client/scripts/batches/templates/cam-cockpit-batch-view.html index 516bc7c1f9c..0813ea94e5b 100644 --- a/webapps/ui/cockpit/client/scripts/batches/templates/cam-cockpit-batch-view.html +++ b/webapps/ui/cockpit/client/scripts/batches/templates/cam-cockpit-batch-view.html @@ -121,8 +121,7 @@

- diff --git a/webapps/ui/cockpit/client/scripts/batches/templates/delete-modal.html b/webapps/ui/cockpit/client/scripts/batches/templates/delete-modal.html index f314b389bb3..97dd126605d 100644 --- a/webapps/ui/cockpit/client/scripts/batches/templates/delete-modal.html +++ b/webapps/ui/cockpit/client/scripts/batches/templates/delete-modal.html @@ -3,9 +3,11 @@