diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/ELNDictionary.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/ELNDictionary.js index ad6abe53af52caefd47ef31ce539350dc2018819..46bd617cda7b015864ee682874f59be5a8ef7595 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/ELNDictionary.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/ELNDictionary.js @@ -36,6 +36,10 @@ ELNDictionary.settingsView = { title : "Main Menu", info : "These options give the opportunity to the administrator to show/hide different sections of the user interface from the main menu.", }, + customWidgets : { + title : "Custom Widgets", + info : "Assign custom widgets to properties!", + }, forcedDisableRTF : { title : "Forced Disable RTF", info : "By default all MULTILINE_VARCHAR properties have RTF. Use this section to disable the RTF on specific properties.", diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js index 66e2a02e0ed64a2a27b1e49decd7b445131e111a..54e465edf478e2fb681cb23c6f129a87e94f841d 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/server/ServerFacade.js @@ -67,7 +67,31 @@ function ServerFacade(openbisServer) { } this.openbisServer.setResponseInterceptor(responseInterceptor); - + + // + // Custom Widget Settings + // + this.getCustomWidgetSettings = function(doneCallback) { + require([ "openbis", "as/dto/property/search/PropertyTypeSearchCriteria", "as/dto/property/fetchoptions/PropertyTypeFetchOptions" ], + function(openbis, PropertyTypeSearchCriteria, PropertyTypeFetchOptions) { + var ptsc = new PropertyTypeSearchCriteria(); + var ptfo = new PropertyTypeFetchOptions(); + mainController.openbisV3.searchPropertyTypes(ptsc, ptfo).done(function(searchResult) { + var customWidgetProperties = []; + for(var oIdx = 0; oIdx < searchResult.totalCount; oIdx++) { + var propertyType = searchResult.objects[oIdx]; + if(propertyType.metaData["custom_widget"]) { + customWidgetProperties.push({ + "Property Type" : propertyType.code, + "Widget" : propertyType.metaData["custom_widget"] + }); + } + } + doneCallback(customWidgetProperties); + }); + }); + } + // // Display Settings // 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 526ebc24dddf8ca34ef1ebe810f4af34171afd57..df11a74183125b909d6c7e0f70cb24c79b08f912 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 @@ -21,17 +21,21 @@ function SettingsFormController(mainController, settingsSample, mode) { this._settingsManager = new SettingsManager(this._mainController.serverFacade); this.init = function(views) { - var runningProfile = jQuery.extend(true, {}, profile); - var profileToEdit = null; - - if(settingsSample.properties["$ELN_SETTINGS"]) { - profileToEdit = JSON.parse(settingsSample.properties["$ELN_SETTINGS"]); - } else { - profileToEdit = runningProfile; - } - - this._settingsManager.applySettingsToProfile(profileToEdit, runningProfile); - this._settingsFormView.repaint(views, runningProfile); + var _this = this; + mainController.serverFacade.getCustomWidgetSettings(function(customWidgetSettings) { + var runningProfile = jQuery.extend(true, {}, profile); + var profileToEdit = null; + + if(settingsSample.properties["$ELN_SETTINGS"]) { + profileToEdit = JSON.parse(settingsSample.properties["$ELN_SETTINGS"]); + } else { + profileToEdit = runningProfile; + } + + _this._settingsManager.applySettingsToProfile(profileToEdit, runningProfile); + _this._settingsFormView.repaint(views, runningProfile); + _this._settingsFormModel.customWidgetSettings = customWidgetSettings; + }); } this.save = function(settings) { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js index 26ec6ab3a9d3d2f761098cf7e55af76cde111872..455d82cd9dba598368389aa85ab05c02e96d7bc1 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SettingsForm/SettingsFormModel.js @@ -17,4 +17,5 @@ function SettingsFormModel(settingsSample, mode) { this.settingsSample = settingsSample; this.mode = mode; + this.customWidgetSettings = []; } \ No newline at end of file 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 d620792fc509d8260f4b0a5b81e4bd1c52f1a800..f4681e457ffa736a0785bb891451bb90c64ec12d 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 @@ -22,6 +22,7 @@ function SettingsFormView(settingsFormController, settingsFormModel) { this._mainMenuItemsTableModel = null; this._forcedDisableRTFTableModel = null; + this._customWidgetsTableModel = null; this._forcedMonospaceTableModel = null; this._inventorySpacesTableModel = null; this._sampleTypeDefinitionsMiscellaneousSettingsTableModels = {}; // key: sample type; value: table model @@ -81,6 +82,7 @@ function SettingsFormView(settingsFormController, settingsFormModel) { this._paintMainMenuSection($formColumn, texts.mainMenu); this._paintStoragesSection($formColumn, texts.storages); this._paintTemplateSection($formColumn, texts.templates); + this._paintCustomWidgetsSection($formColumn, texts.customWidgets); this._paintForcedDisableRtfSection($formColumn, texts.forcedDisableRTF); this._paintForcedMonospaceSection($formColumn, texts.forceMonospaceFont); this._paintInventorySpacesSection($formColumn, texts.inventorySpaces); @@ -170,10 +172,11 @@ function SettingsFormView(settingsFormController, settingsFormModel) { var $fieldset = this._getFieldset($container, text.title, "settings-section-templates"); $fieldset.append(FormUtil.getInfoText(text.info)); - var $gridContainer = $("<div>"); + var $dropdownContainer = $("<p>"); var $dropDownMenu = $("<span>", { class : 'dropdown' }); var $caret = $("<a>", { 'href' : '#', 'data-toggle' : 'dropdown', class : 'dropdown-toggle btn btn-default'}).append("Operations ").append($("<b>", { class : 'caret' })); var $list = $("<ul>", { class : 'dropdown-menu', 'role' : 'menu', 'aria-labelledby' :'sampleTableDropdown' }); + $dropdownContainer.append($dropDownMenu); $dropDownMenu.append($caret); $dropDownMenu.append($list); @@ -185,7 +188,9 @@ function SettingsFormView(settingsFormController, settingsFormModel) { }); $list.append($createSampleOption); - $fieldset.append($dropDownMenu); + $fieldset.append($dropdownContainer); + + var $gridContainer = $("<div>"); $fieldset.append($gridContainer); var advancedSampleSearchCriteria = { @@ -217,6 +222,14 @@ function SettingsFormView(settingsFormController, settingsFormModel) { $fieldset.append(this._getTable(this._forcedDisableRTFTableModel)); } + this._paintCustomWidgetsSection = function($container, text) { + var $fieldset = this._getFieldset($container, text.title, "settings-section-custom-widgets"); + $fieldset.append(FormUtil.getInfoText(text.info)); + this._customWidgetsTableModel = this._getCustomWidgetsTableModel(); + $fieldset.append(this._getTable(this._customWidgetsTableModel)); + } + + this._paintForcedMonospaceSection = function($container, text) { var $fieldset = this._getFieldset($container, text.title, "settings-section-monospace"); $fieldset.append(FormUtil.getInfoText(text.info)); @@ -277,6 +290,50 @@ function SettingsFormView(settingsFormController, settingsFormModel) { }); } + this._getCustomWidgetsTableModel = function() { + return this._getDoubleColumnDropdownTableModel({ + columnName : "Property Type", + placeholder : "select property type", + options : profile.allPropertyTypes.map(function(_) { return _.code; }) + }, { + columnName : "Widget", + placeholder : "select widget", + options : ["Default", "Word Processor", "Spreadsheet"] + }, this._settingsFormModel.customWidgetSettings); + // [{ "Property Type" : "$NAME", "Widget" : "Word Processor" }] + } + + this._getDoubleColumnDropdownTableModel = function(params, paramsB, initialValues) { + var tableModel = this._getTableModel(); + tableModel.dynamicRows = true; + // define columns + tableModel.columns = [{ label : params.columnName }, { label : paramsB.columnName }]; + tableModel.rowBuilders[params.columnName] = function(rowData) { + return FormUtil.getDropdown(params.options.map(function(option) { + return { + label : Util.getDisplayNameFromCode(option), + value : option, + selected : option === rowData[params.columnName], + }; + }), params.placeholder); + } + tableModel.rowBuilders[paramsB.columnName] = function(rowData) { + return FormUtil.getDropdown(paramsB.options.map(function(option) { + return { + label : option, + value : option, + selected : option === rowData[paramsB.columnName], + }; + }), paramsB.placeholder); + } + // add data + for (var item of initialValues) { + tableModel.addRow(item); + } + + return tableModel; + } + this._getForcedMonospaceTableModel = function() { return this._getSingleColumnDropdownTableModel({ columnName : "Property Type",