From 30aebf6d0f5d1fe392102ff5975b4ee7ad97b969 Mon Sep 17 00:00:00 2001 From: felmer <franz-josef.elmer@id.ethz.ch> Date: Mon, 10 Apr 2023 10:34:21 +0200 Subject: [PATCH] SSDM-13120: Show semanric annotations for sample types --- .../eln-lims/html/js/server/ServerFacade.js | 3 +- .../js/views/SampleForm/SampleFormView.js | 28 ++++++++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js index fc9f1f39665..f10c7d33963 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js @@ -2409,6 +2409,7 @@ function ServerFacade(openbisServer) { v1Sample["experimentIdentifierOrNull"] = (v3Sample.experiment)?v3Sample.experiment.identifier.identifier:null; v1Sample["experimentTypeCode"] = v3Sample.experiment && v3Sample.experiment.type ? v3Sample.experiment.type.code : null; v1Sample["sampleTypeCode"] = (v3Sample.type)?v3Sample.type.code:null; + v1Sample["semanticAnnotations"] = (v3Sample.type)?v3Sample.type.semanticAnnotations:null; v1Sample["properties"] = v3Sample.properties; v1Sample["registrationDetails"] = {}; @@ -2741,7 +2742,7 @@ function ServerFacade(openbisServer) { // var fetchOptions = new SampleFetchOptions(); fetchOptions.withSpace(); - fetchOptions.withType(); + fetchOptions.withType().withSemanticAnnotations(); fetchOptions.withRegistrator(); fetchOptions.withModifier(); fetchOptions.withProject(); diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index 2ee13ab8afb..896e08c16e8 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -851,6 +851,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { $fieldset.append(FormUtil.getFieldForComponentWithLabel(entityPath, "Path")); } $fieldset.append(FormUtil.getFieldForLabelWithText("Type", this._sampleFormModel.sample.sampleTypeCode)); + this._appendSemanticAnnotions($fieldset); if(this._sampleFormModel.sample.experimentIdentifierOrNull) { $fieldset.append(FormUtil.getFieldForLabelWithText(ELNDictionary.getExperimentKindName(this._sampleFormModel.sample.experimentTypeCode), this._sampleFormModel.sample.experimentIdentifierOrNull)); } @@ -919,7 +920,32 @@ function SampleFormView(sampleFormController, sampleFormModel) { return $identificationInfo; } - this._createParentsSection = function(hideShowOptionsModel, sampleTypeDefinitionsExtension, sampleTypeCode, loadFromTemplate) { + this._appendSemanticAnnotions = function($fieldset) { + if (this._sampleFormModel.sample.semanticAnnotations && this._sampleFormModel.sample.semanticAnnotations.length > 0) { + var $group = $("<div>", {class : "form-group"}); + $group.append($("<label>", {class : "control-label"}).text("Semantic Annotations:")); + var $controls = $("<div>", {class : "controls" }); + var _this = this; + this._sampleFormModel.sample.semanticAnnotations.forEach(function(annotation) { + var $line = $("<div>"); + $line.append(_this.asHyperLinkOrText(annotation.getDescriptorAccessionId())); + $line.append(" (Ontology: "); + $line.append(_this.asHyperLinkOrText(annotation.getDescriptorOntologyId())); + $line.append(", Version: "); + $line.append(_this.asHyperLinkOrText(annotation.getDescriptorOntologyVersion())); + $line.append(")"); + $controls.append($line); + }); + $group.append($controls); + $fieldset.append($("<div>").append($group)); + } + } + + this.asHyperLinkOrText = function(text) { + return text.startsWith("http") ? FormUtil.asHyperlink(text) : text; + } + + this._createParentsSection = function(hideShowOptionsModel, sampleTypeDefinitionsExtension, sampleTypeCode, loadFromTemplate) { var _this = this; var requiredParents = []; if (sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_PARENTS_HINT"]) { -- GitLab