Skip to content
Snippets Groups Projects
Commit d276d2ae authored by parkera's avatar parkera
Browse files

SSDM-3632 : Batch delete on sample table, polished

SVN: 36644
parent 97f3ec7f
No related branches found
No related tags found
No related merge requests found
...@@ -83,8 +83,38 @@ function SampleTableController(parentController, title, experimentIdentifier, pr ...@@ -83,8 +83,38 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
} }
//Create and display table //Create and display table
this._sampleTableView._dataGridController = SampleDataGridUtil.getSampleDataGrid(selectedSampleTypeCode, samples, null, null, null, null, null, null, true); var dataGridController = SampleDataGridUtil.getSampleDataGrid(selectedSampleTypeCode, samples, null, null, null, null, null, null, true);
this._sampleTableView._dataGridController.init(this._sampleTableView.getTableContainer());
var extraOptions = [];
extraOptions.push({ name : "Delete selected", action : function(selected) {
var grid = dataGridController._grid;
var selected = grid.getSelected();
if(selected != undefined && selected.length == 0){
alert("Please select at least one sample to delete!");
} else {
var warningText = "The next samples will be deleted: ";
var sampleTechIds = [];
for(var sIdx = 0; sIdx < selected.length; sIdx++) {
sampleTechIds.push(selected[sIdx].id);
warningText += selected[sIdx].identifier + " ";
}
var modalView = new DeleteEntityController(function(reason) {
mainController.serverFacade.deleteSamples(sampleTechIds, reason, function(data) {
if(data.error) {
Util.showError(data.error.message);
} else {
Util.showSuccess("Sample/s Deleted");
mainController.refreshView();
}
});
}, true, warningText);
modalView.init();
}
}});
dataGridController.init(this._sampleTableView.getTableContainer(), extraOptions);
} }
} }
} }
\ No newline at end of file
...@@ -129,36 +129,6 @@ function SampleTableView(sampleTableController, sampleTableModel) { ...@@ -129,36 +129,6 @@ function SampleTableView(sampleTableController, sampleTableModel) {
}); });
$list.append($batchUpdateOption); $list.append($batchUpdateOption);
var $batchDeleteOption = $("<li>", { 'role' : 'presentation' }).append($("<a>", {'title' : 'Delete Samples'}).append("Delete Samples"));
$batchDeleteOption.click(function() {
var grid = _this._dataGridController._grid;
var selected = grid.getSelected();
if(selected != undefined && selected.length == 0){
alert("Please select at least one sample to delete!");
}else{
var warningText = "The next samples will be deleted: ";
var sampleTechIds = [];
for(var sIdx = 0; sIdx < selected.length; sIdx++) {
sampleTechIds.push(selected[sIdx].id);
warningText += selected[sIdx].identifier + " ";
}
var modalView = new DeleteEntityController(function(reason) {
mainController.serverFacade.deleteSamples(sampleTechIds, reason, function(data) {
if(data.error) {
Util.showError(data.error.message);
} else {
Util.showSuccess("Sample/s Deleted");
mainController.refreshView();
}
});
}, true, warningText);
modalView.init();
}
});
$list.append($batchDeleteOption);
return $dropDownMenu; return $dropDownMenu;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment