From 9fc12dec7012fecb930d3634a3c51b4fe4160d5b Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Tue, 24 Mar 2015 16:35:00 +0000 Subject: [PATCH] SSDM-1614 : YEASTLAB - ELN UI - Show Names (Fix names on links) SVN: 33726 --- .../newbrowser/html/js/server/ServerFacade.js | 66 ++++++++++++------- .../js/views/SampleForm/SampleFormView.js | 35 +++++----- 2 files changed, 61 insertions(+), 40 deletions(-) diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js index c392369a7d3..4363731d9af 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/server/ServerFacade.js @@ -542,34 +542,52 @@ function ServerFacade(openbisServer) { this.searchWithIdentifiers = function(sampleIdentifiers, callbackFunction) { - var matchClauses = []; - sampleIdentifiers.forEach(function(sampleIdentifier){ - matchClauses.push({ - "@type":"AttributeMatchClause", - fieldType : "ATTRIBUTE", - attribute : "SPACE", - desiredValue : sampleIdentifier.split("/")[1] - }, - { - "@type":"AttributeMatchClause", - fieldType : "ATTRIBUTE", - attribute : "CODE", - desiredValue : sampleIdentifier.split("/")[2] - }); - }); + var _this = this; + var searchResults = []; + var searchForIdentifiers = jQuery.extend(true, [], sampleIdentifiers); + var searchFunction = null; + + var searchNext = function() { + if(searchForIdentifiers.length === 0) { + callbackFunction(searchResults); + } else { + var next = searchForIdentifiers.pop(); + searchFunction(next); + } + } - var sampleCriteria = - { - matchClauses : matchClauses, - operator : "MATCH_ALL_CLAUSES" - }; + var searchFunction = function(sampleIdentifier) { + var matchClauses = [{ + "@type":"AttributeMatchClause", + fieldType : "ATTRIBUTE", + attribute : "SPACE", + desiredValue : sampleIdentifier.split("/")[1] + }, { + "@type":"AttributeMatchClause", + fieldType : "ATTRIBUTE", + attribute : "CODE", + desiredValue : sampleIdentifier.split("/")[2] + }]; + + var sampleCriteria = { + matchClauses : matchClauses, + operator : "MATCH_ALL_CLAUSES" + } + + _this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES", "ANCESTORS", "DESCENDANTS"], function(data) { + var partialResults = _this.getInitializedSamples(data.result); + partialResults.forEach(function(partialResult) { + searchResults.push(partialResult); + }); + + searchNext(); + }); + } - var localReference = this; - this.openbisServer.searchForSamplesWithFetchOptions(sampleCriteria, ["PROPERTIES", "ANCESTORS", "DESCENDANTS"], function(data) { - callbackFunction(localReference.getInitializedSamples(data.result)); - }); + searchNext(); } + this.searchWithUniqueId = function(samplePermId, callbackFunction) { var matchClauses = [ diff --git a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js index 43fce293186..17dd12186ae 100644 --- a/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/newbrowser/1/as/webapps/newbrowser/html/js/views/SampleForm/SampleFormView.js @@ -233,23 +233,21 @@ function SampleFormView(sampleFormController, sampleFormModel) { //Make samples from Orphans left if(annotationsFromSample) { for(var orphanSamplePermId in annotationsFromSample) { - var orphanSample = {}; - orphanSample.permId = orphanSamplePermId; - orphanSample.code = annotationsFromSample[orphanSamplePermId].identifier.split('/')[2]; - orphanSample.identifier = annotationsFromSample[orphanSamplePermId].identifier; - orphanSample.sampleTypeCode = annotationsFromSample[orphanSamplePermId].sampleType; - orphanSample.properties = { "NAME" : "TO-DO, get names on links"}; - currentOrphanLinks.push(orphanSample); + currentOrphanLinks.push(annotationsFromSample[orphanSamplePermId].identifier); } } - this._sampleFormModel.sampleLinks = new SampleLinksWidget(sampleLinksWidgetId, - profile, - mainController.serverFacade, - "Links", - requiredLinks, - isDisabled, - currentOrphanLinks, - this._sampleFormModel.mode === FormMode.CREATE); + + var showLinksWidgetAction = function(data) { + _this._sampleFormModel.sampleLinks = new SampleLinksWidget(sampleLinksWidgetId, + profile, + mainController.serverFacade, + "Links", + requiredLinks, + isDisabled, + data, + _this._sampleFormModel.mode === FormMode.CREATE); + _this._sampleFormModel.sampleLinks.repaint(); + } // // LINKS TO CHILDREN @@ -447,7 +445,12 @@ function SampleFormView(sampleFormController, sampleFormModel) { //Repaint parents and children after updating the property state to show the annotations this._sampleFormModel.sampleLinksParents.repaint(); this._sampleFormModel.sampleLinksChildren.repaint(); - this._sampleFormModel.sampleLinks.repaint(); + + if(currentOrphanLinks.length !== 0) { + mainController.serverFacade.searchWithIdentifiers(currentOrphanLinks, showLinksWidgetAction); + } else { + showLinksWidgetAction([]); + } if(this._sampleFormModel.mode !== FormMode.CREATE) { //Preview image -- GitLab