From 0016b9748500029578b5550986e7881fe22cae17 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Thu, 16 Oct 2014 08:43:20 +0000 Subject: [PATCH] SSDM-1015 : GENERAL - Delete DataSets + refactoring SVN: 32617 --- .../newbrowser/html/js/server/ServerFacade.js | 3 ++ .../DataSetForm/DataSetFormController.js | 16 ++++++++-- .../js/views/DataSetForm/DataSetFormView.js | 29 ++++++++++++++----- .../ExperimentFormController.js | 8 +++-- .../views/SampleForm/SampleFormController.js | 17 +++++++++++ .../js/views/SampleForm/SampleFormView.js | 10 +------ 6 files changed, 62 insertions(+), 21 deletions(-) diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js index 514730051ba..92a25e9a0e5 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js @@ -164,6 +164,9 @@ function ServerFacade(openbisServer) { } } + this.deleteDataSets = function(datasetIds, reason, callback) { + this.openbisServer.deleteDataSets(datasetIds, reason, "TRASH", callback); + } this.deleteSamples = function(sampleIds, reason, callback) { this.openbisServer.deleteSamples(sampleIds, reason, "TRASH", callback); diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormController.js index 3b8cf1b5f80..44cd2758d37 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormController.js @@ -14,9 +14,9 @@ * limitations under the License. */ -function DataSetFormController(mainController, mode, sample, dataset) { +function DataSetFormController(mainController, mode, sample, dataSet) { this._mainController = mainController; - this._dataSetFormModel = new DataSetFormModel(mode, sample, dataset); + this._dataSetFormModel = new DataSetFormModel(mode, sample, dataSet); this._dataSetFormView = new DataSetFormView(this, this._dataSetFormModel); this.init = function($container) { @@ -42,6 +42,18 @@ function DataSetFormController(mainController, mode, sample, dataset) { return null; } + this.deleteDataSet = function(reason) { + var _this = this; + mainController.serverFacade.deleteDataSets([this._dataSetFormModel.dataSet.code], reason, function(data) { + if(data.error) { + Util.showError(data.error.message); + } else { + Util.showSuccess("Data Set Deleted"); + mainController.changeView('showViewSamplePageFromPermId', _this._dataSetFormModel.sample.permId); + } + }); + } + // // Form Submit // diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormView.js index 10e547078cc..5cc83be555b 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormView.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/DataSetForm/DataSetFormView.js @@ -26,15 +26,29 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { var $wrapper = $('<form>', { class : 'form-horizontal ', 'id' : 'mainDataSetForm', 'role' : 'form'}); $wrapper.submit(function(event) {_this._dataSetFormController.submitDataSet(); event.preventDefault();}); + //Title var titleText = null; - var $editButton = ""; if(this._dataSetFormModel.mode === FormMode.CREATE) { - titleText = 'Create Dataset '; + titleText = 'Create Dataset'; } else if(this._dataSetFormModel.mode === FormMode.EDIT) { - titleText = 'Update Dataset '; + titleText = 'Update Dataset'; } else if(this._dataSetFormModel.mode === FormMode.VIEW) { - titleText = 'View Dataset '; - + titleText = 'View Dataset'; + } + var $title = $('<h2>').text(titleText); + $wrapper.append($title); + + //Delete Button + if(this._dataSetFormModel.mode !== FormMode.CREATE) { + $title.append(" "); + $title.append(FormUtil.getDeleteButton(function(reason) { + _this._dataSetFormController.deleteDataSet(reason); + }, true)); + } + + //Edit Button + if(this._dataSetFormModel.mode === FormMode.VIEW) { + $title.append(" "); var $editButton = $("<a>", { 'class' : 'btn btn-default'} ) .append($('<span>', { 'class' : 'glyphicon glyphicon-edit' })) .append(' Enable Editing'); @@ -42,11 +56,10 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { $editButton.click(function() { mainController.changeView('showEditDataSetPageFromPermId', _this._dataSetFormModel.dataSet.code); }); + + $title.append($editButton) } - //Edit button; - $wrapper.append($('<h2>').text(titleText).append($editButton)); - //Drop Down DataSetType Field Set var $dataSetTypeFieldSet = $('<div>'); $dataSetTypeFieldSet.append($('<legend>').text('Type Info')); diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm/ExperimentFormController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm/ExperimentFormController.js index 942109a9567..278609e3aad 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm/ExperimentFormController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/ExperimentForm/ExperimentFormController.js @@ -30,8 +30,12 @@ function ExperimentFormController(mainController, mode, experiment) { this.deleteExperiment = function(reason) { var _this = this; mainController.serverFacade.deleteExperiments([this._experimentFormModel.experiment.id], reason, function(data) { - Util.showSuccess("Experiment Deleted"); - mainController.sideMenu.deleteUniqueIdAndMoveToParent(_this._experimentFormModel.experiment.identifier); + if(data.error) { + Util.showError(data.error.message); + } else { + Util.showSuccess("Experiment Deleted"); + mainController.sideMenu.deleteUniqueIdAndMoveToParent(_this._experimentFormModel.experiment.identifier); + } }); } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js index 2a2d1757223..1adcc78d5b1 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormController.js @@ -50,6 +50,23 @@ function SampleFormController(mainController, mode, sample) { this._storageControllers.push(storageController); } + this.deleteSample = function(reason) { + var _this = this; + mainController.serverFacade.deleteSamples([this._sampleFormModel.sample.id], reason, function(data) { + if(data.error) { + Util.showError(data.error.message); + } else { + Util.showSuccess("Sample Deleted"); + if(_this._sampleFormModel.isELNSubExperiment) { + mainController.sideMenu.refreshSubExperiment(_this._sampleFormModel.sample.experimentIdentifierOrNull); + mainController.changeView("showExperimentPageFromIdentifier", _this._sampleFormModel.sample.experimentIdentifierOrNull); + } else { + mainController.changeView('showSamplesPage', ":" + _this._sampleFormModel.sample.experimentIdentifierOrNull); + } + } + }); + } + this.createUpdateCopySample = function(isCopyWithNewCode, linkParentsOnCopy, copyChildrenOnCopy) { Util.blockUI(); var _this = this; diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js index 627f1cd3b36..9e40205651e 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js @@ -68,15 +68,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { if(this._sampleFormModel.mode !== FormMode.CREATE) { //Delete $formTitle.append(FormUtil.getDeleteButton(function(reason) { - mainController.serverFacade.deleteSamples([_this._sampleFormModel.sample.id], reason, function(data) { - Util.showSuccess("Sample Deleted"); - if(_this._sampleFormModel.isELNSubExperiment) { - mainController.sideMenu.refreshSubExperiment(_this._sampleFormModel.sample.experimentIdentifierOrNull); - mainController.changeView("showExperimentPageFromIdentifier", _this._sampleFormModel.sample.experimentIdentifierOrNull); - } else { - mainController.changeView('showSamplesPage', ":" + _this._sampleFormModel.sample.experimentIdentifierOrNull); - } - }); + _this._sampleFormController.deleteSample(reason); }, true)); //Pin $formTitle.append(" "); -- GitLab