diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js index 886631581cd62714f73a936d2967b8e5770d91ab..dcfb8ec4cae47d8685de117b5fcac00e4b31764f 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/controllers/MainController.js @@ -257,8 +257,14 @@ function MainController(profile) { break; case "showAdvancedSearchPage": document.title = "Advanced Search"; - var freeTextForGlobalSearch = arg; - this._showAdvancedSearchPage(freeTextForGlobalSearch); + var argToUse = null; + try { + var cleanText = decodeURIComponent(arg); //If the JSON is written on the URL we need to clean special chars + argToUse = JSON.parse(cleanText); + } catch(err) { + argToUse = arg; + } + this._showAdvancedSearchPage(argToUse); window.scrollTo(0,0); break; case "showUserManagerPage": 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 e17595517b46c061fd0700e9ec12a82c196a04df..ab5c36f71473b976890faccee031082374377d77 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 @@ -14,9 +14,9 @@ * limitations under the License. */ -function AdvancedSearchController(mainController, forceFreeTextSearch) { +function AdvancedSearchController(mainController, forceSearch) { this._mainController = mainController; - this._advancedSearchModel = new AdvancedSearchModel(forceFreeTextSearch); + this._advancedSearchModel = new AdvancedSearchModel(forceSearch); this._advancedSearchView = new AdvancedSearchView(this, this._advancedSearchModel); this.init = function($container) { 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 009b017cb08210fdb24fe0a7c0ff1af09da3b3b3..638cb193a808d4961151b26ea9c67401d99f035c 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 @@ -14,17 +14,24 @@ * limitations under the License. */ -function AdvancedSearchModel(forceFreeTextSearch) { - - this.forceFreeTextSearch = forceFreeTextSearch; - this.isSampleTypeForced = false; +function AdvancedSearchModel(forceSearch) { + this.forceFreeTextSearch = null; + this.forceLoadCriteria = false; this.criteria = { - entityKind : null, - logicalOperator : null, - rules : { } // { "UUIDv4" : { type : "PROPERTY", name : "GENE", value : "aa" } } + entityKind : null, + logicalOperator : null, + rules : { } // { "UUIDv4" : { type : "PROPERTY", name : "GENE", value : "aa" } } } + if(typeof forceSearch === 'object') { + this.criteria = forceSearch; + this.forceLoadCriteria = true; + } else { + this.forceFreeTextSearch = forceSearch; + } + + this.isSampleTypeForced = false; this.isAllRules = function() { for(ruleUUID in this.criteria.rules) { var rule = this.criteria.rules[ruleUUID]; 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 efad134ca11d4089d03763d482d695beaa99d5b2..d4e6713ab5e939975bea135febef101f5ce1f254 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 @@ -17,6 +17,7 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._advancedSearchController = advancedSearchController; this._advancedSearchModel = advancedSearchModel; + this._$entityTypeDropdown = null; this._$andOrDropdownComponent = null; this._$menuPanelContainer = null; this._$searchCriteriaPanelContainer = null; @@ -52,8 +53,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._paintCriteriaPanel(this._$searchCriteriaPanelContainer); $mainPanel.append(this._$searchCriteriaPanelContainer); - // - //Search Results Panel this._$dataGridContainer = $("<div>"); $mainPanel.append(this._$dataGridContainer); @@ -62,6 +61,11 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { //Triggers Layout refresh $container.append($mainPanel); + if(this._advancedSearchModel.forceLoadCriteria) { + this._$entityTypeDropdown.val(this._advancedSearchModel.criteria.entityKind); + this._$andOrDropdownComponent.val(this._advancedSearchModel.criteria.logicalOperator); + this._advancedSearchModel.forceLoadCriteria = undefined; + } } // @@ -70,8 +74,8 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._paintMenuPanel = function($menuPanelContainer) { $menuPanelContainer.empty(); - var $entityTypeDropdown = this._getEntityTypeDropdown(); - $menuPanelContainer.append(FormUtil.getFieldForComponentWithLabel($entityTypeDropdown, "Search For", null, true)); + this._$entityTypeDropdown = this._getEntityTypeDropdown(); + $menuPanelContainer.append(FormUtil.getFieldForComponentWithLabel(this._$entityTypeDropdown, "Search For", null, true)); var andOrOptions = [{value : "AND", label : "AND", selected : true}, {value : "OR", label : "OR"}]; this._$andOrDropdownComponent = FormUtil.getDropdown(andOrOptions, "Select logical operator"); @@ -123,18 +127,22 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { this._paintInputRow = function() { var _this = this; - var uuidValue = Util.guid(); - this._advancedSearchModel.criteria.rules[uuidValue] = { }; + if(this._advancedSearchModel.forceLoadCriteria) { + var uuidValue = null; + for(var ruleKey in this._advancedSearchModel.criteria.rules) { + uuidValue = ruleKey; + } + } else { + var uuidValue = Util.guid(); + this._advancedSearchModel.criteria.rules[uuidValue] = { }; + } + + var $newFieldNameContainer = $("<td>"); var $newRow = $("<tr>", { id : uuidValue }); + var $fieldTypeDropdown = this._getNewFieldTypeDropdownComponent($newFieldNameContainer, this._advancedSearchModel.criteria.entityKind, uuidValue); var $fieldValue = $("<input>", { class : "form-control", type: "text"}); - if(this._advancedSearchModel.forceFreeTextSearch) { - $fieldValue.val(this._advancedSearchModel.forceFreeTextSearch); - this._advancedSearchModel.criteria.rules[uuidValue].value = this._advancedSearchModel.forceFreeTextSearch; //Update model - this._advancedSearchModel.forceFreeTextSearch = undefined; - } - $fieldValue.change(function() { var $thisComponent = $(this); //Get uuid and value and update model (type only) @@ -152,14 +160,30 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { } }); - var $newFieldNameContainer = $("<td>"); - $newRow.append($("<td>").append(this._getNewFieldTypeDropdownComponent($newFieldNameContainer, this._advancedSearchModel.criteria.entityKind, uuidValue))) + + $newRow.append($("<td>").append($fieldTypeDropdown)) .append($newFieldNameContainer) .append($("<td>").append($fieldValue)) .append($("<td>").append(this._getMinusButtonComponentForRow(this._$tbody, $newRow))); this._$tbody.append($newRow); + + if(this._advancedSearchModel.forceFreeTextSearch) { + $fieldValue.val(this._advancedSearchModel.forceFreeTextSearch); + this._advancedSearchModel.criteria.rules[uuidValue].value = this._advancedSearchModel.forceFreeTextSearch; //Update model + this._advancedSearchModel.forceFreeTextSearch = undefined; + } + + if(this._advancedSearchModel.forceLoadCriteria) { + for(var ruleKey in this._advancedSearchModel.criteria.rules) { + var rule = this._advancedSearchModel.criteria.rules[ruleKey]; + $fieldTypeDropdown.val(rule.type).change(); + $fieldValue.val(rule.value); + $fieldNameDropdown = $($newFieldNameContainer.children()[0]); + $fieldNameDropdown.val(rule.name); + } + } } //should make new objects every time. otherwise, using the same object will produce odd results! @@ -201,8 +225,6 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { break; } - this._advancedSearchModel.criteria.rules[uuid].type = "All"; //Update model with defaults - var $fieldTypeComponent = FormUtil.getDropdown(fieldTypeOptions, "Select Field Type"); $fieldTypeComponent.change(function() { var $thisComponent = $(this); @@ -236,6 +258,11 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { //Do Nothing } }); + + if(!this._advancedSearchModel.forceLoadCriteria) { + this._advancedSearchModel.criteria.rules[uuid].type = "All"; //Update model with defaults + } + return $fieldTypeComponent; } @@ -363,7 +390,10 @@ function AdvancedSearchView(advancedSearchController, advancedSearchModel) { model.push({ value : 'SAMPLE$' + sampleType.code, label : Util.getDisplayNameFromCode(sampleType.code) }); } - this._advancedSearchModel.resetModel('ALL'); + if(!this._advancedSearchModel.forceLoadCriteria) { + this._advancedSearchModel.resetModel('ALL'); + } + var $dropdown = FormUtil.getDropdown(model, 'Select Entity Type to search for'); $dropdown.change(function() { diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js index 1ba497370e028e4bf5535d2511ca04fbcf93a618..eb6f66ecffc63cae8738375bef7e901b6a2f07ea 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleTable/SampleTableView.js @@ -132,6 +132,17 @@ function SampleTableView(sampleTableController, sampleTableModel) { }); $list.append($batchUpdateOption); + var expKindName = ELNDictionary.getExperimentKindName(_this._sampleTableModel.experimentIdentifier, false); + var $searchCollectionOption = $("<li>", { 'role' : 'presentation' }).append($("<a>", {'title' : 'Search Into ' + expKindName }).append('Search Into ' + expKindName)); + $searchCollectionOption.click(function() { + + var sampleRules = { "UUIDv4" : { type : "Experiment", name : "ATTR.PERM_ID", value : _this._sampleTableModel.experiment.permId } }; + var rules = { entityKind : "SAMPLE", logicalOperator : "AND", rules : sampleRules }; + + mainController.changeView("showAdvancedSearchPage", JSON.stringify(rules)); + }); + $list.append($searchCollectionOption); + return $dropDownMenu; }