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 d009f95fc21896c295b38bce7132133a624fe3d1..9d13173e5f05ec5718f5fb4e38816f96f511f1f8 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 @@ -260,6 +260,13 @@ HOST = [ FIRST_TIME_VERSIONED, "HOST", "Host organism", ["DONKEY", "donkey", None] ]]; +STORAGE_VALIDATION_LEVEL = [ FIRST_TIME_VERSIONED, "STORAGE_VALIDATION_LEVEL", "Validation Level", + [ + ["RACK", "Rack Validation", None], + ["BOX", "Box Validation", None], + ["BOX_POSITION", "Box Position Validation", None] + ]]; + DETECTION = [ FIRST_TIME_VERSIONED, "DETECTION", "Protein detection system", [ ["HRP", "horseradish peroxydase", "The antibody is conjugated with the horseradish peroxydase"], @@ -839,20 +846,6 @@ FLY = [FIRST_TIME_VERSIONED, True, "FLY", "", [ [FIRST_TIME_VERSIONED, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_FLY", None] ]]; -## -## Storage Properties used by mostly by materials -## - -STORAGE_PROPERTIES = [ - [FIRST_TIME_VERSIONED, "STORAGE_NAMES", "Physical Storage", "Storage Name", DataType.CONTROLLEDVOCABULARY, "STORAGE_NAMES", "Storage Name", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_ROW", "Physical Storage", "Storage Row", DataType.INTEGER, None, "Storage Row", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_COLUMN", "Physical Storage", "Storage Column", DataType.INTEGER, None, "Storage Column", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_BOX_NAME", "Physical Storage", "Storage Box Name", DataType.VARCHAR, None, "Storage Box Name", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_BOX_SIZE", "Physical Storage", "Storage Box Size", DataType.CONTROLLEDVOCABULARY, "STORAGE_BOX_SIZE", "Storage Box Size", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_USER", "Physical Storage", "Storage User Id", DataType.VARCHAR, None, "Storage User Id", None, None], - [FIRST_TIME_VERSIONED, "STORAGE_POSITION", "Physical Storage", "Storage Position", DataType.VARCHAR, None, "Storage Position", None, None] -]; - ## ## Sample Types - Non Materials ## @@ -924,6 +917,33 @@ WESTERN_BLOTTING_PROTOCOL = [FIRST_TIME_VERSIONED, True, "WESTERN_BLOTTING_PROTO GENERAL_ELN_SETTINGS = [MANDATORY_ITEM_VERSION, False, "GENERAL_ELN_SETTINGS", "Used to store the settings of the ELN application", [ [MANDATORY_ITEM_VERSION, "ELN_SETTINGS", "Settings", "ELN Settings", DataType.VARCHAR, None, "ELN Settings", None, None, False, False] ]]; + +## +## Types - Storage +## +STORAGE_RACK = [MANDATORY_ITEM_VERSION, False, "STORAGE_RACK", "", [ + [FIRST_TIME_VERSIONED, "NAME", "General", "Name", DataType.VARCHAR, None, "Name", None, None], + [FIRST_TIME_VERSIONED, "ROW_NUM", "General", "Row", DataType.INTEGER, None, "Row", None, None], + [FIRST_TIME_VERSIONED, "COLUMN_NUM", "General", "Column", DataType.INTEGER, None, "Column", None, None], + [FIRST_TIME_VERSIONED, "BOX_NUM", "General", "Box Number", DataType.INTEGER, None, "Box Number", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_SPACE_WARNING", "General", "Storage Space Warning", DataType.INTEGER, None, "Storage Space Warning", None, None], + [FIRST_TIME_VERSIONED, "BOX_SPACE_WARNING", "General", "Box Space Warning", DataType.INTEGER, None, "Box Space Warning", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_VALIDATION_LEVEL", "General", "Validation level", DataType.CONTROLLEDVOCABULARY, "STORAGE_VALIDATION_LEVEL", "Validation level", None, None], + [FIRST_TIME_VERSIONED, "XMLCOMMENTS", "Comments", "Comments List", DataType.XML, None, "Several comments can be added by different users", "COMMENTS_SAMPLE", None], + [FIRST_TIME_VERSIONED, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_STORAGE_POSITION", None] +]]; + +STORAGE_POSITION = [MANDATORY_ITEM_VERSION, False, "STORAGE_POSITION", "", [ + [FIRST_TIME_VERSIONED, "STORAGE_NAMES", "Physical Storage", "Storage Name", DataType.CONTROLLEDVOCABULARY, "STORAGE_NAMES", "Storage Name", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_ROW", "Physical Storage", "Storage Row", DataType.INTEGER, None, "Storage Row", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_COLUMN", "Physical Storage", "Storage Column", DataType.INTEGER, None, "Storage Column", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_BOX_NAME", "Physical Storage", "Storage Box Name", DataType.VARCHAR, None, "Storage Box Name", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_BOX_SIZE", "Physical Storage", "Storage Box Size", DataType.CONTROLLEDVOCABULARY, "STORAGE_BOX_SIZE", "Storage Box Size", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_USER", "Physical Storage", "Storage User Id", DataType.VARCHAR, None, "Storage User Id", None, None], + [FIRST_TIME_VERSIONED, "STORAGE_POSITION", "Physical Storage", "Storage Position", DataType.VARCHAR, None, "Storage Position", None, None], + [FIRST_TIME_VERSIONED, "XMLCOMMENTS", "Comments", "Comments List", DataType.XML, None, "Several comments can be added by different users", "COMMENTS_SAMPLE", None], + [FIRST_TIME_VERSIONED, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_STORAGE_POSITION", None] +]]; ## ## Types - Orders diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initialize-master-data.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initialize-master-data.py index 8b3b2f4b238de19b7f3e46576d7535c277757f42..1013018ce8938d5de0ca612298321df73952619c 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initialize-master-data.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initialize-master-data.py @@ -58,8 +58,6 @@ elnTypes.createVocabularyWithTerms(tr, elnTypes.CELL_MEDIUM); elnTypes.createVocabularyWithTerms(tr, elnTypes.CELL_TYPE); elnTypes.createVocabularyWithTerms(tr, elnTypes.ORGANISM); elnTypes.createVocabularyWithTerms(tr, elnTypes.PLASMID_RELATIONSHIP); -elnTypes.createVocabularyWithTerms(tr, elnTypes.STORAGE_NAMES); -elnTypes.createVocabularyWithTerms(tr, elnTypes.STORAGE_BOX_SIZE); elnTypes.createVocabularyWithTerms(tr, elnTypes.COLOR_ENCODED_ANNOTATIONS); ## @@ -105,21 +103,6 @@ elnTypes.createSampleTypeWithProperties(tr, elnTypes.YEAST); elnTypes.createSampleTypeWithProperties(tr, elnTypes.CELL_LINE); elnTypes.createSampleTypeWithProperties(tr, elnTypes.FLY); -elnTypes.addPropertiesToSamples(tr, [ - "ANTIBODY", - "BACTERIA", - "CHEMICAL", - "ENZYME", - "CELL_LINE", - "FLY", - "MEDIA", - "OLIGO", - "PLASMID", - "YEAST", - "SOLUTION_BUFFER", - "RNA" - ], elnTypes.STORAGE_PROPERTIES); - ## ## Sample Types - Non Materials ## diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py index 97873d43788b91b058e07a97ad7c6102e108defb..e5c64394a91552766f3df1d96158ef5cad08f768 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/initializemasterdataminimum.py @@ -30,6 +30,9 @@ def initBasicMasterData(tr): elnTypes.createVocabularyWithTerms(tr, elnTypes.OWNER); elnTypes.createVocabularyWithTerms(tr, elnTypes.EXPERIMENTAL_READOUT); elnTypes.createVocabularyWithTerms(tr, elnTypes.MACHINE); + elnTypes.createVocabularyWithTerms(tr, elnTypes.STORAGE_VALIDATION_LEVEL); + elnTypes.createVocabularyWithTerms(tr, elnTypes.STORAGE_NAMES); + elnTypes.createVocabularyWithTerms(tr, elnTypes.STORAGE_BOX_SIZE); ## ## Property Types for annotations @@ -59,7 +62,8 @@ def initBasicMasterData(tr): ## elnTypes.createSampleTypeWithProperties(tr, elnTypes.GENERAL_ELN_SETTINGS); elnTypes.createSampleTypeWithProperties(tr, elnTypes.EXPERIMENTAL_STEP); - + elnTypes.createSampleTypeWithProperties(tr, elnTypes.STORAGE_RACK); + elnTypes.createSampleTypeWithProperties(tr, elnTypes.STORAGE_POSITION); ## ## Ordering System ## 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 2371b4d8d89931a435bfa1dc9787e073874c41a7..ab01f3fa5897886df94213c8dea528dc2cadf461 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 @@ -128,12 +128,17 @@ $.extend(DefaultProfile.prototype, { } this.searchDomains = [ { "@id" : -1, "@type" : "GobalSearch", label : "Global", name : "global"}]; - this.inventorySpaces = ["MATERIALS", "METHODS"]; //"STOCK_CATALOG" + this.inventorySpaces = ["MATERIALS", "METHODS", "STORAGE"]; //"STOCK_CATALOG" this.inventorySpacesReadOnly = ["ELN_SETTINGS"]; //"STOCK_ORDERS" this.sampleTypeProtocols = ["GENERAL_PROTOCOL", "PCR_PROTOCOL", "WESTERN_BLOTTING_PROTOCOL"]; + this.sampleTypeStorageEnabled = ["ANTIBODY", "BACTERIA", "CHEMICAL", "ENZYME", "CELL_LINE", "FLY", "MEDIA", "OLIGO", "PLASMID", "YEAST", "SOLUTION_BUFFER", "RNA"]; this.searchSamplesUsingV3OnDropbox = false; this.searchSamplesUsingV3OnDropboxRunCustom = false; + this.isSampleTypeWithStorage = function(sampleTypeCode) { + return $.inArray(sampleTypeCode, this.sampleTypeStorageEnabled) !== -1; + } + this.isELNIdentifier = function(identifier) { var space = identifier.split("/")[1]; return !this.isInventorySpace(space); @@ -152,10 +157,10 @@ $.extend(DefaultProfile.prototype, { this.copyPastePlainText = false; this.hideCodes = true; this.hideTypes = { - "sampleTypeCodes" : ["GENERAL_ELN_SETTINGS"], + "sampleTypeCodes" : ["GENERAL_ELN_SETTINGS", "STORAGE_POSITION", "STORAGE_RACK"], "experimentTypeCodes" : [] } - this.hideSpaces = ["ELN_SETTINGS"]; + this.hideSpaces = ["ELN_SETTINGS", "STORAGE"]; this.propertyReplacingCode = "NAME"; @@ -228,52 +233,24 @@ $.extend(DefaultProfile.prototype, { return null; } - var storagePropertyGroups = this.storagesConfiguration["STORAGE_PROPERTIES"]; - if(!storagePropertyGroups) { - return null; - } - - for(var i = 0; i < storagePropertyGroups.length; i++) { - if(storagePropertyGroupDisplayName === storagePropertyGroups[i]["STORAGE_GROUP_DISPLAY_NAME"]) { - propertyGroup = {}; - propertyGroup.groupDisplayName = storagePropertyGroups[i]["STORAGE_GROUP_DISPLAY_NAME"]; - propertyGroup.nameProperty = storagePropertyGroups[i]["NAME_PROPERTY"]; - propertyGroup.rowProperty = storagePropertyGroups[i]["ROW_PROPERTY"]; - propertyGroup.columnProperty = storagePropertyGroups[i]["COLUMN_PROPERTY"]; - propertyGroup.boxProperty = storagePropertyGroups[i]["BOX_PROPERTY"]; - propertyGroup.boxSizeProperty = storagePropertyGroups[i]["BOX_SIZE_PROPERTY"]; - propertyGroup.userProperty = storagePropertyGroups[i]["USER_PROPERTY"]; - propertyGroup.positionProperty = storagePropertyGroups[i]["POSITION_PROPERTY"]; - return propertyGroup; - } - } - - return null; + propertyGroup = {}; + propertyGroup.groupDisplayName = "Physical Storage"; + propertyGroup.nameProperty = "STORAGE_NAMES"; + propertyGroup.rowProperty = "STORAGE_ROW"; + propertyGroup.columnProperty = "STORAGE_COLUMN"; + propertyGroup.boxProperty = "STORAGE_BOX_NAME"; + propertyGroup.boxSizeProperty = "STORAGE_BOX_SIZE"; + propertyGroup.userProperty = "STORAGE_USER"; + propertyGroup.positionProperty = "STORAGE_POSITION"; + return propertyGroup; } this.getStoragePropertyGroups = function() { if(!this.storagesConfiguration["isEnabled"]) { return null; } - - var storagePropertyGroups = this.storagesConfiguration["STORAGE_PROPERTIES"]; - if(!storagePropertyGroups) { - return null; - } - - var propertyGroups = []; - for(var i = 0; i < storagePropertyGroups.length; i++) { - propertyGroups[i] = {}; - propertyGroups[i].groupDisplayName = storagePropertyGroups[i]["STORAGE_GROUP_DISPLAY_NAME"]; - propertyGroups[i].nameProperty = storagePropertyGroups[i]["NAME_PROPERTY"]; - propertyGroups[i].rowProperty = storagePropertyGroups[i]["ROW_PROPERTY"]; - propertyGroups[i].columnProperty = storagePropertyGroups[i]["COLUMN_PROPERTY"]; - propertyGroups[i].boxProperty = storagePropertyGroups[i]["BOX_PROPERTY"]; - propertyGroups[i].boxSizeProperty = storagePropertyGroups[i]["BOX_SIZE_PROPERTY"]; - propertyGroups[i].userProperty = storagePropertyGroups[i]["USER_PROPERTY"]; - propertyGroups[i].positionProperty = storagePropertyGroups[i]["POSITION_PROPERTY"]; - } - return propertyGroups; + + return [this.getStoragePropertyGroup()]; } this.getStorageConfiguation = function(storageCode) { 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 8beaa46595e16bf310a09649072c629ed138d1ed..6d13a7cefdaa5e4174a9b40fd66c4236c20a237c 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 @@ -354,6 +354,7 @@ function ServerFacade(openbisServer) { prefix+"*", false, function(results) { + var nextCode; if(results.length == 0){ nextcode = prefix + "1"; } else{ @@ -370,7 +371,7 @@ function ServerFacade(openbisServer) { return a - b; }); var nextid = codes[codes.length-1] + 1; - var nextcode = prefix + nextid; + nextcode = prefix + nextid; } action(nextcode); }); 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 0eaf55365e726a2900d214b0e873f3593f7a4a4b..e10bbbc429de88af763e2a5d1ce430a8d4e665c9 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 @@ -225,20 +225,46 @@ function SampleFormController(mainController, mode, sample) { var samplesToCreate = []; _this._sampleFormModel.sampleLinksChildren.getSamples().forEach(function(child) { if(child.newSample) { + child.experimentIdentifier = experimentIdentifier; child.properties = {}; + child.children = []; if(profile.storagesConfiguration["isEnabled"]) { - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["NAME_PROPERTY"]] = $("#childrenStorageSelector").val(); - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["ROW_PROPERTY"]] = 1; - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["COLUMN_PROPERTY"]] = 1; - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["BOX_SIZE_PROPERTY"]] = "1X1"; - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["BOX_PROPERTY"]] = experimentIdentifier.replace(/\//g,'\/') + "_" + sample.code + "_EXP_RESULTS"; - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["USER_PROPERTY"]] = mainController.serverFacade.openbisServer.getSession().split("-")[0]; - child.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["POSITION_PROPERTY"]] = "A1"; + var uuid = Util.guid(); + var storagePosition = { + newSample : true, + code : uuid, + identifier : "/STORAGE/" + uuid, + sampleTypeCode : "STORAGE_POSITION", + properties : {} + }; + + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["NAME_PROPERTY"]] = $("#childrenStorageSelector").val(); + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["ROW_PROPERTY"]] = 1; + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["COLUMN_PROPERTY"]] = 1; + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["BOX_SIZE_PROPERTY"]] = "1X1"; + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["BOX_PROPERTY"]] = experimentIdentifier.replace(/\//g,'\/') + "_" + sample.code + "_EXP_RESULTS"; + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["USER_PROPERTY"]] = mainController.serverFacade.openbisServer.getSession().split("-")[0]; + storagePosition.properties[profile.storagesConfiguration["STORAGE_PROPERTIES"][0]["POSITION_PROPERTY"]] = "A1"; + + child.children.push(storagePosition); } samplesToCreate.push(child); } }); + if(_this._sampleFormModel.sample.children) { + _this._sampleFormModel.sample.children.forEach(function(child) { + if(child.newSample) { + samplesToCreate.push(child); + } else if(child.deleteSample) { + if(!samplesToDelete) { + samplesToDelete = []; + } + samplesToDelete.push(child.id); + } + }); + } + //Method var method = ""; if(_this._sampleFormModel.mode === FormMode.CREATE) { @@ -408,13 +434,12 @@ function SampleFormController(mainController, mode, sample) { } if(samplesToDelete) { - mainController.serverFacade.deleteSamples(samplesToDelete, - "Order " + _this._sampleFormModel.sample.code + " Created", + mainController.serverFacade.deleteSamples(samplesToDelete, "Deleted to trashcan from eln sample form " + _this._sampleFormModel.sample.identifier, function() { Util.showSuccess(message, callbackOk); _this._sampleFormModel.isFormDirty = false; }, - true); + false); } else { Util.showSuccess(message, callbackOk); _this._sampleFormModel.isFormDirty = false; 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 f8a9e29d0fda9cf9a23c306cb05101fcc7cd42cb..c865ee18eb0e63dc737959bb1a5b6515fc3885a1 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 @@ -260,11 +260,10 @@ function SampleFormView(sampleFormController, sampleFormModel) { // // Form Defined Properties from General Section // - var isStorageAvailable = false; for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { var propertyTypeGroup = sampleType.propertyTypeGroups[i]; if(propertyTypeGroup.name === "General") { - isStorageAvailable = isStorageAvailable || this._paintPropertiesForSection($formColumn, propertyTypeGroup, i); + this._paintPropertiesForSection($formColumn, propertyTypeGroup, i); } } @@ -327,11 +326,21 @@ function SampleFormView(sampleFormController, sampleFormModel) { if(sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_TITLE"]) { childrenTitle = sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_TITLE"]; } + + var currentChildrenLinksNoStorage = []; + if(currentChildrenLinks != null) { + for(var cIdx = 0; cIdx < currentChildrenLinks.length; cIdx++) { + if(currentChildrenLinks[cIdx].sampleTypeCode !== "STORAGE_POSITION") { + currentChildrenLinksNoStorage.push(currentChildrenLinks[cIdx]); + } + } + } + var childrenAnyTypeDisabled = sampleTypeDefinitionsExtension && sampleTypeDefinitionsExtension["SAMPLE_CHILDREN_ANY_TYPE_DISABLED"]; this._sampleFormModel.sampleLinksChildren = new LinksController(childrenTitle, requiredChildren, isDisabled, - currentChildrenLinks, + currentChildrenLinksNoStorage, this._sampleFormModel.mode === FormMode.CREATE, childrenAnyTypeDisabled, sampleTypeCode); @@ -357,11 +366,10 @@ function SampleFormView(sampleFormController, sampleFormModel) { // // Form Defined Properties from non General Section // - var isStorageAvailable = false; for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { var propertyTypeGroup = sampleType.propertyTypeGroups[i]; if(propertyTypeGroup.name !== "General") { - isStorageAvailable = isStorageAvailable || this._paintPropertiesForSection($formColumn, propertyTypeGroup, i); + this._paintPropertiesForSection($formColumn, propertyTypeGroup, i); } } @@ -380,6 +388,7 @@ function SampleFormView(sampleFormController, sampleFormModel) { // // Storage // + var isStorageAvailable = profile.isSampleTypeWithStorage(this._sampleFormModel.sample.sampleTypeCode); if(isStorageAvailable) { var $fieldsetOwner = $("<div>"); var $legend = $("<legend>").append("Storage"); @@ -392,7 +401,6 @@ function SampleFormView(sampleFormController, sampleFormModel) { var storageListController = new StorageListController(this._sampleFormModel.sample, this._sampleFormModel.mode === FormMode.VIEW); storageListController.init(storageListContainer); - } // @@ -501,12 +509,6 @@ function SampleFormView(sampleFormController, sampleFormModel) { $legend.remove(); } - var storagePropertyGroup = profile.getPropertyGroupFromStorage(propertyTypeGroup.name); - if(storagePropertyGroup) { - $legend.remove(); - return true; - } - var propertyGroupPropertiesOnForm = 0; for(var j = 0; j < propertyTypeGroup.propertyTypes.length; j++) { var propertyType = propertyTypeGroup.propertyTypes[j]; diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js index 76377a16d3cfdc0d71c715dc1aab36b55d5c7be2..96e8f2299402838b2bd437a6d985be6beed6bcf9 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListController.js @@ -22,21 +22,21 @@ function StorageListController(sample, isDisabled) { this._storageListView.repaint($container); } - this._saveState = function(storagePropGroup){ + this._saveState = function(sampleChild, storagePropGroup){ delete this._storageListModel.savedState; var savedState = {}; for(key in storagePropGroup) { var propertyKey = storagePropGroup[key]; if(key != "groupDisplayName") { - savedState[propertyKey] = this._storageListModel.sample.properties[propertyKey]; + savedState[propertyKey] = sampleChild.properties[propertyKey]; } } this._storageListModel.savedState = savedState; } - this._restoreState = function() { + this._restoreState = function(sampleChild) { for(key in this._storageListModel.savedState) { - this._storageListModel.sample.properties[key] = this._storageListModel.savedState[key]; + sampleChild.properties[key] = this._storageListModel.savedState[key]; } } } \ 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/SampleForm/widgets/StorageListView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js index f74d0926425645c99b1e84c6f1a2671e8ea74738..c1d96611aa11e16dab460e9b5e50c778cdaa8710 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/StorageListView.js @@ -58,53 +58,61 @@ function StorageListView(storageListController, storageListModel) { sortable : true }]; + if(!this._storageListModel.isDisabled) { + columns.push(this.createOperationsColumn()); + } + var getDataList = function(callback) { var dataList = []; - var sample = _this._storageListModel.sample; - var sampleTypeCode = sample.sampleTypeCode; - var sampleType = mainController.profile.getSampleTypeForSampleTypeCode(sampleTypeCode); + var sampleChildren = _this._storageListModel.sample.children; + if(!sampleChildren) { + sampleChildren = []; + _this._storageListModel.sample.children = sampleChildren; + } + var sampleType = mainController.profile.getSampleTypeForSampleTypeCode("STORAGE_POSITION"); + var storagePropertyGroup = profile.getStoragePropertyGroup(); - for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { - var propertyTypeGroup = sampleType.propertyTypeGroups[i]; - var storagePropertyGroup = profile.getStoragePropertyGroup(propertyTypeGroup.name); + for(var i = 0; i < sampleChildren.length; i++) { + var sample = sampleChildren[i]; + if(sample.sampleTypeCode !== "STORAGE_POSITION" || sample.deleteSample) { + continue; + } + var userProperty = sample.properties[storagePropertyGroup.userProperty]; - if(storagePropertyGroup) { - var userProperty = sample.properties[storagePropertyGroup.userProperty]; - - var namePropertyTypeCode = storagePropertyGroup.nameProperty; - var namePropertyCode = sample.properties[namePropertyTypeCode]; - var nameProperty = null; - if(namePropertyCode) { - var namePropertyTerm = profile.getVocabularyTermByCodes("STORAGE_NAMES", namePropertyCode); - if(namePropertyTerm && namePropertyTerm.label) { - nameProperty = namePropertyTerm.label; - } else { - nameProperty = namePropertyCode; - } - } - - if( (userProperty && userProperty !== "") || - (nameProperty && nameProperty !== "")) { - dataList.push({ - groupDisplayName : storagePropertyGroup.groupDisplayName, - nameProperty : nameProperty, - rowProperty : sample.properties[storagePropertyGroup.rowProperty], - columnProperty : sample.properties[storagePropertyGroup.columnProperty], - boxProperty : sample.properties[storagePropertyGroup.boxProperty], - boxSizeProperty : sample.properties[storagePropertyGroup.boxSizeProperty], - positionProperty : sample.properties[storagePropertyGroup.positionProperty], - userProperty : userProperty - }); + var namePropertyTypeCode = storagePropertyGroup.nameProperty; + var namePropertyCode = sample.properties[namePropertyTypeCode]; + var nameProperty = null; + if(namePropertyCode) { + var namePropertyTerm = profile.getVocabularyTermByCodes("STORAGE_NAMES", namePropertyCode); + if(namePropertyTerm && namePropertyTerm.label) { + nameProperty = namePropertyTerm.label; + } else { + nameProperty = namePropertyCode; } } + + if( (userProperty && userProperty !== "") || + (nameProperty && nameProperty !== "")) { + dataList.push({ + '$object' : sample, + groupDisplayName : storagePropertyGroup.groupDisplayName, + nameProperty : nameProperty, + rowProperty : sample.properties[storagePropertyGroup.rowProperty], + columnProperty : sample.properties[storagePropertyGroup.columnProperty], + boxProperty : sample.properties[storagePropertyGroup.boxProperty], + boxSizeProperty : sample.properties[storagePropertyGroup.boxSizeProperty], + positionProperty : sample.properties[storagePropertyGroup.positionProperty], + userProperty : userProperty + }); + } } callback(dataList); } var rowClick = null; if(!this._storageListModel.isDisabled) { - rowClick = function(e) { - _this.showStorageWidget(e) + rowClick = function(data) { + _this.showStorageWidget(data.data['$object']) } } @@ -116,77 +124,27 @@ function StorageListView(storageListController, storageListModel) { var $storageAddButton = $("<a>", { class : 'btn btn-default', style : "float: right; background-color:#f9f9f9;" }).append($("<i>", { class : "glyphicon glyphicon-plus" } )); - $storageAddButton.on("click", function(event) { - var sample = _this._storageListModel.sample; - var sampleTypeCode = sample.sampleTypeCode; - var sampleType = mainController.profile.getSampleTypeForSampleTypeCode(sampleTypeCode); - - for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { - var propertyTypeGroup = sampleType.propertyTypeGroups[i]; - var storagePropertyGroup = profile.getStoragePropertyGroup(propertyTypeGroup.name); - - if(storagePropertyGroup) { - var userProperty = sample.properties[storagePropertyGroup.userProperty]; - if(!userProperty || userProperty === "") { //Not Used - sample.properties[storagePropertyGroup.userProperty] = mainController.serverFacade.openbisServer.getSession().split("-")[0]; //Mark to show - } - } - } - - if(_this.getUsedStorages() === _this.getMaxStorages()) { - $storageAddButton.attr("disabled", ""); - } - - _this._dataGrid.refresh(); + var uuid = Util.guid(); + var newChildSample = { + newSample : true, + code : uuid, + identifier : "/STORAGE/" + uuid, + sampleTypeCode : "STORAGE_POSITION", + properties : {} + }; + _this._storageListModel.sample.children.push(newChildSample); + rowClick({ data : { '$object' : newChildSample }}); }); - if(this._storageListModel.isDisabled || this.getUsedStorages() === this.getMaxStorages()) { + if(this._storageListModel.isDisabled) { $storageAddButton.attr("disabled", ""); } $container.append($storageAddButton); - $container.append("NOTE: Storages limited to " + this.getMaxStorages() + " for this type."); } - this.getUsedStorages = function() { - var count = 0; - var sample = this._storageListModel.sample; - var sampleTypeCode = sample.sampleTypeCode; - var sampleType = mainController.profile.getSampleTypeForSampleTypeCode(sampleTypeCode); - - for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { - var propertyTypeGroup = sampleType.propertyTypeGroups[i]; - var storagePropertyGroup = profile.getStoragePropertyGroup(propertyTypeGroup.name); - - if(storagePropertyGroup) { - var userProperty = sample.properties[storagePropertyGroup.userProperty]; - if(userProperty) { - count++; - } - } - } - return count; - } - - this.getMaxStorages = function() { - var count = 0; - var sample = this._storageListModel.sample; - var sampleTypeCode = sample.sampleTypeCode; - var sampleType = mainController.profile.getSampleTypeForSampleTypeCode(sampleTypeCode); - - for(var i = 0; i < sampleType.propertyTypeGroups.length; i++) { - var propertyTypeGroup = sampleType.propertyTypeGroups[i]; - var storagePropertyGroup = profile.getStoragePropertyGroup(propertyTypeGroup.name); - - if(storagePropertyGroup) { - count++; - } - } - return count; - } - - this.showStorageWidget = function(e) { + this.showStorageWidget = function(sampleChild) { var _this = this; var css = { 'text-align' : 'left', @@ -203,9 +161,8 @@ function StorageListView(storageListController, storageListModel) { Util.blockUI(container, css); - var storageController = new StorageController({ - title : e.data.groupDisplayName, + title : "Physical Storage", storagePropertyGroupSelector : "off", storageSelector : "on", userSelector : "off", @@ -220,10 +177,11 @@ function StorageListView(storageListController, storageListModel) { boxPositionMultiple: "on", positionDragAndDropEnabled: "off" }); - var storagePropGroup = profile.getStoragePropertyGroup(e.data.groupDisplayName); + + var storagePropGroup = profile.getStoragePropertyGroup(); storageController.getModel().storagePropertyGroup = storagePropGroup; - this._storageListController._saveState(storagePropGroup); - storageController.bindSample(this._storageListModel.sample, this._storageListModel.isDisabled); + this._storageListController._saveState(sampleChild, storagePropGroup); + storageController.bindSample(sampleChild, this._storageListModel.isDisabled); var storageContainer = $("#storage-pop-up-container"); storageController.getView().repaint(storageContainer); @@ -239,9 +197,52 @@ function StorageListView(storageListController, storageListModel) { }); $("#storage-cancel").on("click", function(event) { - _this._storageListController._restoreState(); + _this._storageListController._restoreState(sampleChild); Util.unblockUI(); _this._dataGrid.refresh(); }); } + + this.createOperationsColumn = function() { + var _this = this; + return { + label : "", + property : "_Operations_", + isExportable: false, + showByDefault: true, + sortable : false, + render : function(data) { + var $minus = FormUtil.getButtonWithIcon("glyphicon-minus", function(event) { + event.stopPropagation(); + event.preventDefault(); + var sample = data['$object']; + _this.removeChildFromSampleOrMarkToDelete(sample); + _this._dataGrid.refresh(); + }, null, "Delete"); + return $minus; + }, + filter : function(data, filter) { + return false; + }, + sort : function(data1, data2, asc) { + return 0; + } + } + } + + this.removeChildFromSampleOrMarkToDelete = function(child) { + if(child.newSample) { + //Remove + var allChildren = this._storageListModel.sample.children; + for(var i = 0; i < allChildren.length; i++) { + if(allChildren[i].permId === child.permId) { + allChildren.splice(i,1); + } + } + } else { + //Mark To delete + child.deleteSample = true; + } + } + } \ No newline at end of file diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py index 3ac742b9b19366514df8fd5aa1e1592173b69e1a..54df302c8a94aaaf4f201c92ac967a27a36371d8 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/dss/reporting-plugins/eln-lims-api/script.py @@ -372,6 +372,7 @@ def init(tr, parameters, tableBuilder): ## Installing Mandatory Spaces/Projects on every login if missing insertSpaceIfMissing(tr, "ELN_SETTINGS"); + insertSpaceIfMissing(tr, "STORAGE"); insertSpaceIfMissing(tr, "METHODS"); insertSpaceIfMissing(tr, "MATERIALS"); @@ -394,11 +395,30 @@ def init(tr, parameters, tableBuilder): defaultExperiment = tr.createNewExperiment("/DEFAULT_LAB_NOTEBOOK/DEFAULT_PROJECT/DEFAULT_EXPERIMENT", "DEFAULT_EXPERIMENT"); defaultExperiment.setPropertyValue("NAME", "Default Experiment"); + if isSampleTypeAvailable(installedTypes, "STORAGE_RACK"): + bench = insertSampleIfMissing(tr, "/STORAGE/BENCH", "STORAGE_RACK"); + bench.setPropertyValue("NAME", "Bench"); + bench.setPropertyValue("ROW_NUM", "1"); + bench.setPropertyValue("COLUMN_NUM", "1"); + bench.setPropertyValue("BOX_NUM", "9999"); + bench.setPropertyValue("STORAGE_SPACE_WARNING", "80"); + bench.setPropertyValue("BOX_SPACE_WARNING", "80"); + bench.setPropertyValue("STORAGE_VALIDATION_LEVEL", "BOX_POSITION"); + + defaultStorage = insertSampleIfMissing(tr, "/STORAGE/DEFAULT_STORAGE", "STORAGE_RACK"); + defaultStorage.setPropertyValue("NAME", "Bench"); + defaultStorage.setPropertyValue("ROW_NUM", "4"); + defaultStorage.setPropertyValue("COLUMN_NUM", "4"); + defaultStorage.setPropertyValue("BOX_NUM", "9999"); + defaultStorage.setPropertyValue("STORAGE_SPACE_WARNING", "80"); + defaultStorage.setPropertyValue("BOX_SPACE_WARNING", "80"); + defaultStorage.setPropertyValue("STORAGE_VALIDATION_LEVEL", "BOX_POSITION"); + if isSampleTypeAvailable(installedTypes, "GENERAL_ELN_SETTINGS"): insertSampleIfMissing(tr, "/ELN_SETTINGS/GENERAL_ELN_SETTINGS", "GENERAL_ELN_SETTINGS"); + # On new installations check if the default types are installed to create their respective PROJECT/EXPERIMENTS if isNewInstallation: - if isSampleTypeAvailable(installedTypes, "ANTIBODY"): insertProjectIfMissing(tr, "/MATERIALS/REAGENTS", projectsCache); insertExperimentIfMissing(tr, "/MATERIALS/REAGENTS/ANTIBODY_COLLECTION_1", "MATERIALS", "Antibody Collection 1"); @@ -806,14 +826,34 @@ def insertUpdateSample(tr, parameters, tableBuilder): child = tr.createNewSample(newSampleChild["identifier"], newSampleChild["sampleTypeCode"]); #Create Sample given his id sampleChildrenNewIdentifiers.append(newSampleChild["identifier"]); child.setParentSampleIdentifiers([sampleIdentifier]); - if experiment != None: - child.setExperiment(experiment); + childExperimentIdentifier = None + childExperiment = None + if "experimentIdentifier" in newSampleChild: + childExperimentIdentifier = newSampleChild["experimentIdentifier"]; + childExperiment = tr.getExperiment(childExperimentIdentifier); + if childExperiment != None: + child.setExperiment(childExperiment); for key in newSampleChild["properties"].keySet(): propertyValue = unicode(newSampleChild["properties"][key]); if propertyValue == "": propertyValue = None; - - child.setPropertyValue(key,propertyValue); + child.setPropertyValue(key, propertyValue); + if ("children" in newSampleChild) and (newSampleChild["children"] != None): + for childChildrenData in newSampleChild["children"]: + childChildren = tr.createNewSample(childChildrenData["identifier"], childChildrenData["sampleTypeCode"]); #Create Sample given his id + childChildren.setParentSampleIdentifiers([newSampleChild["identifier"]]); + childChildrenExperimentIdentifier = None + childChildrenExperiment = None + if "experimentIdentifier" in childChildrenData: + childChildrenExperimentIdentifier = childChildrenData["experimentIdentifier"]; + childChildrenExperiment = tr.getExperiment(childChildrenExperimentIdentifier); + if childChildrenExperiment != None: + childChildren.setExperiment(childChildrenExperiment); + for key in childChildrenData["properties"].keySet(): + propertyValue = unicode(childChildrenData["properties"][key]); + if propertyValue == "": + propertyValue = None; + childChildren.setPropertyValue(key, propertyValue); #Add sample children that are not newly created if sampleChildrenAdded != None: