From e1b482c1c73e495e01b574894f8fcd4f142853f8 Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Mon, 22 Jun 2015 15:22:57 +0000
Subject: [PATCH] SSDM-2077 : "Create" button for each sample type in Inventory

SVN: 34239
---
 .../js/views/SampleTable/SampleTableView.js   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
index 2d31b74896e..36dc6656634 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js
@@ -20,9 +20,28 @@ function SampleTableView(sampleTableController, sampleTableModel) {
 	this.sampleTypeSelector = null;
 	
 	this.repaint = function($container) {
+		var _this = this;
 		$container.empty();
 		if(this._sampleTableModel.title) {
 			var $title = $("<h1>").append(this._sampleTableModel.title);
+			
+			var experimentCode = this._sampleTableModel.experimentIdentifier.split("/")[3];
+			var sampleTypeCode = experimentCode.substring(0,experimentCode.indexOf("_COLLECTION"));
+			
+			//Add Experiment Step
+			if(profile.getSampleTypeForSampleTypeCode(sampleTypeCode)) {
+				$title.append("&nbsp;");
+				$title.append(FormUtil.getButtonWithText("Create " + sampleTypeCode, function() {
+					var argsMap = {
+							"sampleTypeCode" : sampleTypeCode,
+							"experimentIdentifier" : _this._sampleTableModel.experimentIdentifier
+					}
+					var argsMapStr = JSON.stringify(argsMap);
+					Util.unblockUI();
+					mainController.changeView("showCreateSubExperimentPage", argsMapStr);
+				}));
+			}
+			
 			$container.append($title);
 		}
 		
-- 
GitLab