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 bf429e989588e5dcfc7708605cdab7f5519182ef..ecf4c7a39e673c742524de51a83e9efb2f478e74 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 @@ -860,6 +860,13 @@ FLY = [FIRST_TIME_VERSIONED, True, True, "FLY", "", [ [FIRST_TIME_VERSIONED, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_FLY", None] ]]; +SEARCH_QUERY = [MANDATORY_ITEM_VERSION, True, True, "SEARCH_QUERY", "Used to store saved search queries", [ + [MANDATORY_ITEM_VERSION, "NAME", "General", "Name", DataType.VARCHAR, None, "Name", None, None], + [MANDATORY_ITEM_VERSION, "CRITERIA", "General", "Criteria", DataType.XML, None, "Criteria", None, None], + [MANDATORY_ITEM_VERSION, "XMLCOMMENTS", "Comments", "Comments List", DataType.XML, None, "Several comments can be added by different users", "COMMENTS_SAMPLE", None], + [MANDATORY_ITEM_VERSION, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", "ANNOTATIONS_CHEMICAL", None] + ]]; + ## ## Sample Types - Non Materials ## @@ -1048,4 +1055,4 @@ ORDER = [MANDATORY_ITEM_VERSION, False, True, "ORDER", "", [ [MANDATORY_ITEM_VERSION, "ADDITIONAL_INFORMATION", "General", "Additional Information", DataType.VARCHAR, None, "Additional Information", None, None], [MANDATORY_ITEM_VERSION, "ANNOTATIONS_STATE", "Comments", "Annotations State", DataType.XML, None, "Annotations State", None, None], [MANDATORY_ITEM_VERSION, "ORDER_STATE", "Comments", "Order State", DataType.VARCHAR, None, "Order State", None, None, None, False] - ]]; \ No newline at end of file + ]]; 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 fe2669761f80c3211950f8633bea2ceb6cd18177..c2be900823e32d9589eef062899f6512b12d18db 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 @@ -63,6 +63,7 @@ def initBasicMasterData(tr): ## Sample Types - Non Materials ## elnTypes.createSampleTypeWithProperties(tr, elnTypes.GENERAL_ELN_SETTINGS); + elnTypes.createSampleTypeWithProperties(tr, elnTypes.SEARCH_QUERY); elnTypes.createSampleTypeWithProperties(tr, elnTypes.EXPERIMENTAL_STEP); elnTypes.createSampleTypeWithProperties(tr, elnTypes.STORAGE_RACK); elnTypes.createSampleTypeWithProperties(tr, elnTypes.STORAGE_POSITION); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/css/style.css b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/css/style.css index cdc1d86362db61fcf37555301eaefef6427e93de..14e79791d056613412d8bb6f82fb8d49150afed9 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/css/style.css +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/css/style.css @@ -18,14 +18,18 @@ * Placeholder Patch * https://github.com/select2/select2/issues/291 */ -.select2-selection--multiple .select2-search--inline .select2-search__field { -width: auto !important; -} /* * General Overrides */ +.select2-container .select2-selection__rendered > *:first-child.select2-search--inline { + width: 100% !important; +} +.select2-container .select2-selection__rendered > *:first-child.select2-search--inline .select2-search__field { + width: 100% !important; +} + .form-group { margin-bottom: 5px; } @@ -745,4 +749,4 @@ span.fancytree-custom-icon { background-repeat: no-repeat; background-position: 0 0; margin-left: .5em; -} \ 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/ELNDictionary.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/config/ELNDictionary.js index 58dedcee5d42c7d45602cf8877bce9ca4fc03e32..8db94a714886760dc0e5d203b912e316aa117baa 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 @@ -62,3 +62,9 @@ ELNDictionary.settingsView = { }, } } + +ELNDictionary.generatedObjects = { + searchQueriesProject: { + description: 'Generated by ELN for stored search queries.' + } +} \ 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 c8518d38538fe11ea21e8448eb0d6303dcfa7d22..42f079f722fad466df5ab41dd0fd677ea9a575a8 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 @@ -229,7 +229,20 @@ $.extend(DefaultProfile.prototype, { callback(); }); } - + + this.getHomeSpace = function(defaultToUsername, callback) { + mainController.serverFacade.getPersons([mainController.serverFacade.getUserId()], function(persons) { + var HOME_SPACE = null; + if(persons !== null) { + HOME_SPACE = (persons[0].getSpace()?persons[0].getSpace().getCode():null); + } + if(HOME_SPACE === null && defaultToUsername) { + HOME_SPACE = mainController.serverFacade.getUserId().toUpperCase(); + } + callback(HOME_SPACE); + }); + } + this.getSampleConfigSpacePrefix = function(sample) { var prefix = null; var spaceCode = sample.spaceCode; @@ -1115,4 +1128,4 @@ $.extend(DefaultProfile.prototype, { }); } } -}); \ No newline at end of file +}); 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 cd600c62a48fb79c32b37f4bc6802390ab8e55ce..4495e2483365e33cbf1c286076a3c1b4b00ad7f6 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 @@ -442,26 +442,22 @@ function ServerFacade(openbisServer) { this.deleteSamples = function(samplePermIds, reason, callback, confirmDeletions) { require(["as/dto/sample/id/SamplePermId", "as/dto/sample/delete/SampleDeletionOptions" ], - function(SamplePermId, SampleDeletionOptions) { - var samplePermIdsObj = []; - for(var sPIdx = 0; sPIdx < samplePermIds.length; sPIdx++) { - samplePermIdsObj.push(new SamplePermId(samplePermIds[sPIdx])); - } - - var deletionOptions = new SampleDeletionOptions(); - deletionOptions.setReason(reason); - - // logical deletion (move objects to the trash can) - mainController.openbisV3.deleteSamples(samplePermIdsObj, deletionOptions).done(function(deletionId) { - if(confirmDeletions) { - // Confirm deletion of samples - mainController.openbisV3.confirmDeletions([deletionId]).then(function() { - callback({}); - }); - } else { - callback(deletionId); - } - }); + function(SamplePermId, SampleDeletionOptions) { + var samplePermIdsObj = samplePermIds.map(function(permId) { return new SamplePermId(permId)}); + var deletionOptions = new SampleDeletionOptions(); + deletionOptions.setReason(reason); + + // logical deletion (move objects to the trash can) + mainController.openbisV3.deleteSamples(samplePermIdsObj, deletionOptions).done(function(deletionId) { + if(confirmDeletions) { + // Confirm deletion of samples + mainController.openbisV3.confirmDeletions([deletionId]).then(function() { + callback({}); + }); + } else { + callback(deletionId); + } + }); }); } @@ -2163,26 +2159,196 @@ function ServerFacade(openbisServer) { } // - // V3 Save Functions + // V3 Functions // - this.updateSample = function(sampleV1, callbackFunction) { - require([ "as/dto/sample/update/SampleUpdate", "as/dto/sample/id/SamplePermId"], - function(SampleUpdate, SamplePermId) { - var sampleUpdate = new SampleUpdate(); - sampleUpdate.setSampleId(new SamplePermId(sampleV1.permId)); - - for(var propertyCode in sampleV1.properties) { - sampleUpdate.setProperty(propertyCode, sampleV1.properties[propertyCode]); + this.getProject = function(projectIdentifier, callbackFunction) { + require(["as/dto/project/id/ProjectIdentifier", "as/dto/project/fetchoptions/ProjectFetchOptions"], + function(ProjectIdentifier, ProjectFetchOptions) { + var projectId = new ProjectIdentifier(projectIdentifier); + var fetchOptions = new ProjectFetchOptions(); + + mainController.openbisV3.getProjects([projectId], fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); } + ); + } - mainController.openbisV3.updateSamples([ sampleUpdate ]).done(function() { - callbackFunction(true); - }).fail(function(result) { + this.searchSamplesV3 = function(sampleType, callbackFunction) { + require(["as/dto/sample/search/SampleSearchCriteria", "as/dto/sample/fetchoptions/SampleFetchOptions"], + function(SampleSearchCriteria, SampleFetchOptions) { + var searchCriteria = new SampleSearchCriteria(); + searchCriteria.withType().withCode().thatEquals(sampleType); + var fetchOptions = new SampleFetchOptions(); + fetchOptions.withProperties(); + fetchOptions.withExperiment().withProject().withSpace(); + fetchOptions.withRegistrator(); + fetchOptions.sortBy().modificationDate().desc(); + mainController.openbisV3.searchSamples(searchCriteria, fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { Util.showError("Call failed to server: " + JSON.stringify(result)); callbackFunction(false); }); - }); + }); + } + + this.getSamples = function(permIds, callbackFunction) { + require(["as/dto/sample/id/SamplePermId", "as/dto/sample/fetchoptions/SampleFetchOptions"], + function(SamplePermId, SampleFetchOptions) { + var samplePermIds = permIds.map(function(permId) { return new SamplePermId(permId) }); + var fetchOptions = new SampleFetchOptions(); + fetchOptions.withProperties(); + fetchOptions.withExperiment().withProject().withSpace(); + fetchOptions.withRegistrator(); + fetchOptions.sortBy().modificationDate().desc(); + mainController.openbisV3.getSamples(samplePermIds, fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); + } + + this.createSample = function(sampleType, experiment, properties, callbackFunction) { + require(["as/dto/sample/create/SampleCreation", "as/dto/entitytype/id/EntityTypePermId", + "as/dto/experiment/id/ExperimentPermId", "as/dto/space/id/SpacePermId"], + function(SampleCreation, EntityTypePermId, ExperimentPermId, SpacePermId) { + var experimentPermId = experiment.permId.permId; + var space = experiment.project.space.code; + var sampleCreation = new SampleCreation(); + sampleCreation.setTypeId(new EntityTypePermId(sampleType)); + sampleCreation.setExperimentId(new ExperimentPermId(experimentPermId)); + sampleCreation.setSpaceId(new SpacePermId(space)); + if (properties) { + for (var property in properties) { + if (properties.hasOwnProperty(property)) { + sampleCreation.setProperty(property, properties[property]); + } + } + } + + mainController.openbisV3.createSamples([sampleCreation]).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + }); + + } + + this.createProject = function(space, code, description, callbackFunction) { + require(["as/dto/project/create/ProjectCreation", "as/dto/space/id/SpacePermId"], + function(ProjectCreation, SpacePermId) { + var projectCreation = new ProjectCreation(); + projectCreation.setSpaceId(new SpacePermId(space)); + projectCreation.setCode(code); + projectCreation.setDescription(description); + + mainController.openbisV3.createProjects([projectCreation]).done(function(result) { + callbackFunction(true); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + }); + } + + this.searchExperimentTypes = function(experimentTypeCode, callbackFunction) { + require(["as/dto/experiment/search/ExperimentTypeSearchCriteria", "as/dto/experiment/fetchoptions/ExperimentTypeFetchOptions"], + function(ExperimentTypeSearchCriteria, ExperimentTypeFetchOptions) { + var searchCriteria = new ExperimentTypeSearchCriteria(); + var fetchOptions = new ExperimentTypeFetchOptions(); + searchCriteria.withCode().thatEquals(experimentTypeCode); + + mainController.openbisV3.searchExperimentTypes(searchCriteria, fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); + } + + this.getExperiments = function(experimentPermIds, callbackFunction) { + require(["as/dto/experiment/id/ExperimentPermId", "as/dto/experiment/fetchoptions/ExperimentFetchOptions"], + function(ExperimentPermId, ExperimentFetchOptions) { + var expPermIds = experimentPermIds.map(function(permId) { return new ExperimentPermId(permId)}); + var fetchOptions = new ExperimentFetchOptions(); + fetchOptions.withProject().withSpace(); + + mainController.openbisV3.getExperiments(expPermIds, fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); + } + + this.searchExperiments = function(projectCode, experimentCode, callbackFunction) { + require(["as/dto/experiment/search/ExperimentSearchCriteria", "as/dto/experiment/fetchoptions/ExperimentFetchOptions"], + function(ExperimentSearchCriteria, ExperimentFetchOptions) { + var searchCriteria = new ExperimentSearchCriteria(); + var fetchOptions = new ExperimentFetchOptions(); + searchCriteria.withProject().withCode().thatEquals(projectCode); + searchCriteria.withCode().thatEquals(experimentCode); + fetchOptions.withProject().withSpace(); + + mainController.openbisV3.searchExperiments(searchCriteria, fetchOptions).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); + } + + this.createExperiment = function(experimentTypePermId, projectIdentifier, code, callbackFunction) { + require(["as/dto/experiment/create/ExperimentCreation", "as/dto/project/id/ProjectIdentifier", "as/dto/entitytype/id/EntityTypePermId"], + function(ExperimentCreation, ProjectIdentifier, EntityTypePermId) { + var experimentCreation = new ExperimentCreation(); + experimentCreation.setTypeId(new EntityTypePermId(experimentTypePermId)); + experimentCreation.setProjectId(new ProjectIdentifier(projectIdentifier)); + experimentCreation.setCode(code); + + mainController.openbisV3.createExperiments([experimentCreation]).done(function(result) { + callbackFunction(result); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); + } + + this.updateSample = function(sampleV1, callbackFunction) { + require([ "as/dto/sample/update/SampleUpdate", "as/dto/sample/id/SamplePermId"], + function(SampleUpdate, SamplePermId) { + var sampleUpdate = new SampleUpdate(); + sampleUpdate.setSampleId(new SamplePermId(sampleV1.permId)); + for(var propertyCode in sampleV1.properties) { + sampleUpdate.setProperty(propertyCode, sampleV1.properties[propertyCode]); + } + + mainController.openbisV3.updateSamples([ sampleUpdate ]).done(function() { + callbackFunction(true); + }).fail(function(result) { + Util.showError("Call failed to server: " + JSON.stringify(result)); + callbackFunction(false); + }); + } + ); } this.updateDataSet = function(dataSetPermId, newPhysicalData, callbackFunction) { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js index 033403ce3159c073c13fcdbd9ee499ff77be1aab..6dd24d4506e925591ddf72e21dc74da723f532a8 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/util/FormUtil.js @@ -1299,6 +1299,7 @@ var FormUtil = new function() { // params.buttons: array of buttons // params.css: css as a map // params.callback: function to be called on submit + // params.onBlock: function to be called when dialog is rendered this.showDialog = function(params) { var $window = $('<form>', { 'action' : 'javascript:void(0);' }); @@ -1320,6 +1321,9 @@ var FormUtil = new function() { if (params.focuseComponent) { params.focuseComponent.focus(); } + if (params.onBlock) { + params.onBlock(); + } }); } diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js index 307e6bb426f8d209509930c3c47a2a9ac78ac722..49e93942ef19027888211cd73db6fc3eb46582cd 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchController.js @@ -21,9 +21,11 @@ function AdvancedSearchController(mainController, forceSearch) { this.init = function(views) { var _this = this; - _this._advancedSearchView.repaint(views); + this._loadSavedSearches(function() { + _this._advancedSearchView.repaint(views); + }); } - + this.search = function() { var criteria = this._advancedSearchModel.criteria; var numberOfGeneralRules = 0; @@ -217,4 +219,178 @@ function AdvancedSearchController(mainController, forceSearch) { } } } -} \ No newline at end of file + + // + // query loading / saving + // + + this.selectSavedSearch = function(selcetedSavedSearchIndex) { + var savedSearch = this._advancedSearchModel.savedSearches[selcetedSavedSearchIndex]; + this._advancedSearchModel.selcetedSavedSearchIndex = selcetedSavedSearchIndex; + this._advancedSearchModel.criteria = savedSearch.criteria; + this._advancedSearchModel.forceLoadCriteria = true; + this._advancedSearchView.repaintContent(); + } + + // params.name + // params.experiment + this.saveNewSample = function(params, callback) { + var _this = this; + var criteria = _this._getSerializedCriteria(); + + this._ensureProjectAndExperiment(params.experiment, function(experiment) { + _this._doIfAdmin(experiment, function() { + _this._mainController.serverFacade.createSample('SEARCH_QUERY', experiment, { + NAME: params.name, + CRITERIA: criteria, + }, function(result) { + var permId = result[0].permId; + _this._mainController.serverFacade.getSamples([permId], function(result) { + if (result[permId]) { + var savedSearch = _this._sampleToSavedSearch(result[permId]); + _this._advancedSearchModel.savedSearches.push(savedSearch); + _this.selectSavedSearch(_this._advancedSearchModel.savedSearches.length - 1); + } + callback(); + }); + }); + }); + }); + } + + this.updateSelectedSample = function(callback) { + var _this = this; + var criteria = _this._getSerializedCriteria(); + var savedSearch = _this._advancedSearchModel.savedSearches[_this._advancedSearchModel.selcetedSavedSearchIndex]; + _this._doIfAdmin(savedSearch.sample.experiment, function() { + _this._mainController.serverFacade.updateSample({ + permId: savedSearch.sample.permId.permId, + properties: { + CRITERIA: criteria, + }, + }, function(success) { + if (success) { + Util.showSuccess('Search updated.'); + } + callback(); + }); + }); + } + + this.delete = function(selcetedSavedSearchIndex, callback) { + var _this = this; + var savedSearch = _this._advancedSearchModel.savedSearches[selcetedSavedSearchIndex]; + this._mainController.serverFacade.deleteSamples( + [savedSearch.sample.permId.permId], + 'Search query deletion by user', + function(deletionId) { + if (deletionId) { + _this._advancedSearchModel.selcetedSavedSearchIndex = -1; + Util.showSuccess('Search deleted.'); + _this._loadSavedSearches(function() { + _this._advancedSearchView.repaintContent(); + }); + } + callback(); + } + ); + } + + this._loadSavedSearches = function(callback) { + var _this = this; + this._mainController.serverFacade.searchSamplesV3('SEARCH_QUERY', function(result) { + _this._advancedSearchModel.savedSearches = []; + if(result != null && result.objects != null) { + var samples = _this._sortSavedSearchSamples(result.objects); + for (var i=0; i<samples.length; i++) { + _this._advancedSearchModel.savedSearches.push(_this._sampleToSavedSearch(samples[i])); + } + } + callback(); + }); + } + + // puts own samples on top + // samples are assumed to already be sorted by date + this._sortSavedSearchSamples = function(samples) { + var ownSamples = []; + var otherSamples = []; + for (var i=0; i<samples.length; i++) { + if (samples[i].registrator.userId == this._mainController.serverFacade.getUserId()) { + ownSamples.push(samples[i]); + } else { + otherSamples.push(samples[i]); + } + } + return ownSamples.concat(otherSamples); + } + + this._ensureProjectAndExperiment = function(experiment, callback) { + var _this = this; + if (experiment.defaultDummyExperiment) { + var dummyExperiment = experiment; + _this._mainController.serverFacade.getProject(dummyExperiment.projectIdentifier, function(result) { + if ($.isEmptyObject(result)) { + var description = ELNDictionary.generatedObjects.searchQueriesProject.description; + _this._mainController.serverFacade.createProject( + dummyExperiment.space, dummyExperiment.projectCode, description, function(result) { + _this._ensureExperiment(dummyExperiment, callback); + } + ); + } else { + _this._ensureExperiment(experiment, callback); + } + }); + } else { + callback(experiment); + } + } + + this._ensureExperiment = function(dummyExperiment, callback) { + var _this = this; + _this._mainController.serverFacade.searchExperiments( + dummyExperiment.projectCode, dummyExperiment.code, function(result) { + if (result != null && result.objects != null && result.objects.length > 0) { + callback(result.objects[0]); + } else { + var experimentTypePermId = 'COLLECTION'; + _this._mainController.serverFacade.createExperiment( + experimentTypePermId, dummyExperiment.projectIdentifier, dummyExperiment.code, function(result) { + if (result && result.length > 0) { + var experimentPermId = result[0].permId; + _this._mainController.serverFacade.getExperiments([experimentPermId], function(result) { + callback(result[experimentPermId]); + }); + } + }); + } + }); + } + + this._sampleToSavedSearch = function(sample) { + return { + sample: sample, + name: sample.properties.NAME, + criteria: JSON.parse(atob(sample.properties.CRITERIA.replace('<criteria>', '').replace('</criteria>', ''))), + }; + } + + this._getSerializedCriteria = function() { + return '<criteria>' + btoa(JSON.stringify(this._advancedSearchModel.criteria)) + '</criteria>'; + } + + this._doIfAdmin = function(experiment, action) { + var _this = this; + _this._mainController.getUserRole({ + space: experiment.project.code, + project: experiment.project.space.code, + }, function(roles) { + var hasAdmin = roles.filter(function(role) { return role.indexOf('ADMIN') > -1 }).length > 0; + if (hasAdmin) { + action(); + } else { + Util.showUserError('You need to be admin in the related space or project to save queries.'); + } + }); + } +} diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js index 638cb193a808d4961151b26ea9c67401d99f035c..0bc09d820013cdd67a1ca9f2a668a6f9bc97fbbc 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchModel.js @@ -23,7 +23,9 @@ function AdvancedSearchModel(forceSearch) { logicalOperator : null, rules : { } // { "UUIDv4" : { type : "PROPERTY", name : "GENE", value : "aa" } } } - + this.savedSearches = []; // [{ sample: v3Sample, name: "name", criteria: { see this.criteria }}, ...] + this.selcetedSavedSearchIndex = -1; + if(typeof forceSearch === 'object') { this.criteria = forceSearch; this.forceLoadCriteria = true; @@ -50,4 +52,4 @@ function AdvancedSearchModel(forceSearch) { this.criteria.entityKind = entityKind; this.criteria.rules = {}; } -} \ 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/AdvancedSearch/AdvancedSearchView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js index 8244e45dc70b90b8b98fff73f966623a26e7bb21..643c801d6f82f8d5d6cfb8f81f0080e39370aca5 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/AdvancedSearch/AdvancedSearchView.js @@ -23,6 +23,8 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._$searchCriteriaPanelContainer = null; this._$tbody = null; this._$dataGridContainer = null; + this._$saveLoadContainer = null; + this._$savedSearchesDropdown = null; // // Main Repaint Method @@ -40,7 +42,9 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { 'action' : 'javascript:void(0);' }); $mainPanelHeader.append($("<h2>").append("Advanced Search")); - this._paintMenuPanel($mainPanelHeader); + this._$saveLoadContainer = $("<div>"); + $mainPanelHeader.append(this._$saveLoadContainer); + this._paintSaveLoadPanel(this._$saveLoadContainer); $header.append($mainPanelHeader); //Search Criteria Panel @@ -70,12 +74,127 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { } } - + + this.repaintContent = function() { + this._paintSaveLoadPanel(this._$saveLoadContainer); + this._paintCriteriaPanel(this._$searchCriteriaPanelContainer); + } + // // Repaint Panels Methods // - - this._paintMenuPanel = function($menuPanelContainer) { + + this._save = function() { + var _this = this; + profile.getHomeSpace(false, function(HOME_SPACE) { + + Â Â Â Â var $nameField = FormUtil.getTextInputField('Name', 'Name', true); + + Â Â Â Â var $searchDropdownContainer = $('<div>'); + Â Â Â Â var advancedEntitySearchDropdown = new AdvancedEntitySearchDropdown(false, true, "search entity to store query", true, false, false, false); + Â Â Â Â advancedEntitySearchDropdown.init($searchDropdownContainer); + if (HOME_SPACE) { + Â Â Â Â advancedEntitySearchDropdown.addSelected({ + Â Â Â Â Â Â defaultDummyExperiment: true, + space: HOME_SPACE, + code: 'QUERIES_COLLECTION', + projectCode: 'QUERIES', + projectIdentifier: IdentifierUtil.getProjectIdentifier(HOME_SPACE, 'QUERIES'), + Â Â Â Â Â Â identifier: { identifier: IdentifierUtil.getExperimentIdentifier(HOME_SPACE, 'QUERIES', 'QUERIES_COLLECTION') }, + Â Â Â Â Â Â permId: { permId: 'permId' }, + Â Â Â Â }); + } + + Â Â Â Â var $btnSave = $('<input>', { 'type': 'submit', 'class' : 'btn btn-primary', 'value' : 'Save' }); + Â Â Â Â var $btnCancel = $('<a>', { 'class' : 'btn btn-default' }).append('Cancel'); + Â Â Â Â $btnCancel.click(function() { + Â Â Â Â Â Â Util.unblockUI(); + Â Â Â Â }); + + Â Â Â Â // update existing sample or save new one + Â Â Â Â if (_this._advancedSearchModel.selcetedSavedSearchIndex > -1) { + Â Â Â Â Â Â Util.blockUI(); + Â Â Â Â Â Â _this._advancedSearchController.updateSelectedSample(function() { + Â Â Â Â Â Â Â Â Util.unblockUI(); + Â Â Â Â Â Â }); + Â Â Â Â } else { + Â Â Â Â Â Â FormUtil.showDialog({ + Â Â Â Â Â Â Â Â css: {'text-align': 'left'}, + Â Â Â Â Â Â Â Â title: 'Save search query', + Â Â Â Â Â Â Â Â components: [$nameField, $searchDropdownContainer], + Â Â Â Â Â Â Â Â buttons: [$btnSave, $btnCancel], + Â Â Â Â Â Â Â Â callback: function() { + Â Â Â Â Â Â Â Â Â Â Util.unblockUI(); + Â Â Â Â Â Â Â Â Â Â Util.blockUI(); + Â Â Â Â Â Â Â Â Â Â _this._advancedSearchController.saveNewSample({ + Â Â Â Â Â Â Â Â Â Â Â Â name: $nameField.val(), + Â Â Â Â Â Â Â Â Â Â Â Â experiment: advancedEntitySearchDropdown.getSelected()[0], + Â Â Â Â Â Â Â Â Â Â }, Util.unblockUI);Â + Â Â Â Â Â Â Â Â }, + Â Â Â Â Â Â }); + Â Â Â Â } + + }); + } + + this._delete = function() { + var i = this._advancedSearchModel.selcetedSavedSearchIndex; + if (i !== null && i > -1) { + Util.blockUI(); + this._advancedSearchController.delete(i, function() { + Util.unblockUI(); + }); + } + } + + this._paintSaveLoadPanel = function($container) { + var _this = this; + $container.empty(); + + var savedSearchOptions = [{ + label: 'load a saved search', + value: -1, + disabled: true, + selected: _this._advancedSearchModel.selcetedSavedSearchIndex == -1, + }]; + for (var i=0; i<this._advancedSearchModel.savedSearches.length; i++) { + var savedSearch = this._advancedSearchModel.savedSearches[i]; + savedSearchOptions.push({ + label: savedSearch.name, + value: i, + selected: _this._advancedSearchModel.selcetedSavedSearchIndex == i, + }); + } + this._$savedSearchesDropdown = FormUtil.getPlainDropdown(savedSearchOptions); + this._$savedSearchesDropdown.change(function(change) { + var i = _this._$savedSearchesDropdown.val(); + _this._advancedSearchController.selectSavedSearch(i); + }); + $container.append(this._$savedSearchesDropdown); + this._$savedSearchesDropdown.select2({ + width: '400px', + theme: "bootstrap" + }); + + var $buttonSave = FormUtil.getButtonWithIcon('glyphicon-floppy-disk', function() { + _this._save(); + }, 'Save'); + $buttonSave.css({ 'margin-left': '8px'}); + $container.append($buttonSave); + + var $buttonDelete = FormUtil.getButtonWithIcon('glyphicon-trash', function() { + _this._delete(); + }, 'Delete'); + $buttonDelete.css({ 'margin-left': '8px'}); + var i = this._advancedSearchModel.selcetedSavedSearchIndex; + if (i == null || i < 0) { + $buttonDelete.attr('disabled', ''); + } + $container.append($buttonDelete); + + } + + this._paintTypeSelectionPanel = function($menuPanelContainer) { this._$entityTypeDropdown = this._getEntityTypeDropdown(); var entityTypeDropdownFormGroup = FormUtil.getFieldForComponentWithLabel(this._$entityTypeDropdown, "Search For", null, true); entityTypeDropdownFormGroup.css("width","50%"); @@ -105,9 +224,12 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._paintCriteriaPanel = function($searchCriteriaPanelContainer) { $searchCriteriaPanelContainer.empty(); $searchCriteriaPanelContainer.append($("<legend>").append("Criteria")); - + + this._paintTypeSelectionPanel(this._$searchCriteriaPanelContainer); + var _this = this; var $table = $("<table>", { class : "table table-bordered"}); + $table.css({ 'margin-top': '10px' }); $thead = $("<thead>"); this._$tbody = $("<tbody>"); diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown.js index f4e736a874123d7a5fd74bbf1ca1b11848115cf4..6dae6dfcfe24c34902d4c4657174de093ff5b7ef 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown.js @@ -342,4 +342,4 @@ function AdvancedEntitySearchDropdown( isMultiple, } } -} \ 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/SideMenu/SideMenuWidgetView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js index 4ebfcadbbeca3fa4d8826f4528cc61cfaf017b2e..222598d3b4a3238654e80c7b27495f323957b3d4 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SideMenu/SideMenuWidgetView.js @@ -264,15 +264,8 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { var showLabNotebooks = function(dfd, showEnabled, showDisabled) { var spaceRules = { entityKind : "SPACE", logicalOperator : "AND", rules : { } }; - mainController.serverFacade.getPersons([mainController.serverFacade.getUserId()], function(persons) { + profile.getHomeSpace(true, function(HOME_SPACE) { mainController.serverFacade.searchForSpacesAdvanced(spaceRules, null, function(searchResult) { - var HOME_SPACE = null; - if(persons !== null) { - HOME_SPACE = (persons[0].getSpace()?persons[0].getSpace().getCode():null); - } - if(HOME_SPACE === null) { - HOME_SPACE = mainController.serverFacade.getUserId().toUpperCase(); - } var results = []; var spaces = searchResult.objects; var nonInventoryNonHiddenSpaces = []; @@ -315,15 +308,8 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { switch(type) { case "LAB_NOTEBOOK": var spaceRules = { entityKind : "SPACE", logicalOperator : "AND", rules : { } }; - mainController.serverFacade.getPersons([mainController.serverFacade.getUserId()], function(persons) { + profile.getHomeSpace(true, function(HOME_SPACE) { mainController.serverFacade.searchForSpacesAdvanced(spaceRules, null, function(searchResult) { - var HOME_SPACE = null; - if(persons !== null) { - HOME_SPACE = (persons[0].getSpace()?persons[0].getSpace().getCode():null); - } - if(HOME_SPACE === null) { - HOME_SPACE = mainController.serverFacade.getUserId().toUpperCase(); - } var results = []; var spaces = searchResult.objects; for (var i = 0; i < spaces.length; i++) { @@ -395,14 +381,18 @@ function SideMenuWidgetView(sideMenuWidgetController, sideMenuWidgetModel) { mainController.serverFacade.searchForProjectsAdvanced({ entityKind : "PROJECT", logicalOperator : "AND", rules : projectRules }, null, function(searchResult) { var results = []; var projects = searchResult.objects; - for (var i = 0; i < projects.length; i++) { - var project = projects[i]; - var normalizedProjectTitle = Util.getDisplayNameFromCode(project.code); - var projectLink = _this.getLinkForNode(normalizedProjectTitle, project.getPermId().getPermId(), "showProjectPageFromPermId", project.getPermId().getPermId()); - results.push({ title : projectLink, entityType: "PROJECT", key : project.getPermId().getPermId(), folder : true, lazy : true, view : "showProjectPageFromPermId", viewData: project.getPermId().getPermId() }); - - } - dfd.resolve(results); + for (var i = 0; i < projects.length; i++) { + var project = projects[i]; + if (project.code == 'QUERIES' && + project.description == ELNDictionary.generatedObjects.searchQueriesProject.description) { + continue; + } + var normalizedProjectTitle = Util.getDisplayNameFromCode(project.code); + var projectLink = _this.getLinkForNode(normalizedProjectTitle, project.getPermId().getPermId(), "showProjectPageFromPermId", project.getPermId().getPermId()); + results.push({ title : projectLink, entityType: "PROJECT", key : project.getPermId().getPermId(), folder : true, lazy : true, view : "showProjectPageFromPermId", viewData: project.getPermId().getPermId() }); + + } + dfd.resolve(results); }); break; case "PROJECT": diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/4 b/openbis_standard_technologies/dist/core-plugins/eln-lims/4 new file mode 120000 index 0000000000000000000000000000000000000000..56a6051ca2b02b04ef92d5150c9ef600403cb1de --- /dev/null +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/4 @@ -0,0 +1 @@ +1 \ No newline at end of file