From d276d2aec64fd900ce81175d9f8827c5f70c74d8 Mon Sep 17 00:00:00 2001
From: parkera <parkera>
Date: Tue, 7 Jun 2016 13:47:52 +0000
Subject: [PATCH] SSDM-3632 : Batch delete on sample table, polished

SVN: 36644
---
 .../SampleTable/SampleTableController.js      | 34 +++++++++++++++++--
 .../js/views/SampleTable/SampleTableView.js   | 30 ----------------
 2 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
index a0680da146b..e6da480ed72 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
@@ -83,8 +83,38 @@ function SampleTableController(parentController, title, experimentIdentifier, pr
 			}
 			
 			//Create and display table
-			this._sampleTableView._dataGridController = SampleDataGridUtil.getSampleDataGrid(selectedSampleTypeCode, samples, null, null, null, null, null, null, true);
-			this._sampleTableView._dataGridController.init(this._sampleTableView.getTableContainer());
+			var dataGridController = SampleDataGridUtil.getSampleDataGrid(selectedSampleTypeCode, samples, null, null, null, null, null, null, true);
+			
+			
+			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
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
index 242c0906d85..d7d37402655 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
@@ -129,36 +129,6 @@ function SampleTableView(sampleTableController, sampleTableModel) {
 		});
 		$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;
 	}
 	
-- 
GitLab