From 854db09c50bf8f31e2f55147eec97b19f28e5c2f Mon Sep 17 00:00:00 2001 From: juanf <juanf@bsse-bs-dock-dhcp-404.ethz.ch> Date: Tue, 7 Aug 2018 13:47:01 +0200 Subject: [PATCH] SSDM-6701 : Dropdown for DEFAULT_OBJECT_TYPE + Select2 Dropdowns on Forms --- .../js/views/DataSetForm/DataSetFormView.js | 20 ++++++++++++++++++- .../ExperimentForm/ExperimentFormView.js | 20 ++++++++++++++++++- .../js/views/SampleForm/SampleFormView.js | 12 +++++++++++ 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js index 80d9762db64..11903711e0d 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/DataSetFormView.js @@ -17,6 +17,7 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { this._dataSetFormController = dataSetFormController; this._dataSetFormModel = dataSetFormModel; + this.enableSelect2 = []; this.repaint = function(views) { var $container = views.content; @@ -181,7 +182,7 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { } _this.isFormDirty = true; }); - + this.enableSelect2.push($dataSetTypeSelector); var $dataSetTypeDropDown = $('<div>', { class : 'form-group' }); if(!this._dataSetFormModel.isMini) { $dataSetTypeDropDown.append($('<label>', {class: "control-label"}).html('Data Set Type (*):')); @@ -407,6 +408,12 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { var dataSetViewer = new DataSetViewerController("filesViewer", profile, this._dataSetFormModel.entity, mainController.serverFacade, profile.getDefaultDataStoreURL(), [this._dataSetFormModel.dataSet], false, true); dataSetViewer.init(); } + + // Select2 + for(var cIdx = 0;cIdx < this.enableSelect2.length; cIdx++) { + this.enableSelect2[cIdx].select2({ width: '100%', theme: "bootstrap" }); + } + // } this._updateFileOptions = function() { @@ -474,6 +481,7 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { this._repaintMetadata = function(dataSetType) { var _this = this; + this.enableSelect2 = []; $("#metadataContainer").empty(); var $wrapper = $("<div>"); @@ -577,6 +585,10 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { } } + if(propertyType.dataType === "CONTROLLEDVOCABULARY") { + this.enableSelect2.push($component); + } + //Update values if is into edit mode if(this._dataSetFormModel.mode === FormMode.EDIT) { if(propertyType.dataType === "BOOLEAN") { @@ -618,6 +630,12 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { } $("#metadataContainer").append($wrapper); + + // Select2 + for(var cIdx = 0;cIdx < this.enableSelect2.length; cIdx++) { + this.enableSelect2[cIdx].select2({ width: '100%', theme: "bootstrap" }); + } + // } this.requestArchiving = function() { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js index cd3b38ed2e4..c37bfc92b30 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js @@ -17,6 +17,7 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { this._experimentFormController = experimentFormController; this._experimentFormModel = experimentFormModel; + this.enableSelect2 = []; this.repaint = function(views) { var $container = views.content; @@ -242,6 +243,12 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { // $container.append($form); + // Select2 + for(var cIdx = 0;cIdx < this.enableSelect2.length; cIdx++) { + this.enableSelect2[cIdx].select2({ width: '100%', theme: "bootstrap" }); + } + // + Util.unblockUI(); if(this._experimentFormModel.mode !== FormMode.CREATE) { @@ -406,8 +413,19 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { continue; } } else { - var $component = FormUtil.getFieldForPropertyType(propertyType, value); + var $component = null; + if(propertyType.code === "DEFAULT_OBJECT_TYPE") { + $component = FormUtil.getSampleTypeDropdown(propertyType.code, true); + this.enableSelect2.push($component); + } else { + $component = FormUtil.getFieldForPropertyType(propertyType, value); + } + //Update values if is into edit mode + if(propertyType.dataType === "CONTROLLEDVOCABULARY") { + this.enableSelect2.push($component); + } + if(this._experimentFormModel.mode === FormMode.EDIT) { if(propertyType.dataType === "BOOLEAN") { $($($component.children()[0]).children()[0]).prop('checked', value === "true"); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index 2b41a09cf71..97bfbe8d90b 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -17,6 +17,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { this._sampleFormController = sampleFormController; this._sampleFormModel = sampleFormModel; + this.enableSelect2 = []; this.repaint = function(views, loadFromTemplate) { var $container = views.content; @@ -526,6 +527,12 @@ function SampleFormView(sampleFormController, sampleFormModel) { // $container.append($form); + // Select2 + for(var cIdx = 0;cIdx < this.enableSelect2.length; cIdx++) { + this.enableSelect2[cIdx].select2({ width: '100%', theme: "bootstrap" }); + } + // + // // Extra content // @@ -614,6 +621,11 @@ function SampleFormView(sampleFormController, sampleFormModel) { } } else { var $component = FormUtil.getFieldForPropertyType(propertyType, value); + + if(propertyType.dataType === "CONTROLLEDVOCABULARY") { + this.enableSelect2.push($component); + } + //Update values if is into edit mode if(this._sampleFormModel.mode === FormMode.EDIT || loadFromTemplate) { if(propertyType.dataType === "BOOLEAN") { -- GitLab