From a28ca886a1c42dbae037ec34468b9ca7f94fb60d Mon Sep 17 00:00:00 2001
From: juanf <juanf>
Date: Wed, 10 Feb 2016 11:05:50 +0000
Subject: [PATCH] SSDM-3023 : Project Form showing important samples.

SVN: 35655
---
 .../eln-lims/html/js/server/ServerFacade.js   | 24 +++++++++++++++++--
 .../js/views/ProjectForm/ProjectFormView.js   |  6 +++++
 .../SampleTable/SampleTableController.js      | 14 +++++++----
 .../js/views/SampleTable/SampleTableModel.js  |  4 +++-
 .../js/views/SampleTable/SampleTableView.js   |  6 +++--
 5 files changed, 45 insertions(+), 9 deletions(-)

diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
index 9cc87d94724..c4538be4559 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js
@@ -704,6 +704,7 @@ function ServerFacade(openbisServer) {
 		var withChildren = fechOptions["withChildren"];
 		var withAncestors = fechOptions["withAncestors"];
 		var withDescendants = fechOptions["withDescendants"];
+		var withExperimentWithProjectPermId = fechOptions["withExperimentWithProjectPermId"];
 		
 		var matchClauses = [];
 		
@@ -811,6 +812,23 @@ function ServerFacade(openbisServer) {
 		
 		//Sub Queries
 		var subCriterias = [];
+		
+		if(withExperimentWithProjectPermId) {
+			subCriterias.push({
+				"@type" : "SearchSubCriteria",
+				"targetEntityKind" : "EXPERIMENT",	
+				"criteria" : {
+					matchClauses : [{
+							"@type":"AttributeMatchClause",
+							fieldType : "ATTRIBUTE",			
+							attribute : "PROJECT_PERM_ID",
+							desiredValue : withExperimentWithProjectPermId
+					}],
+					operator : "MATCH_ALL_CLAUSES"
+				}
+			});
+		}
+		
 		if(sampleExperimentIdentifier) {
 			var sampleExperimentIdentifierParts = sampleExperimentIdentifier.split("/");
 			subCriterias.push({
@@ -929,12 +947,14 @@ function ServerFacade(openbisServer) {
 		}, callbackFunction);
 	}
 	
-	this.searchWithExperiment = function(experimentIdentifier, callbackFunction)
+	this.searchWithExperiment = function(experimentIdentifier, projectPermId, properyKeyValueList, callbackFunction)
 	{	
 		this.searchSamples({
 			"sampleExperimentIdentifier" : experimentIdentifier,
+			"withExperimentWithProjectPermId" : projectPermId,
 			"withProperties" : true,
-			"withParents" : true
+			"withParents" : true,
+			"properyKeyValueList" : properyKeyValueList
 		}, callbackFunction);
 	}
 	
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
index 95f7949f462..3a2f0b40ae1 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
@@ -158,6 +158,12 @@ function ProjectFormView(projectFormController, projectFormModel) {
 		var experimentTableController = new ExperimentTableController(this._projectFormController, "Experiments", this._projectFormModel.project);
 		experimentTableController.init($experimentsContainer);
 		
+		var $samplesContainer = $("<div>");
+		$formColumn.append($samplesContainer);
+		
+		var sampleTableController = new SampleTableController(this._projectFormController, "Samples", null, this._projectFormModel.project.permId, true);
+		sampleTableController.init($samplesContainer);
+		
 		$container.append($form);
 		FormUtil.activateRichTextProperties();
 	}
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
index 602f74447fe..6096c6738d2 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableController.js
@@ -14,9 +14,9 @@
  * limitations under the License.
  */
 
-function SampleTableController(parentController, title, experimentIdentifier) {
+function SampleTableController(parentController, title, experimentIdentifier, projectPermId, showInProjectOverview) {
 	this._parentController = parentController;
-	this._sampleTableModel = new SampleTableModel(title, experimentIdentifier);
+	this._sampleTableModel = new SampleTableModel(title, experimentIdentifier, projectPermId, showInProjectOverview);
 	this._sampleTableView = new SampleTableView(this, this._sampleTableModel);
 	
 	this.init = function($container) {
@@ -28,7 +28,7 @@ function SampleTableController(parentController, title, experimentIdentifier) {
 			Util.unblockUI();
 		};
 		
-		if(this._sampleTableModel.experimentIdentifier) {
+		if(this._sampleTableModel.experimentIdentifier || projectPermId) {
 			this._loadExperimentData(callback);
 		} else {
 			callback();
@@ -37,7 +37,13 @@ function SampleTableController(parentController, title, experimentIdentifier) {
 	
 	this._loadExperimentData = function(callback) {
 		var _this = this;
-		mainController.serverFacade.searchWithExperiment(this._sampleTableModel.experimentIdentifier, function(experimentSamples) {
+		
+		var properyKeyValueList = null;
+		if (this._sampleTableModel.showInProjectOverview) {
+			properyKeyValueList = [{ "SHOW_IN_PROJECT_OVERVIEW" : "\"true\"" }];
+		}
+		
+		mainController.serverFacade.searchWithExperiment(this._sampleTableModel.experimentIdentifier, this._sampleTableModel.projectPermId, properyKeyValueList, function(experimentSamples) {
 			_this._sampleTableModel.allSamples = experimentSamples;
 			for(var i = 0; i < experimentSamples.length; i++) {
 				if(_this._sampleTableModel.sampleTypes[experimentSamples[i].sampleTypeCode]) {
diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableModel.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableModel.js
index a6e69426402..a5b1ff1bf20 100644
--- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableModel.js
+++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableModel.js
@@ -14,9 +14,11 @@
  * limitations under the License.
  */
 
-function SampleTableModel(title, experimentIdentifier) {
+function SampleTableModel(title, experimentIdentifier, projectPermId, showInProjectOverview) {
 	this.title = title;
 	this.experimentIdentifier = experimentIdentifier;
+	this.projectPermId = projectPermId;
+	this.showInProjectOverview = showInProjectOverview;
 	this.sampleTypes = {};
 	this.allSamples = new Array();
 }
\ No newline at end of file
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 374cd9e9c2c..63d8a619478 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
@@ -64,7 +64,9 @@ function SampleTableView(sampleTableController, sampleTableModel) {
 		$toolbox.append("Sample Type: ");
 		
 		if(this._sampleTableModel.experimentIdentifier) {
-			$toolbox.append(this._getExperimentSampleTypesDropdown()).append(" ").append(this._getOptionsMenu());
+			$toolbox.append(this._getLoadedSampleTypesDropdown()).append(" ").append(this._getOptionsMenu());
+		} else if(this._sampleTableModel.projectPermId) {
+			$toolbox.append(this._getLoadedSampleTypesDropdown());
 		} else {
 			$toolbox.append(this._getAllSampleTypesDropdown());
 		}
@@ -116,7 +118,7 @@ function SampleTableView(sampleTableController, sampleTableModel) {
 		return $dropDownMenu;
 	}
 	
-	this._getExperimentSampleTypesDropdown = function() {
+	this._getLoadedSampleTypesDropdown = function() {
 		var _this = this;
 		var	$sampleTypesSelector = $('<select>', { 'id' : 'sampleTypeCodesToShow', class : 'form-control' });
 		$sampleTypesSelector.append($('<option>', { 'value' : '' }).text(''));
-- 
GitLab