From bff0f4c09d408bea128c9ccd443ec81d072e0c57 Mon Sep 17 00:00:00 2001
From: Mariia Pukhliakova <mariia.pukhliakova@id.ethz.ch>
Date: Mon, 6 Jan 2020 17:06:01 +0100
Subject: [PATCH] SSDM-9053 return readonly mode for CKEditor5

---
 .../webapps/eln-lims/html/js/util/FormUtil.js | 51 +++++++++----------
 .../js/views/ProjectForm/ProjectFormView.js   |  4 +-
 2 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js
index dbb62b1c654..44cb663e706 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js
@@ -830,7 +830,7 @@ var FormUtil = new function() {
 		return $component;
 	}
 	
-this._getTextBox = function(id, alt, isRequired) {
+    this._getTextBox = function(id, alt, isRequired) {
 		var $component = $('<textarea>', {'id' : id, 'alt' : alt, 'style' : 'height: 80px; width: 450px;', 'placeholder' : alt, 'class' : 'form-control'});
 		if (isRequired) {
 			$component.attr('required', '');
@@ -876,34 +876,29 @@ this._getTextBox = function(id, alt, isRequired) {
 	}
 
 	this.createCkeditor = function($component, componentOnChange, value, isReadOnly) {
-
-        if(isReadOnly && value) {
-            $component.append(value);
-        } else {
-            InlineEditor.create($component[0], {
-                             simpleUpload: {
-                                 uploadUrl: "/openbis/openbis/file-service/eln-lims?type=Files&sessionID=" + mainController.serverFacade.getSession()
-                             }
-                        })
-                        .then( editor => {
-                            if (value) {
-                                value = this.prepareCkeditorData(value);
-                                editor.setData(value);
-                            }
-
-                            editor.isReadOnly = isReadOnly;
-
-                            editor.model.document.on('change:data', function (event) {
-                                var value = editor.getData();
-                                componentOnChange(event, value);
-                            });
-
-                            CKEditorManager.addEditor($component.attr('id'), editor);
-                        })
-                        .catch(error => {
-                            Util.showError(error);
+        InlineEditor.create($component[0], {
+                         simpleUpload: {
+                             uploadUrl: "/openbis/openbis/file-service/eln-lims?type=Files&sessionID=" + mainController.serverFacade.getSession()
+                         }
+                    })
+                    .then( editor => {
+                        if (value) {
+                            value = this.prepareCkeditorData(value);
+                            editor.setData(value);
+                        }
+
+                        editor.isReadOnly = isReadOnly;
+
+                        editor.model.document.on('change:data', function (event) {
+                            var value = editor.getData();
+                            componentOnChange(event, value);
                         });
-        }
+
+                        CKEditorManager.addEditor($component.attr('id'), editor);
+                    })
+                    .catch(error => {
+                        Util.showError(error);
+                    });
 	}
 
 	this.prepareCkeditorData = function(value) {
diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
index b620a3705ec..60e52a4d35d 100644
--- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
+++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ProjectForm/ProjectFormView.js
@@ -255,7 +255,9 @@ function ProjectFormView(projectFormController, projectFormModel) {
 			$textBox = FormUtil.activateRichTextProperties($textBox, textBoxEvent, null, description, false);
 			$formColumn.append(FormUtil.getFieldForComponentWithLabel($textBox, "Description"));
 		} else {
-			$formColumn.append(FormUtil.getFieldForLabelWithText("Description", description));
+            var $textBox = FormUtil._getTextBox(null, "Description", false);
+			$textBox = FormUtil.activateRichTextProperties($textBox, undefined, null, description, true);
+            $formColumn.append(FormUtil.getFieldForComponentWithLabel($textBox, "Description"));
 		}
 		
 		// Experiment And Samples Table
-- 
GitLab