diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js index a2a853232a04cb1bb497d34022a17cf49fe512ca..acf393c80870fe28d8403fc01f851f03e8d9512f 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/SettingsManager.js @@ -19,10 +19,17 @@ function SettingsManager(serverFacade) { } this.loadSettings = function(callback) { - this._serverFacade.searchSamples({ "sampleIdentifier" : "/ELN_SETTINGS/GENERAL_ELN_SETTINGS", "withProperties" : true }, (function(data) { - if (data && data[0] && data[0].properties && data[0].properties.ELN_SETTINGS) { - var settings = JSON.parse(data[0].properties.ELN_SETTINGS); - callback(settings); + this._serverFacade.searchSamples({ "sampleTypeCode" : "GENERAL_ELN_SETTINGS", + "withProperties" : true }, (function(settingsObjects) { + if(settingsObjects && settingsObjects.length > 0) { + settingsObjects.sort(function(a, b) { + if(a.identifier === "/ELN_SETTINGS/GENERAL_ELN_SETTINGS") { // Global settings are applied first to be overriden by others + return 1; + } else { + return -1; + } + }); + callback(settingsObjects); } else { callback(); } @@ -32,15 +39,23 @@ function SettingsManager(serverFacade) { // Loads settings and logs validation errors to console. // Applies the settings to the profile even if they are invalid. - this.loadSettingsAndApplyToProfile = function(doneCallback) { - this.loadSettings((function(settings) { - if (settings) { - var errors = this._validateSettings(settings); - if (errors.length > 0) { - console.log("The settings contain the following errors:"); - console.log(errors); + this.loadSettingsAndApplyToProfile = function(doneCallback, profileToEditOrNull) { + this.loadSettings((function(settingsObjects) { + if(settingsObjects) { + for(var sIdx = 0; sIdx < settingsObjects.length; sIdx++) { + var settingsObject = settingsObjects[sIdx]; + if (settingsObject && settingsObject.properties && settingsObject.properties.ELN_SETTINGS) { + var settings = JSON.parse(settingsObject.properties.ELN_SETTINGS); + if (settings) { + var errors = this._validateSettings(settings); + if (errors.length > 0) { + console.log("The settings contain the following errors:"); + console.log(errors); + } + this.applySettingsToProfile(settings, (profileToEditOrNull)?profileToEditOrNull:profile); + } + } } - this.applySettingsToProfile(settings, profile); } doneCallback(); }).bind(this)); @@ -71,7 +86,7 @@ function SettingsManager(serverFacade) { } this.applySettingsToProfile = function(settings, targetProfile) { - // fields to be overwritten + // fields that get overwritten with settings if found var fields = [ "dataSetTypeForFileNameMap", "forcedDisableRTF", @@ -83,15 +98,19 @@ function SettingsManager(serverFacade) { targetProfile[field] = settings[field]; } } - // main menu + // main menu, checks menu items one by one to keep new ones for (var menuItem of Object.keys(targetProfile.mainMenu)) { if (settings.mainMenu[menuItem] != undefined) { targetProfile.mainMenu[menuItem] = settings.mainMenu[menuItem]; } } - // sampleTypeDefinitionsExtension + // sampleTypeDefinitionsExtension gets overwritten with settings if found for (var sampleType of Object.keys(settings.sampleTypeDefinitionsExtension)) { profile.sampleTypeDefinitionsExtension[sampleType] = settings.sampleTypeDefinitionsExtension[sampleType]; + // Add the types to hide + if(settings.sampleTypeDefinitionsExtension[sampleType].HIDE) { + targetProfile.hideTypes["sampleTypeCodes"].push(sampleType); + } } } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js index b2454b21db8bcdc9e26d3324b5315e05be3a1ff1..a7e7904184c81d05efa3353bfdc6b473a9196d18 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/StandardProfile.js @@ -254,12 +254,17 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, { } ], }, + "GENERAL_ELN_SETTINGS" : { + "HIDE" : true + }, "STORAGE" : { "SAMPLE_CHILDREN_DISABLED" : true, "SAMPLE_PARENTS_DISABLED" : true, + "HIDE" : true }, "STORAGE_POSITION" : { - "SAMPLE_CHILDREN_DISABLED" : true + "SAMPLE_CHILDREN_DISABLED" : true, + "HIDE" : true }, "REQUEST" : { "SAMPLE_PARENTS_TITLE" : "Products from Catalog", diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js index afe1675fd2c3d98038ef83ba1cd1dfbd1949ed27..3015e629d9cfdc2a6dc526b30de5a0b1fa9feaed 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormController.js @@ -28,12 +28,9 @@ function SettingsFormController(mainController, settingsSample, mode) { // apply settings to copy of profile, even if invalid, for editing var profileToEdit = jQuery.extend(true, {}, profile); - this._settingsManager.loadSettings((function(settings) { - if (settings) { - this._settingsManager.applySettingsToProfile(settings, profileToEdit); - } + this._settingsManager.loadSettingsAndApplyToProfile((function() { this._settingsFormView.repaint(views, profileToEdit); - }).bind(this)); + }).bind(this), profileToEdit); } this.save = function(settings) { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js index 07cacc746232c105e05db86afaa7898465bcb1be..2449dfef151ffec8bb7f20f32d7df42f6cdefa1c 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormView.js @@ -325,7 +325,7 @@ function SettingsFormView(settingsFormController, settingsFormModel) { this._paintSampleTypesDefinition = function($container, text) { var $fieldset = this._getFieldset($container, text.title, "settings-section-sampletype-definitions"); $fieldset.append(FormUtil.getInfoText(text.info)); - for (var sampleType of this._profileToEdit.getAllSampleTypes(true)) { + for (var sampleType of this._profileToEdit.getAllSampleTypes(false)) { // layout var $div = $("<div>").css("padding-left", "15px"); var displayName = Util.getDisplayNameFromCode(sampleType.code); @@ -389,6 +389,10 @@ function SettingsFormView(settingsFormController, settingsFormModel) { name : "Enable Storage", enabled : sampleTypeSettings["ENABLE_STORAGE"] }); + tableModel.addRow({ + name : "Hide", + enabled : sampleTypeSettings["HIDE"] + }); } else { // default values tableModel.addRow({ name : "Use as Protocol", @@ -407,6 +411,8 @@ function SettingsFormView(settingsFormController, settingsFormModel) { settings["USE_AS_PROTOCOL"] = rowValues["enabled"]; } else if (rowValues["Options"] === "Enable Storage") { settings["ENABLE_STORAGE"] = rowValues["enabled"]; + } else if (rowValues["Options"] === "Hide") { + settings["HIDE"] = rowValues["enabled"]; } } return settings;