From ec09c766facff686387246898b263dbfbab28c03 Mon Sep 17 00:00:00 2001 From: juanf <juanf> Date: Thu, 11 Aug 2016 14:18:59 +0000 Subject: [PATCH] SSDM-2732 : Storing order status on update, if the order state changes to ordered SVN: 36898 --- .../core-plugins/eln-lims/1/as/elnTypes.py | 7 +++--- .../eln-lims/html/js/config/Profile.js | 6 +++++ .../html/js/config/StandardProfile.js | 23 ++++++++++++++++++- .../views/SampleForm/SampleFormController.js | 4 ++++ .../js/views/SampleForm/SampleFormView.js | 2 +- .../SampleForm/widgets/LinksController.js | 8 ++++++- 6 files changed, 44 insertions(+), 6 deletions(-) diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py index 23b9f3388b5..f79717cb8d8 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/elnTypes.py @@ -936,7 +936,8 @@ ORDER = ["ORDER", "", [ ["NAME", "General", "Name", DataType.VARCHAR, None, "Name", None, None], ["ORDER_MANAGER", "General", "Order Manager", DataType.VARCHAR, None, "Order Manager", None, None], ["ORDER_MANAGER_CONTACT_DETAILS", "General", "Order Manager Contact Details", DataType.VARCHAR, None, "Order Manager Contact Details", None, None], - ["ORDER_STATUS", "General", "Order Status", DataType.CONTROLLEDVOCABULARY, "ORDER_STATUS", "Order Status", None, None], - ["ADDITIONAL_INFORMATION", "General", "Additional Information", DataType.VARCHAR, None, "Additional Information", None, None], - ["ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", None, None] + ["ORDER_STATUS", "General", "Order Status", DataType.CONTROLLEDVOCABULARY, "ORDER_STATUS", "Order Status", None, None, True], + ["ADDITIONAL_INFORMATION", "General", "Additional Information", DataType.VARCHAR, None, "Additional Information", None, None], + ["ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", None, None], + ["ORDER_STATE", "Comments", "Order State", DataType.VARCHAR, None, "Order State", None, None] ]]; \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js index f9fff2dfc58..76fcd0da249 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/Profile.js @@ -382,6 +382,12 @@ $.extend(DefaultProfile.prototype, { return html; } + /* + * Modifies sample before submit + */ + this.sampleFormOnSubmit = function(sample) { + } + /* * Returns a Jquery component that is appended at the end of the form before the data set viewer */ 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 a6c8709f2f4..ac8fe174a41 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 @@ -404,6 +404,16 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, { } + this.sampleFormOnSubmit = function(sample) { + if(sample.sampleTypeCode === "ORDER") { + var orderStatus = sample.properties["ORDER_STATUS"]; + if(orderStatus === "ORDERED") { + delete sample.properties["ORDER_STATE"]; + sample.properties["ORDER_STATE"] = window.btoa(JSON.stringify(sample)); + } + } + } + this.sampleFormContentExtra = function(sampleTypeCode, sample, containerId) { if(sampleTypeCode === "EXPERIMENTAL_STEP") { var isEnabled = mainController.currentView._sampleFormModel.mode !== FormMode.VIEW; @@ -411,11 +421,17 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, { freeFormTableController.init($("#" + containerId)); } else if(sampleTypeCode === "ORDER") { var isExisting = mainController.currentView._sampleFormModel.mode === FormMode.VIEW; + var isFromState = false; if(isExisting) { // // Data Structures to Help the reports functionality // var order = mainController.currentView._sampleFormModel.sample; + if(order.properties["ORDER_STATE"]) { + isFromState = true; + order = JSON.parse(window.atob(order.properties["ORDER_STATE"])); + } + var requests = order.parents; var providerByPermId = {}; var productsByProviderPermId = {}; @@ -617,7 +633,12 @@ $.extend(StandardProfile.prototype, DefaultProfile.prototype, { }; var orderSummaryContainer = $("<div>"); - var orderSummary = new DataGridController("Order Summary", columns, getDataRows, null, false, "ORDER_SUMMARY"); + var repTitle = "Order Summary"; + if(isFromState) { + repTitle += " (as saved when ordered)" + } + + var orderSummary = new DataGridController(repTitle, columns, getDataRows, null, false, "ORDER_SUMMARY"); orderSummary.init(orderSummaryContainer); var totalsByCurrencyContainer = $("<div>").append($("<br>")).append($("<legend>").append("Total:")); 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 65e8966e98c..24da4d8311f 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 @@ -153,6 +153,10 @@ function SampleFormController(mainController, mode, sample) { return; } + //On Submit + sample.parents = this._sampleFormModel.sampleLinksParents.getSamples(); + profile.sampleFormOnSubmit(sample); + // //Identification Info // 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 cf0c23c61d7..2502054fba7 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 @@ -478,7 +478,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { continue; } - if(propertyType.code === "ANNOTATIONS_STATE" || propertyType.code === "FREEFORM_TABLE_STATE") { + if(propertyType.code === "ANNOTATIONS_STATE" || propertyType.code === "FREEFORM_TABLE_STATE" || propertyType.code === "ORDER_STATE" ) { continue; } else if(propertyType.code === "XMLCOMMENTS") { var $commentsContainer = $("<div>"); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksController.js index 88aec145d59..0733d6de01a 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksController.js @@ -87,7 +87,13 @@ function LinksController(title, sampleTypeHints, isDisabled, samplesToEdit, show } this.addSample = function(sample) { - linksView.updateSample(sample, true); + Util.blockUI(); + mainController.serverFacade.searchWithIdentifiers([sample.identifier], function(results) { + if(results.length > 0) { + linksView.updateSample(results[0], true); + Util.unblockUI(); + } + }); } this.getSamples = function() { -- GitLab