diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js index 4266047457ed3cccd53d37652622eec149973299..f21fd5ff39d84715c967fb7fe449872f751cb060 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js @@ -1280,9 +1280,11 @@ var FormUtil = new function() { } this.fixStringPropertiesForForm = function(propertyType, entity) { - var originalValue = entity.properties[propertyType.code]; - if(propertyType.metaData["custom_widget"] && propertyType.metaData["custom_widget"] === "Word Processor" && originalValue) { // Only filter properties rendered as HTML - entity.properties[propertyType.code] = this.sanitizeRichHTMLText(originalValue); + if(entity) { + var originalValue = entity.properties[propertyType.code]; + if(propertyType.metaData["custom_widget"] && propertyType.metaData["custom_widget"] === "Word Processor" && originalValue) { // Only filter properties rendered as HTML + entity.properties[propertyType.code] = this.sanitizeRichHTMLText(originalValue); + } } } diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js index a731947a24ba7f1ed6e27c6d00719f43f172aaf3..3c68d2b5bfe7857d514d152f9dc1cf21d7e52698 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormController.js @@ -18,6 +18,7 @@ function DataSetFormController(parentController, mode, entity, dataSet, isMini, this._parentController = parentController; this._dataSetFormModel = new DataSetFormModel(mode, entity, isMini, dataSetV3); this._dataSetFormView = new DataSetFormView(this, this._dataSetFormModel); + this._commentsController = null; this.init = function(views) { var _this = this; @@ -70,10 +71,10 @@ function DataSetFormController(parentController, mode, entity, dataSet, isMini, } this._addCommentsWidget = function($container) { - var commentsController = new CommentsController(this._dataSetFormModel.dataSetV3, this._dataSetFormModel.mode, this._dataSetFormModel); + this._commentsController = new CommentsController(this._dataSetFormModel.dataSetV3, this._dataSetFormModel.mode, this._dataSetFormModel); if(this._dataSetFormModel.mode !== FormMode.VIEW || - this._dataSetFormModel.mode === FormMode.VIEW && !commentsController.isEmpty()) { - commentsController.init($container); + this._dataSetFormModel.mode === FormMode.VIEW && !this._commentsController.isEmpty()) { + this._commentsController.init($container); return true; } else { return false; @@ -154,6 +155,9 @@ function DataSetFormController(parentController, mode, entity, dataSet, isMini, // Metadata Submit and Creation (Step 2) // var metadata = this._dataSetFormModel.dataSetV3 ? this._dataSetFormModel.dataSetV3.properties : {}; + if(this._commentsController) { + metadata = Object.assign({}, metadata, this._commentsController._commentsModel._getProperties()); + } var isZipDirectoryUpload = profile.isZipDirectoryUpload($('#DATASET_TYPE').val()); if(isZipDirectoryUpload === null) { diff --git a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsModel.js b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsModel.js index 1f9d7731aa0d1682c082fa2a905f3ab00962bdb8..0241db07c7136a8a0a77e684aa357f8c1dbea6a9 100644 --- a/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsModel.js +++ b/ui-eln-lims/src/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/CommentsModel.js @@ -20,11 +20,19 @@ function CommentsModel(entity, mode, form) { this.form = form; this.getComments = function() { - return this.entity.properties["$XMLCOMMENTS"]; + return this._getProperties()["$XMLCOMMENTS"]; } this.setComments = function(commentsXML) { - this.entity.properties["$XMLCOMMENTS"] = commentsXML; + this._getProperties()["$XMLCOMMENTS"] = commentsXML; this.form.isFormDirty = true; } + + this._getProperties = function() { + if(!this.entity) { + this.entity = { properties : {} }; + } + return this.entity.properties; + } + } \ No newline at end of file