From d87178f624e41015edcae70ea19ab1d77f2472a0 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Tue, 4 Mar 2014 13:26:33 +0000 Subject: [PATCH] BIS-604 / SP-1211: ELN UI - Hierarchical View (Add Children) SVN: 30808 --- .../newbrowser/html/js/config/Profile.js | 13 +++++- .../newbrowser/html/js/views/SampleForm.js | 2 +- .../html/js/views/SampleHierarchy.js | 44 ++++++++++++++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js index 9822354e258..e140fc44da8 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/config/Profile.js @@ -119,8 +119,6 @@ $.extend(DefaultProfile.prototype, { return ""; } - - /* * Used by Inspector */ @@ -236,6 +234,17 @@ $.extend(DefaultProfile.prototype, { return null; } + this.getAllSampleTypes = function() { + var sampleTypes = []; + for(var i = 0; i < this.allTypes.length; i++) { + var sampleType = this.allTypes[i]; + if($.inArray(sampleType.code, this.notShowTypes) === -1) { + sampleTypes.push(sampleType); + } + } + return sampleTypes; + } + this.initVocabulariesForSampleTypes = function() { //Build Vocabularies from sample types for(var sampleTypeIdx = 0; sampleTypeIdx < this.allTypes.length; sampleTypeIdx++) { diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js index 06babf65fc4..a638786ce0a 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm.js @@ -257,7 +257,7 @@ function SampleForm(serverFacade, inspector, containerId, profile, sampleTypeCod this.getLinksToParentsComponent = function() { var component = "<fieldset>"; - component += "<legend>Connected Components</legend>"; + component += "<legend>Parents</legend>"; if (this.mode !== SampleFormMode.VIEW) { component += "<p><i class='icon-info-sign'></i> To connect a component, please select the type from the drop down menu and click on the row of the table.</p>"; } diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleHierarchy.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleHierarchy.js index e6cbb492052..e57bd249bda 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleHierarchy.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleHierarchy.js @@ -259,6 +259,39 @@ function SampleHierarchy(serverFacade, inspector, containerId, profile, sample) this._repaintGraph(newSample); } + this._addChildFor = function(permId) { + var sampleTypes = this.profile.getAllSampleTypes(); + + var component = "<select id='sampleTypeSelector' required>"; + component += "<option disabled=\"disabled\" selected></option>"; + for(var i = 0; i < sampleTypes.length; i++) { + var sampleType = sampleTypes[i]; + var label = Util.getEmptyIfNull(sampleType.description); + if(label === "") { + label = sampleType.code; + } + + component += "<option value='" + sampleType.code + "'>" + label + "</option>"; + } + component += "</select>"; + + Util.blockUI("Select the type for the Child: <br><br>" + component + "<br> or <a class='btn' id='sampleTypeSelectorCancel'>Cancel</a>"); + + $("#sampleTypeSelectorCancel").on("click", function(event) { + Util.unblockUI(); + }); + + var _this = this; + $("#sampleTypeSelector").on("change", function(event) { + var sampleTypeCode = $("#sampleTypeSelector")[0].value; + mainController.changeView('showCreateSamplePage', sampleTypeCode); + _this.serverFacade.searchWithUniqueId(permId, function(data) { + var parentGroup = _this.profile.getGroupTypeCodeForTypeCode(data[0].sampleTypeCode); + mainController.currentView.sampleTypesLinksTables["sampleParents_" + parentGroup].addSample(data[0]); + }); + }); + } + this._updateDataFor = function(show, permId) { var searchAndUpdateData = function(show, permId, sample) { if(sample.permId === permId) { @@ -346,7 +379,15 @@ function SampleHierarchy(serverFacade, inspector, containerId, profile, sample) 'href' : "javascript:mainController.currentView._updateDataFor(" + ((sample.showDataOnGraph)?false:true) + ",'" + sample.permId + "');" }).append( $('<i>', { - 'class' : (sample.showDataOnGraph)?'icon-minus-sign':'icon-plus-sign', + 'class' : (sample.showDataOnGraph)?'icon-chevron-up':'icon-chevron-down', + 'style' : 'cursor:pointer', + })); + + var $addChildLink = $('<a>', { + 'href' : "javascript:mainController.currentView._addChildFor('" + sample.permId + "');" + }).append( + $('<i>', { + 'class' : 'icon-plus-sign', 'style' : 'cursor:pointer', })); @@ -358,6 +399,7 @@ function SampleHierarchy(serverFacade, inspector, containerId, profile, sample) $nodeContent .append($hideLink) .append($dataLink) + .append($addChildLink) .append(sample.sampleTypeCode + ':') .append($sampleLink); -- GitLab