From a5bc8f769d3a9f8602ca1aeb3689548dc3e93295 Mon Sep 17 00:00:00 2001 From: felmer <franz-josef.elmer@id.ethz.ch> Date: Mon, 27 Aug 2018 13:34:22 +0200 Subject: [PATCH] SSDM-7071: Turning many dropdowns to seleclt2 dropdowns --- .../html/js/controllers/MainController.js | 3 +- .../as/webapps/eln-lims/html/js/util/Util.js | 31 +++++-------------- .../js/views/DataSetForm/DataSetFormView.js | 2 +- .../ExperimentTable/ExperimentTableView.js | 5 ++- .../js/views/ProjectForm/ProjectFormView.js | 2 +- .../views/SampleForm/SampleFormController.js | 6 +++- .../js/views/SampleForm/SampleFormView.js | 2 ++ .../js/views/SampleForm/widgets/LinksView.js | 2 +- .../js/views/SampleTable/SampleTableView.js | 3 +- .../SampleTable/widgets/MoveSampleView.js | 10 +++--- .../SampleTable/widgets/TypeAndFileView.js | 1 + .../StorageManager/widgets/StorageView.js | 2 ++ .../html/js/views/legacy/SampleHierarchy.js | 17 ++-------- 13 files changed, 35 insertions(+), 51 deletions(-) diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index d8d87a17dde..0a184649b11 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -845,8 +845,7 @@ function MainController(profile) { var $dropdown = FormUtil.getDropdown(settingsForDropdown, "Select settings"); $dropdown.attr("id", "settingsDropdown"); - Util.blockUI($dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='settingsDropdownCancel'>Cancel</a>"); - $("#settingsDropdown").select2({ width: '100%', theme: "bootstrap" }); + Util.showDropdownAndBlockUI("settingsDropdown", $dropdown); $("#settingsDropdown").on("change", function(event) { var sampleIdentifier = $("#settingsDropdown")[0].value; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js index 8899f48aa27..7fb4f76d40c 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/Util.js @@ -26,7 +26,6 @@ var Util = new function() { // this.blockUINoMessage = function() { this.unblockUI(); - BlockScrollUtil.disable_scroll(); $('#navbar').block({ message: '', css: { width: '0px' } }); $.blockUI({ message: '', css: { width: '0px' } }); } @@ -49,9 +48,13 @@ var Util = new function() { }); } + this.showDropdownAndBlockUI = function(id, $dropdown) { + Util.blockUI($dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='" + id + "Cancel'>Cancel</a>"); + $("#" + id).select2({ width: '100%', theme: "bootstrap" }); + } + this.blockUI = function(message, extraCSS, disabledFadeAnimation) { this.unblockUI(); - BlockScrollUtil.disable_scroll(); var css = { 'border': 'none', @@ -72,7 +75,7 @@ var Util = new function() { $('#navbar').block({ message: '', css: { width: '0px' } }); var params = { css : css }; - if(message) { + if (message) { params.message = message; } else { params.message = '<h1><img src="./img/busy.gif" /> Just a moment...</h1>'; @@ -82,25 +85,6 @@ var Util = new function() { params.fadeOut = 0; } $.blockUI(params); - - //Enable/Disable scroll when the mouse goes in/out - $('.blockUI.blockMsg.blockPage').hover(function() { - if(this.scrollHeight > this.clientHeight) { //Inside, if has scroll, enable when hovering in - BlockScrollUtil.enable_scroll(); - } - }, function() { - BlockScrollUtil.disable_scroll(); //Always disable when hovering out - } - ); - - //Enable/Disable scroll when components change - $('.blockUI.blockMsg.blockPage').bind("DOMSubtreeModified",function() { - if(this.scrollHeight > this.clientHeight) { //Inside, if has scroll, enable - BlockScrollUtil.enable_scroll(); - } else { //If doesn't disable - BlockScrollUtil.disable_scroll(); - } - }); } // @@ -111,8 +95,7 @@ var Util = new function() { $.unblockUI({ onUnblock: function() { window.setTimeout(function() { //Enable after all possible enable/disable events happen - BlockScrollUtil.enable_scroll(); - if(callback) { + if (callback) { callback(); } }, 150); 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 7f2287c763a..006dab1d963 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 @@ -397,7 +397,7 @@ function DataSetFormView(dataSetFormController, dataSetFormModel) { } else { var showSelectDatasetType = function() { var $dropdown = FormUtil.getDataSetsDropDown("datasetTypeForDataset", _this._dataSetFormModel.dataSetTypes); - Util.blockUI("Select the type for the Dataset: <br><br>" + $dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='datasetTypeForDatasetCancel'>Cancel</a>"); + Util.showDropdownAndBlockUI("datasetTypeForDataset", $dropdown); $("#datasetTypeForDataset").on("change", function(event) { var datasetTypeCode = $("#datasetTypeForDataset")[0].value; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentTable/ExperimentTableView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentTable/ExperimentTableView.js index cb6641b2a30..c689d2720d1 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentTable/ExperimentTableView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentTable/ExperimentTableView.js @@ -36,6 +36,8 @@ function ExperimentTableView(experimentTableController, experimentTableModel) { $container.append(FormUtil.getToolbar(toolbarModel)); $container.append(this._tableContainer); + $("#what-experiments-drop-down").select2({ width: '100%', theme: "bootstrap" }); + $("#project-experiment-type-drop-down").select2({ width: '100%', theme: "bootstrap" }); } this.getTableContainer = function() { @@ -58,6 +60,7 @@ function ExperimentTableView(experimentTableController, experimentTableModel) { var $experimentDropdown = FormUtil.getDropdown(expDropModel, "Select what " + ELNDictionary.getExperimentKindName(projectIdentifier, true) + " to show"); + $experimentDropdown.attr("id", "what-experiments-drop-down"); $experimentDropdown.change(function() { switch($(this).val()){ @@ -75,7 +78,7 @@ function ExperimentTableView(experimentTableController, experimentTableModel) { this._getProjectExperimentTypesDropdown = function() { var _this = this; - var $typesSelector = $('<select>', { class : 'form-control' }); + var $typesSelector = $('<select>', { class : 'form-control', id : 'project-experiment-type-drop-down' }); var projectIdentifier = IdentifierUtil.getProjectIdentifier(this._experimentTableModel.project.spaceCode, this._experimentTableModel.project.code); $typesSelector.append($("<option>").attr('value', '').attr('selected', '').attr('disabled', '').text("Select an " + ELNDictionary.getExperimentKindName(projectIdentifier, true) + " type")); for(typeCode in this._experimentTableModel.types) { 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 3426f14f49e..b86e699780f 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 @@ -63,7 +63,7 @@ function ProjectFormView(projectFormController, projectFormModel) { if(this._projectFormModel.mode === FormMode.VIEW) { var showSelectExperimentType = function() { var $dropdown = FormUtil.getExperimentTypeDropdown("experimentTypeDropdown", true); - Util.blockUI("Select the type for the " + ELNDictionary.getExperimentKindName(projectIdentifier) + ": <br><br>" + $dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='experimentTypeDropdownCancel'>Cancel</a>"); + Util.showDropdownAndBlockUI("experimentTypeDropdown", $dropdown); $("#experimentTypeDropdown").on("change", function(event) { var experimentTypeCode = $("#experimentTypeDropdown")[0].value; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index f2515780d0b..1b1692d7984 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -258,7 +258,11 @@ function SampleFormController(mainController, mode, sample, paginationInfo) { storagePosition.properties[storagePropertyGroup.rowProperty] = 1; storagePosition.properties[storagePropertyGroup.columnProperty] = 1; storagePosition.properties[storagePropertyGroup.boxSizeProperty] = "1X1"; - storagePosition.properties[storagePropertyGroup.boxProperty] = experimentIdentifier.replace(/\//g,'\/') + "_" + sample.code + "_EXP_RESULTS"; + var boxProperty = sample.code + "_EXP_RESULTS"; + if (experimentIdentifier) { + boxProperty = experimentIdentifier.replace(/\//g,'\/') + "_" + boxProperty; + } + storagePosition.properties[storagePropertyGroup.boxProperty] = boxProperty; storagePosition.properties[storagePropertyGroup.userProperty] = mainController.serverFacade.openbisServer.getSession().split("-")[0]; storagePosition.properties[storagePropertyGroup.positionProperty] = "A1"; 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 8766549f50f..1c6bed4ff07 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 @@ -891,6 +891,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { if($childrenStorageDropdown && !$("#childrenStorageSelector").length) { var $childrenStorageDropdownWithLabel = FormUtil.getFieldForComponentWithLabel($childrenStorageDropdown, 'Storage'); $("#newChildrenOnBenchDropDown").append($childrenStorageDropdownWithLabel); + $childrenStorageDropdown.select2({ width: '100%', theme: "bootstrap" }); } }); } @@ -1086,6 +1087,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { var $childrenTypeDropdown = FormUtil.getSampleTypeDropdown('childrenTypeSelector', true); var $childrenTypeDropdownWithLabel = FormUtil.getFieldForComponentWithLabel($childrenTypeDropdown, 'Type'); $childrenComponent.append($childrenTypeDropdownWithLabel); + $childrenTypeDropdown.select2({ width: '100%', theme: "bootstrap" }); var $childrenReplicas = FormUtil._getInputField('number', 'childrenReplicas', 'Children Replicas', '1', true); $childrenReplicas.val("1"); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js index 2a1f5ec00cf..dfbb947f225 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js @@ -439,7 +439,7 @@ function LinksView(linksController, linksModel) { linksView.getAddAnyBtn = function() { var enabledFunction = function() { var $sampleTypesDropdown = FormUtil.getSampleTypeDropdown("sampleTypeSelector", true); - Util.blockUI($sampleTypesDropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='sampleTypeSelectorCancel'>Cancel</a>"); + Util.showDropdownAndBlockUI("sampleTypeSelector", $sampleTypesDropdown); $("#sampleTypeSelector").on("change", function(event) { var sampleTypeCode = $(this).val(); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js index 7534aedb553..9818e80ab8e 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js @@ -193,8 +193,7 @@ function SampleTableView(sampleTableController, sampleTableModel) { this.createNewSample = function(experimentIdentifier) { var _this = this; var $dropdown = FormUtil.getSampleTypeDropdown("sampleTypeDropdown", true); - Util.blockUI($dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='sampleTypeDropdownCancel'>Cancel</a>"); - $("#sampleTypeDropdown").select2({ width: '100%', theme: "bootstrap" }); + Util.showDropdownAndBlockUI("sampleTypeDropdown", $dropdown); $("#sampleTypeDropdown").on("change", function(event) { var sampleTypeCode = $("#sampleTypeDropdown")[0].value; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js index 3847bfd44a3..3ebf45e63d3 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/MoveSampleView.js @@ -69,8 +69,9 @@ function MoveSampleView(moveSampleController, moveSampleModel) { var _this = this; $experimentSection.empty(); FormUtil.getProjectAndExperimentsDropdown(true, false, true, function($dropdown) { + $dropdown.attr("id", "future-projects-drop-down"); //Fields - var $expTypeField = FormUtil.getExperimentTypeDropdown(null, true); + var $expTypeField = FormUtil.getExperimentTypeDropdown("future-experiment-type-drop-down", true); var $expNameField = FormUtil._getInputField('text', null, 'Future ' + ELNDictionary.getExperimentDualName() + ' Name', null, true); //Events @@ -96,16 +97,16 @@ function MoveSampleView(moveSampleController, moveSampleModel) { $experimentSection.append(FormUtil.getFieldForComponentWithLabel($dropdown, "Future Project")) .append(FormUtil.getFieldForComponentWithLabel($expTypeField, "Future " + ELNDictionary.getExperimentDualName() + " Type")) .append(FormUtil.getFieldForComponentWithLabel($expNameField, "Future " + ELNDictionary.getExperimentDualName() + " Name")); + $("#future-projects-drop-down").select2({ width: '100%', theme: "bootstrap" }); + $("#future-experiment-type-drop-down").select2({ width: '100%', theme: "bootstrap" }); }); - - - } this.repaintExistingExperiment = function() { var _this = this; $experimentSection.empty(); FormUtil.getProjectAndExperimentsDropdown(false, true, true, function($dropdown) { + $dropdown.attr("id", "existing-experiments-drop-down"); //Events $dropdown.change(function(event){ var value = $(event.target).val(); @@ -113,6 +114,7 @@ function MoveSampleView(moveSampleController, moveSampleModel) { }); //Attach Fields $experimentSection.append(FormUtil.getFieldForComponentWithLabel($dropdown, "Future " + ELNDictionary.getExperimentDualName() + "")); + $("#existing-experiments-drop-down").select2({ width: '100%', theme: "bootstrap" }); }); } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/TypeAndFileView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/TypeAndFileView.js index 742b9eae680..8b1bd993f9b 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/TypeAndFileView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/widgets/TypeAndFileView.js @@ -37,6 +37,7 @@ function TypeAndFileView(typeAndFileController, typeAndFileModel) { }); var $sampleTypeDropDownBoxGroup = FormUtil.getFieldForComponentWithLabel($sampleTypeDropDown, ELNDictionary.Sample + ' Type'); $window.append($sampleTypeDropDownBoxGroup); + $sampleTypeDropDown.select2({ width: '100%', theme: "bootstrap" }); $window.append(this.linkContainer); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/StorageView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/StorageView.js index 718bd855c65..fac0deb9fc7 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/StorageView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/StorageManager/widgets/StorageView.js @@ -92,6 +92,7 @@ function StorageView(storageController, storageModel, gridViewRack, gridViewPosi //Paint var $controlGroupStorages = FormUtil.getFieldForComponentWithLabel(_this._defaultStoragesDropDown); addToTitleLine("Storage:", $controlGroupStorages); + _this._defaultStoragesDropDown.select2({ width: '100%', theme: "bootstrap" }); //Attach Event _this._defaultStoragesDropDown.change(function(event) { var storageName = $(this).val(); @@ -169,6 +170,7 @@ function StorageView(storageController, storageModel, gridViewRack, gridViewPosi _this._storageController.setBoxSizeSelected(_this._storageModel.sample.properties[_this._storageModel.storagePropertyGroup.boxSizeProperty], false); _this._boxSizeDropDown.attr("disabled", ""); } + _this._boxSizeDropDown.select2({ width: '100%', theme: "bootstrap" }); } if(_this._storageModel.config.positionSelector === "on") { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js index ba08f6e4f70..b9dbfc5f1c3 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/legacy/SampleHierarchy.js @@ -167,20 +167,9 @@ function SampleHierarchy(serverFacade, views, profile, sample) { this._addChildFor = function(permId) { var sampleTypes = this.profile.getAllSampleTypes(); - var component = "<select id='sampleTypeSelector' class='form-control' required>"; - component += "<option disabled=\"disabled\" selected></option>"; - for(var i = 0; i < sampleTypes.length; i++) { - var sampleType = sampleTypes[i]; - var label = Util.getEmptyIfNull(sampleType.description); - if(label === "") { - label = sampleType.code; - } - - component += "<option value='" + sampleType.code + "'>" + label + "</option>"; - } - component += "</select>"; - - Util.blockUI("Select the type for the Child: <br><br>" + component + "<br> or <a class='btn btn-default' id='sampleTypeSelectorCancel'>Cancel</a>"); + var $dropdown = FormUtil.getSampleTypeDropdown('sampleTypeSelector', true); + Util.blockUI("Select the type for the Child: <br><br>" + $dropdown[0].outerHTML + "<br> or <a class='btn btn-default' id='sampleTypeSelectorCancel'>Cancel</a>"); + $("#sampleTypeSelector").select2({ width: '100%', theme: "bootstrap" }); $("#sampleTypeSelectorCancel").on("click", function(event) { Util.unblockUI(); -- GitLab