diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js index e9a710a36a77ef80002fd375db21d426f7d2b667..edd65fe9fc418d626bab34804771fe9d6a5f4a6d 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormController.js @@ -106,6 +106,8 @@ function ExperimentFormController(mainController, mode, experiment) { if(_this._experimentFormModel.mode === FormMode.CREATE) { var isInventory = profile.isInventorySpace(experimentSpace); _this._mainController.sideMenu.refreshExperiment(experiment, isInventory); + } else if(_this._experimentFormModel.mode === FormMode.EDIT) { + _this._mainController.sideMenu.updateExperimentName(experiment); } _this._experimentFormModel.isFormDirty = false; _this._mainController.changeView("showExperimentPageFromIdentifier", experimentIdentifier); diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js index 0eddbbb636e6d7f26c7993bf1d89c29eb8aa8aab..df7ae45329dc2d61d27f65e05c58f8e643928ef6 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/ExperimentForm/ExperimentFormView.js @@ -36,12 +36,24 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { // // Title // - var $formTitle = null; - if(this._experimentFormModel.mode === FormMode.VIEW || this._experimentFormModel.mode === FormMode.EDIT) { - $formTitle = $("<h2>").append("Experiment " + this._experimentFormModel.experiment.identifier); - } else { - $formTitle = $("<h2>").append("Create " + this._experimentFormModel.experiment.experimentTypeCode); + var nameLabel = this._experimentFormModel.experiment.properties[profile.propertyReplacingCode]; + if(!nameLabel) { + nameLabel = this._experimentFormModel.experiment.code; + } + var title = ''; + switch(this._experimentFormModel.mode) { + case FormMode.CREATE: + title = "Create " + this._experimentFormModel.experiment.experimentTypeCode; + break; + case FormMode.EDIT: + title = "Update " + nameLabel; + break; + case FormMode.VIEW: + title = "View " + nameLabel; + break; } + + var $formTitle = $("<h2>").append(title); $formColumn.append($formTitle); if(this._experimentFormModel.mode !== FormMode.CREATE) { @@ -104,7 +116,7 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { delete project["@id"]; delete project["@type"]; mainController.serverFacade.listExperiments([project], function(data) { - var autoGeneratedCode = identifierParts[1] + "_EXP_" + (data.result.length + 1); + var autoGeneratedCode = identifierParts[2] + "_EXP_" + (data.result.length + 1); $codeField.val(autoGeneratedCode); _this._experimentFormModel.experiment.code = autoGeneratedCode; @@ -115,9 +127,9 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { }); }); - if(profile.hideCodes) { - $codeFieldRow.hide(); - } +// if(profile.hideCodes) { +// $codeFieldRow.hide(); +// } } // @@ -244,15 +256,7 @@ function ExperimentFormView(experimentFormController, experimentFormModel) { //Create/Update Buttons if(this._experimentFormModel.mode === FormMode.EDIT || this._experimentFormModel.mode === FormMode.CREATE) { - var label = ""; - - if(this._experimentFormModel.mode === FormMode.EDIT) { - label = "Update Experiment " + this._experimentFormModel.experiment.code; - } else if(this._experimentFormModel.mode === FormMode.CREATE) { - label = "Create Experiment"; - } - - var $updateBtn = $("<input>", { "type": "submit", "class" : "btn btn-primary", 'value' : label }); + var $updateBtn = $("<input>", { "type": "submit", "class" : "btn btn-primary", 'value' : title }); $formColumn.append($updateBtn); } diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js index 0d3be8b5a50bb635fd65109ad9cbe6ad0660022e..e8e3b8c26c8085088d0bfa128ef56620116501c7 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormController.js @@ -345,7 +345,7 @@ function SampleFormController(mainController, mode, sample) { var callbackOk = function() { Util.unblockUI(); - if((isCopyWithNewCode || _this._sampleFormModel.mode === FormMode.CREATE) && _this._sampleFormModel.isELNSubExperiment) { + if((isCopyWithNewCode || _this._sampleFormModel.mode === FormMode.CREATE || _this._sampleFormModel.mode === FormMode.EDIT) && _this._sampleFormModel.isELNSubExperiment) { mainController.sideMenu.refreshSubExperiment(_this._sampleFormModel.sample.experimentIdentifierOrNull); } diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js index 963ae4dc116f06d81cdb0500115c70977fb4ce7b..c351f094343dd38d0affd0066aaf2e7c6bfd5440 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/SampleFormView.js @@ -46,17 +46,20 @@ function SampleFormView(sampleFormController, sampleFormModel) { // TITLE // var $formTitle = null; - + var nameLabel = this._sampleFormModel.sample.properties[profile.propertyReplacingCode]; + if(!nameLabel) { + nameLabel = this._sampleFormModel.sample.code; + } var title = null; switch(this._sampleFormModel.mode) { case FormMode.CREATE: title = "Create " + this._sampleFormModel.sample.sampleTypeCode; break; case FormMode.EDIT: - title = "Update " + this._sampleFormModel.sample.code; + title = "Update " + nameLabel; break; case FormMode.VIEW: - title = "View " + this._sampleFormModel.sample.code; + title = "View " + nameLabel; break; } @@ -192,9 +195,9 @@ function SampleFormView(sampleFormController, sampleFormModel) { $formColumn.append($codeField); - if(profile.hideCodes) { - $codeField.hide(); - } +// if(profile.hideCodes) { +// $codeField.hide(); +// } // // Registration and modification info diff --git a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js index 6caeb61850dd50c385d420a238ac29bd2eba3407..d2bb19a9ea14560134b0184945a87167736a7064 100644 --- a/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js +++ b/plasmid/source/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetController.js @@ -95,6 +95,37 @@ function SideMenuWidgetController(mainController) { this._sideMenuWidgetView.repaint(); }; + this._getUniqueId = function(uniqueId) { + var itemsToCheck = [this._sideMenuWidgetModel.menuStructure]; + var currentItem = null; + while(currentItem = itemsToCheck.shift()) { + if(currentItem.newMenuIfSelected) { + for (var i = 0; i < currentItem.newMenuIfSelected.children.length; i++) { + var currentItemChild = currentItem.newMenuIfSelected.children[i]; + if(currentItemChild.uniqueId === uniqueId) { + return currentItemChild; + } + itemsToCheck.push(currentItemChild); + } + } + } + }; + + this.updateExperimentName = function(experiment) { + var node = this._getUniqueId(experiment.identifier); + + var displayName = null; + if (profile.hideCodes) { + displayName = experiment.properties[profile.propertyReplacingCode]; + } + if (!displayName) { + displayName = experiment.code; + } + + node.displayName = displayName; + this._sideMenuWidgetView.repaint(); + } + this.refreshExperiment = function(experiment, isInventory) { var projectIdentifierEnd = experiment.identifier.lastIndexOf("/"); var projectIdentifier = experiment.identifier.substring(0, projectIdentifierEnd);