diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html index 282949b2774a707fcd04450eda5e69c85bcadc04..dea9d8031ab3579f936af6c1d28bb61ea039f7ab 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/index.html @@ -213,7 +213,6 @@ <script type="text/javascript" src="./js/views/DataSetForm/DataSetFormView.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown.js"></script> - <script type="text/javascript" src="./js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown2.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/widgets/DatasetViewerController.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/widgets/DatasetViewerModel.js"></script> <script type="text/javascript" src="./js/views/DataSetForm/widgets/DatasetViewerView.js"></script> 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 d18df1777e5365036a21a5571193006b84ebd2ba..b19d1a6c40d58c5b01892bd80b24a6732870ad7a 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 @@ -51,8 +51,8 @@ function ServerFacade(openbisServer) { var responseInterceptor = function(response, action){ var isError = false; if(response && response.error) { - if(response.error.message === "Session no longer available. Please login again." - || response.error.message.endsWith("is invalid: user is not logged in.")) { + if(response.error.message && (response.error.message === "Session no longer available. Please login again." + || response.error.message.endsWith("is invalid: user is not logged in."))) { isError = true; Util.showError(response.error.message, function() { location.reload(true); 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 9c5a96074d6f508de47c2143f50760544a7d7d4d..efd5f703b3ce66c13aea5b22ea3f9e26a58fccb4 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 @@ -27,6 +27,7 @@ function AdvancedEntitySearchDropdown(isMultiple, var placeholder = placeholder; var selectsExperiments = selectsExperiments; var selectsSamples = selectsSamples; + var getSelectsSamplesCriteria = null; var selectsDatasets = selectsDatasets; var selectsProjects = selectsProjects; var selectSpaces = selectSpaces; @@ -42,6 +43,14 @@ function AdvancedEntitySearchDropdown(isMultiple, this.onChange = function(onChangeCallbackGiven) { onChangeCallback = onChangeCallbackGiven } + + this.setGetSelectsSamplesCriteria = function(newGetSelectsSamplesCriteria) { + getSelectsSamplesCriteria = newGetSelectsSamplesCriteria; + } + + this.getParams = function() { + return storedParams; + } this.addSelectedProject = function(projectIdentifier) { var _this = this; @@ -176,14 +185,20 @@ function AdvancedEntitySearchDropdown(isMultiple, } var searchSample = function(action) { - var criteria = { - entityKind : "SAMPLE", - logicalOperator : "OR", + var criteria = null; + + if(getSelectsSamplesCriteria) { + criteria = getSelectsSamplesCriteria(); + } else { + criteria = { + entityKind : "SAMPLE", + logicalOperator : "OR", rules : { "UUIDv4-1": { type: "Property/Attribute", name: "PROP.$NAME", operator : "thatContainsString", value: storedParams.data.q }, "UUIDv4-2": { type: "Property/Attribute", name: "ATTR.CODE", operator : "thatContains", value: storedParams.data.q } } }; + } mainController.serverFacade.searchForSamplesAdvanced(criteria, { only : true, withType : true, diff --git a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown2.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown2.js deleted file mode 100644 index e4581ba0b44a9988caf2b6b490e47ad1476e7b93..0000000000000000000000000000000000000000 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/DataSetForm/widgets/AdvancedEntitySearchDropdown2.js +++ /dev/null @@ -1,76 +0,0 @@ -function AdvancedEntitySearchDropdown2(placeholder) { - var placeholder = placeholder; - this.isMultiple = true; - this.isRequired = false; - var onChangeCallback = null; - - this.onChange = function(onChangeCallbackGiven) { - onChangeCallback = onChangeCallbackGiven - } - - this.search = function(query, callback) { - callback([]); - } - - this.renderResult = function(result) { - return []; - } - - var $select = FormUtil.getPlainDropdown({}, ""); - - this.init = function($container) { - var _this = this; - $select.attr("multiple", "multiple"); - if (this.isRequired) { - $select.attr("required", "required"); - } - if (this.isMultiple) { - maximumSelectionLength = 9999; - } else { - maximumSelectionLength = 1; - } - $container.append($select); - - $select.select2({ - width: '100%', - theme: "bootstrap", - maximumSelectionLength: maximumSelectionLength, - minimumInputLength: 2, - placeholder : placeholder, - ajax: { - delay: 1000, - processResults: function (data) { - return { - "results": _this.renderResult(data), - "pagination": { - "more": false - } - }; - }, - transport: function (params, success, failure) { - var query = params.data.q; - _this.search(query, success); - return { - abort : function() { /*Not implemented*/ } - } - } - } - }); - - if (onChangeCallback) { - var onSelectOrUnselect = function (e) { - onChangeCallback($select.select2('data')); - }; - $select.on('select2:select', onSelectOrUnselect); - $select.on('select2:unselect', onSelectOrUnselect); - } - } - - this.getData = function() { - return $select.select2('data'); - } - - this.clear = function() { - $select.val(null).trigger('change'); - } -} \ 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/LinksView.js b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js index 1a30ce60acd6207402ce60230244990e3fa816d8..205f1569a5127a23329f59c1c25e727e0a95ddcd 100644 --- a/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js +++ b/openbis_standard_technologies/dist/core-plugins/eln-lims/1/as/webapps/eln-lims/html/js/views/SampleForm/widgets/LinksView.js @@ -174,6 +174,10 @@ function LinksView(linksController, linksModel) { this.repaint = function($container) { var $fieldsetOwner = $("<div>"); var $legend = $("<legend>"); + $legend.css({ + 'padding-top':'5px', + 'padding-bottom':'5px' + }); var $fieldset = $("<div>"); $fieldsetOwner.append($legend).append($fieldset); @@ -191,7 +195,7 @@ function LinksView(linksController, linksModel) { $legend.append(linksModel.title).append(" ").append(addAnyBtn); //.css("margin-top", "20px").css("margin-bottom", "20px"); if(!linksModel.disableAddAnyType && profile.mainMenu.showBarcodes) { - $legend.append(linksView.getAddAnyBarcode()); + $legend.append(" ").append(linksView.getAddAnyBarcode()); } $fieldset.append($samplePicker); @@ -413,52 +417,63 @@ function LinksView(linksController, linksModel) { "padding" : "5px", "background-color" : "#f6f6f6" }); - - //Close Button - var $closeBtn = FormUtil.getButtonWithIcon("glyphicon-remove", function() { - $container.empty().hide(); - }); - var $closeBtnContainer = $("<div>").append($closeBtn).css({"text-align" : "right", "padding-right" : "2px"}); - $container.append($closeBtnContainer); - - //Title - $container.append($("<div>").append("Select " + sampleTypeCode + ":")); - - //Grid Contaienr + + //Grid Layout var $gridContainer = $("<div>"); $container.append($gridContainer); - - //Show Table Logic - var extraOptions = []; - extraOptions.push({ name : "Add selected", action : function(selected) { - for(var sIdx = 0; sIdx < selected.length; sIdx++) { - linksController.addSample(selected[sIdx]); - } - $container.empty().hide(); - }}); - - var advancedSampleSearchCriteria = { - entityKind : "SAMPLE", - logicalOperator : "AND", - rules : { "1" : { type : "Attribute", name : "SAMPLE_TYPE", value : sampleTypeCode } } - } - - if(sampleTypeCode === "REQUEST") { - // This property is missing the $ because the search uses V1 instead of V3 - advancedSampleSearchCriteria.rules["2"] = { type : "Property", name : "PROP.$ORDERING.ORDER_STATUS", value : "NOT_YET_ORDERED" }; - } - if(sampleTypeCode === "ORGANIZATION_UNIT") { - var spaceCode = mainController.currentView._sampleFormModel.sample.spaceCode; - advancedSampleSearchCriteria.rules["2"] = { type : "Attribute", name : "ATTR.SPACE", value : spaceCode }; - } - - var rowClick = function(e) { - linksController.addSample(e.data["$object"]); - $container.empty().hide(); - } - var dataGrid = SampleDataGridUtil.getSampleDataGrid(sampleTypeCode, advancedSampleSearchCriteria, rowClick, null, null, null, true, true, true, false, 60); - dataGrid.init($gridContainer, extraOptions); - dataGrids.push(dataGrid); + + var $closeBtn = FormUtil.getButtonWithIcon("glyphicon-remove", function() { + $container.empty().hide(); + }); + var $closeBtnContainer = $("<div>").append($closeBtn).css({"text-align" : "right", "padding-right" : "2px"}); + $gridContainer.append($closeBtnContainer); + + var $searchDropdownContainer = $("<div>"); + $gridContainer.append($searchDropdownContainer); + + // Search Dropdown + var searchDropdown = new AdvancedEntitySearchDropdown(false, true, "Code or Name of the Object", false, true, false, false, false, '50%'); + searchDropdown.onChange(function(selected) { + linksController.addSample({ identifier : selected[0].identifier.identifier }); + $container.empty().hide(); + }); + searchDropdown.setGetSelectsSamplesCriteria(function() { + var advancedSampleSearchCriteria = { + entityKind : "SAMPLE", + logicalOperator : "OR", + rules : {}, + subCriteria : { + "1": { + entityKind : "SAMPLE", + logicalOperator : "AND", + rules : { + "1-1": { type : "Attribute", name : "SAMPLE_TYPE", value : sampleTypeCode }, + "1-2": { type: "Property/Attribute", name: "ATTR.CODE", operator : "thatContains", value: searchDropdown.getParams().data.q } + } + }, + "2": { + entityKind : "SAMPLE", + logicalOperator : "AND", + rules : { + "2-1": { type : "Attribute", name : "SAMPLE_TYPE", value : sampleTypeCode }, + "2-2": { type: "Property/Attribute", name: "PROP.$NAME", operator : "thatContainsString", value: searchDropdown.getParams().data.q } + } + } + } + } + if(sampleTypeCode === "REQUEST") { + // This property is missing the $ because the search uses V1 instead of V3 + advancedSampleSearchCriteria.subCriteria.rules["1-3"] = { type : "Property", name : "PROP.$ORDERING.ORDER_STATUS", value : "NOT_YET_ORDERED" }; + advancedSampleSearchCriteria.subCriteria.rules["2-3"] = { type : "Property", name : "PROP.$ORDERING.ORDER_STATUS", value : "NOT_YET_ORDERED" }; + } + if(sampleTypeCode === "ORGANIZATION_UNIT") { + var spaceCode = mainController.currentView._sampleFormModel.sample.spaceCode; + advancedSampleSearchCriteria.subCriteria.rules["1-3"] = { type : "Attribute", name : "ATTR.SPACE", value : spaceCode }; + advancedSampleSearchCriteria.subCriteria.rules["2-3"] = { type : "Attribute", name : "ATTR.SPACE", value : spaceCode }; + } + return advancedSampleSearchCriteria; + }); + searchDropdown.init($searchDropdownContainer); } linksView.getAddBtn = function($container, sampleTypeCode, sampleTableContainerLabel) { @@ -466,8 +481,8 @@ function LinksView(linksController, linksModel) { linksView.showSamplePicker($container, sampleTypeCode); }; - var id = "plus-btn-" + sampleTableContainerLabel.toLowerCase().split(" ").join("-"); - var $addBtn = FormUtil.getButtonWithIcon("glyphicon-plus", (linksModel.isDisabled)?null:enabledFunction, null, null, id); + var id = "search-btn-" + sampleTableContainerLabel.toLowerCase().split(" ").join("-"); + var $addBtn = FormUtil.getButtonWithIcon("glyphicon-search", (linksModel.isDisabled)?null:enabledFunction, null, null, id); if(linksModel.isDisabled) { return ""; } else { @@ -491,7 +506,7 @@ function LinksView(linksController, linksModel) { }); }; var id = "plus-btn-" + linksModel.title.split(" ").join("-").toLowerCase() + "-type-selector"; - var $addBtn = FormUtil.getButtonWithIcon("glyphicon-plus", (linksModel.isDisabled)?null:enabledFunction, null, null, id); + var $addBtn = FormUtil.getButtonWithIcon("glyphicon-search", (linksModel.isDisabled)?null:enabledFunction, null, null, id); if(linksModel.isDisabled) { return "";