From 155c91867df718bab236b698f63bdc189a672009 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Mon, 27 Apr 2015 14:12:00 +0000 Subject: [PATCH] SSDM-1724 : Plate View (ongoing work) SVN: 33913 --- .../SampleForm/widgets/PlateController.js | 17 +++++++++++++ .../js/views/SampleForm/widgets/PlateModel.js | 5 ++++ .../js/views/SampleForm/widgets/PlateView.js | 24 +++++++++++++++++++ .../html/js/views/legacy/SampleHierarchy.js | 6 +++++ 4 files changed, 52 insertions(+) diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateController.js index 2b347df3332..dfe675427d2 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateController.js @@ -18,8 +18,25 @@ function PlateController(sample) { this._plateModel = new PlateModel(sample); this._plateView = new PlateView(this, this._plateModel); + this.getPlaceHolder = function() { + return this._plateView.getPlaceHolder(); + } + + this.initWithPlaceHolder = function() { + var _this = this; + var repeatUntilSet = function() { + var placeHolderFound = $("#" + _this._plateModel.getPlaceHolderId()); + if(placeHolderFound.length === 0) { + setTimeout(repeatUntilSet, 100); + } else { + _this.init(placeHolderFound); + } + } + repeatUntilSet(); + } this.init = function($container) { var _this = this; + $container.empty(); $container.append("Loading Wells ..."); mainController.serverFacade.searchContained(this._plateModel.sample.permId, function(contained) { _this._plateModel.wells = contained; diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateModel.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateModel.js index c0b3bd972f2..e0653b55c08 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateModel.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateModel.js @@ -46,6 +46,11 @@ function PlateModel(sample) { return null; } + + this.getPlaceHolderId = function() { + return "PLATE_TEMPLATE_"+this.sample.permId; + } + this.getAlphabetLabel = function(number) { var alphabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']; return alphabet[number]; diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateView.js index 5a9b42d5f00..8755f184173 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/PlateView.js @@ -17,6 +17,30 @@ function PlateView(plateController, plateModel) { this._plateController = plateController; this._plateModel = plateModel; + this.getPlaceHolder = function() { + var container = $("<div>", { "id" : this._plateModel.getPlaceHolderId() }); + var gridTable = $("<table>", { "class" : "table table-bordered gridTable" }); + + for(var i = 0; i <= this._plateModel.numRows; i++) { + var $row = $("<tr>"); + for(var j = 0; j <= this._plateModel.numColumns; j++) { + var $cell = null; + if(i === 0 && j === 0) { //Empty cell at the top left + $cell = $("<th>"); + } else if (i === 0 && j !== 0){ //header with column numbers + $cell = $("<th>").append(j); + } else if (j === 0){ //header with row letter + $cell = $("<th>").append(this._plateModel.getAlphabetLabel(i-1)); + } else { + $cell = $("<td>").append(" "); + } + $row.append($cell); + } + gridTable.append($row); + } + container.append(gridTable); + return container[0].outerHTML + } this.repaint = function($container) { var _this = this; $container.empty(); diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js index bc02319eba6..c25576a967b 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js @@ -328,6 +328,12 @@ function SampleHierarchy(serverFacade, containerId, profile, sample) { 'background-color' : 'transparent' }); $nodeContent.append($graphTable); + + if(sample.sampleTypeCode === "PLATE") { + var plateController = new PlateController(sample); + $nodeContent.append(plateController.getPlaceHolder()); + plateController.initWithPlaceHolder(); + } } } else { -- GitLab