diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index 25dba4c05334dcc4f72300ea3291e62379803ac9..a08adcd58716eb9e6271d9eeb4e625d790d7406f 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -51,7 +51,13 @@ function SampleFormController(mainController, mode, sample) { this._addCommentsWidget = function($container) { var commentsController = new CommentsController(this._sampleFormModel.sample, this._sampleFormModel.mode, this._sampleFormModel); - commentsController.init($container); + if(this._sampleFormModel.mode !== FormMode.VIEW || + this._sampleFormModel.mode === FormMode.VIEW && !commentsController.isEmpty()) { + commentsController.init($container); + return true; + } else { + return false; + } } this.getLastStorageController = function() { diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index 675931c1aa1bf5b9aeeca39130a7e97957c8a583..ff54fa6e40ecd25651ee56a02557d1c10a55950a 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -243,81 +243,6 @@ function SampleFormView(sampleFormController, sampleFormModel) { currentChildrenLinks, this._sampleFormModel.mode === FormMode.CREATE); - // - // LINKS - // -// var requiredLinks = []; -// if(sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_LINKS_HINT"]) { -// requiredLinks = sampleTypeDefinitionsExtension["SAMPLE_LINKS_HINT"]; -// } -// -// var sampleLinksWidgetId = "sampleLinksWidgetId"; -// var $sampleLinksWidget = $("<div>", { "id" : sampleLinksWidgetId }); -// $formColumn.append($sampleLinksWidget); -// -// var currentOrphanLinksIdentifiers = []; -// var currentOrphanLinksPermIds = []; -// -// //Read the XML to build the orphan links list -// var annotationsFromSample = FormUtil.getAnnotationsFromSample(this._sampleFormModel.sample); -// //Delete parents and children -// if(this._sampleFormModel.sample.parents) { -// for(var idxF = 0; idxF < this._sampleFormModel.sample.parents.length; idxF++) { -// var sample = this._sampleFormModel.sample.parents[idxF]; -// delete annotationsFromSample[sample.permId]; -// } -// } -// if(this._sampleFormModel.sample.children) { -// for(var idxC = 0; idxC < this._sampleFormModel.sample.children.length; idxC++) { -// var sample = this._sampleFormModel.sample.children[idxC]; -// delete annotationsFromSample[sample.permId]; -// } -// } -// //Make samples from Orphans left -// if(annotationsFromSample) { -// for(var orphanSamplePermId in annotationsFromSample) { -// currentOrphanLinksIdentifiers.push(annotationsFromSample[orphanSamplePermId].identifier); -// currentOrphanLinksPermIds.push(orphanSamplePermId); -// } -// } -// -// var isPresentLinkOnData = function(orphanSamplePermId, data) { -// for(var dIdx = 0; dIdx <data.length; dIdx++) { -// if(data[dIdx].permId === orphanSamplePermId) { -// return true; -// } -// } -// return false; -// } -// -// var buildFakeSampleIfNotFoundLink = function(orphanSamplePermId, annotationsFromSample) { -// var orphanSample = {}; -// orphanSample.notFound = true; -// orphanSample.permId = orphanSamplePermId; -// orphanSample.code = annotationsFromSample[orphanSamplePermId].identifier.split('/')[2]; -// orphanSample.identifier = annotationsFromSample[orphanSamplePermId].identifier; -// orphanSample.sampleTypeCode = annotationsFromSample[orphanSamplePermId].sampleType; -// return orphanSample; -// } -// -// var showLinksWidgetAction = function(data) { -// for(var oIdx = 0; oIdx < currentOrphanLinksPermIds.length; oIdx++) { -// if(!isPresentLinkOnData(currentOrphanLinksPermIds[oIdx], data)) { -// data.push(buildFakeSampleIfNotFoundLink(currentOrphanLinksPermIds[oIdx], annotationsFromSample)); -// } -// } -// -// _this._sampleFormModel.sampleLinks = new SampleLinksWidget(sampleLinksWidgetId, -// profile, -// mainController.serverFacade, -// "Links", -// requiredLinks, -// isDisabled, -// data, -// _this._sampleFormModel.mode === FormMode.CREATE); -// _this._sampleFormModel.sampleLinks.repaint(); -// } - // // GENERATE CHILDREN // @@ -468,7 +393,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { if(propertyType.code === "XMLCOMMENTS") { var $commentsContainer = $("<div>"); $fieldset.append($commentsContainer); - this._sampleFormController._addCommentsWidget($commentsContainer); + var isAvailable = this._sampleFormController._addCommentsWidget($commentsContainer); continue; } var $controlGroup = null; @@ -535,7 +460,9 @@ function SampleFormView(sampleFormController, sampleFormModel) { } $fieldset.append($controlGroup); - propertyGroupPropertiesOnForm++; + if(propertyType.code !== "ANNOTATIONS_STATE") { + propertyGroupPropertiesOnForm++; + } } if(propertyGroupPropertiesOnForm === 0) { diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsController.js index c542023a4bffe57f0e1d46e844eb098aa15cc33d..e66e50f411d57b601dfdb1091ce324cd1f64f07e 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsController.js @@ -22,6 +22,18 @@ function CommentsController(entity, mode, form) { this._commentsView.repaint($container); } + this.isEmpty = function() { + var comments = this.getComments(); + return comments === null || comments.length === 0; + } + + this.getComments = function() { + var commentsXML = this._commentsModel.getComments(); + var xmlDoc = new DOMParser().parseFromString(commentsXML, 'text/xml'); + var comments = xmlDoc.getElementsByTagName("commentEntry"); + return comments; + } + this.deleteComment = function(commentTimestampToDelete) { var commentsXML = this._commentsModel.getComments(); var xmlDoc = new DOMParser().parseFromString(commentsXML, 'text/xml'); diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsView.js index e66af2582e14c8c5d334a8ef162dfdade3dc20a5..136e4f1a7037d0eb665224cd5d802fd38adf207f 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsView.js @@ -23,11 +23,9 @@ function CommentsView(commentsController, commentsModel) { this.repaint = function($container) { $container.empty(); $container.append(this.commentsContainer); - this.commentsContainer.append($("<legend>").text("Comments Log")); + this.commentsContainer.append($("<legend>", { "style" : "border-bottom-style:none; font-weight: bold;"} ).text("Comments Log")); $container.append(this.commentsAddButton); - var commentsXML = this._commentsModel.getComments(); - var xmlDoc = new DOMParser().parseFromString(commentsXML, 'text/xml'); - var comments = xmlDoc.getElementsByTagName("commentEntry"); + var comments = this._commentsController.getComments(); for(var i = 0; i < comments.length; i++) { this.addCommentWidgetFromXML(comments[i]); }