diff --git a/sources/services/gallery/filter.js b/sources/services/gallery/filter.js index bcc943e..500a61f 100644 --- a/sources/services/gallery/filter.js +++ b/sources/services/gallery/filter.js @@ -73,7 +73,7 @@ function _setFilterCounts(controlView, totalCount, currentCount) { } function _setDiagnosisFilterCounts(treeView, option, totalCount, currentCount) { - const baseLabelText = option.id; + const baseLabelText = option.name; let firstNumberHtml; if (totalCount === currentCount) { firstNumberHtml = ""; diff --git a/sources/services/gallery/gallery.js b/sources/services/gallery/gallery.js index f164dd2..ded298a 100644 --- a/sources/services/gallery/gallery.js +++ b/sources/services/gallery/gallery.js @@ -130,10 +130,21 @@ class GalleryService { } } }); + const treeDataElements = this._filtersForm.queryView({view: "treetable"}, "all"); + let foundTreeDataElementFlag = false; + treeDataElements.forEach((e) => { + e.data.each((i) => { + const labelLowerCase = i.name.replace(/\([\/ 0-9]*\)$/, ""); + if (labelLowerCase.indexOf(searchValue.toLowerCase()) > -1) { + e.checkItem(i.id); + foundTreeDataElementFlag = true; + } + }); + }); if (filtersInfo.length > 0) { filtersBySearchCollection.parse(filtersInfo); } - else { + else if (!foundTreeDataElementFlag) { webix.alert(`"There are no filters which include "${searchValue}"`); } this._view.$scope.app.callEvent("filtersChanged", [filtersInfo]); @@ -1560,7 +1571,6 @@ class GalleryService { _searchEventsMethods(eventMethod) { this._searchInput.detachEvent("onEnter"); this._searchInput.on_click["gallery-search-filter"] = eventMethod; - this._searchInput.attachEvent("onEnter", eventMethod); } _clearNameFilter() { diff --git a/sources/services/gallery/searchSuggest.js b/sources/services/gallery/searchSuggest.js index 9fbc10c..f211109 100644 --- a/sources/services/gallery/searchSuggest.js +++ b/sources/services/gallery/searchSuggest.js @@ -50,16 +50,34 @@ function attachEvents(searchSuggest, searchInput, toggleButton) { return true; }); + // remove default behavior suggestList.detachEvent("onItemClick"); + // add new behavior suggestList.attachEvent("onItemClick", (id, event) => { const item = suggestList.getItem(id); - const controlId = util.getOptionId(item.key, item.value); - /** @type {webix.ui.checkbox} */ - const control = $$(controlId); - if (control) { - const controlValue = control.getValue(); - control.setValue(!controlValue); + if (item.key === "diagnosis") { + /** @type {webix.ui.treetable} */ + const diagnosisTree = $$(`treeTable-${item.key}`); + const controlId = item.optionId; + const control = diagnosisTree.getItem(controlId); + if (control) { + if (diagnosisTree.isChecked(controlId)) { + diagnosisTree.uncheckItem(controlId); + } + else { + diagnosisTree.checkItem(controlId); + } + } + } + else { + const controlId = util.getOptionId(item.key, item.value); + /** @type {webix.ui.checkbox} */ + const control = $$(controlId); + if (control) { + const controlValue = control.getValue(); + control.setValue(!controlValue); + } } if (!event.metaKey && !event.ctrlKey) { suggestList.hide(); diff --git a/sources/services/gallery/suggest.js b/sources/services/gallery/suggest.js index 9d58966..10d77d7 100644 --- a/sources/services/gallery/suggest.js +++ b/sources/services/gallery/suggest.js @@ -35,6 +35,7 @@ function formSuggestionsFromOptions(parent) { suggestions.push({ id: `${parent.id}|${o.key}`, key: parent.id, + name: "Collections", value: currentCollection.name ?? "", optionId: currentCollection.id, isCollection: true, @@ -75,7 +76,8 @@ function formSuggestionsFromOptions(parent) { parent.options?.forEach((o) => { suggestions.push({ id: `${parent.id}|${o.key}`, - key: parent.name, + name: parent.name, + key: parent.id, value: o.key ?? "", }); if (o.options) { @@ -92,7 +94,8 @@ function formSuggestionsFromData(parent) { const valueArray = parent.id.split("|").map((v, index) => (index < 2 ? v.toUpperCase() : v)); suggestions.push({ id: `diagnosis|${parent.id}`, - key: "", + key: "diagnosis", + optionId: parent.id, value: valueArray.join("|") ?? "", }); if (d.data) { diff --git a/sources/views/subviews/gallery/parts/filterPanel.js b/sources/views/subviews/gallery/parts/filterPanel.js index 2f5435b..2e4b4d0 100644 --- a/sources/views/subviews/gallery/parts/filterPanel.js +++ b/sources/views/subviews/gallery/parts/filterPanel.js @@ -42,8 +42,8 @@ function getConfig(config) { css: "filters-suggest", }; const searchSuggestView = searchSuggest.getConfig(searchSuggestConfig); - searchSuggestView.body.template = obj => (obj.key - ? `${obj.key}: ${obj.value}` + searchSuggestView.body.template = obj => (obj.name + ? `${obj.name}: ${obj.value}` : `${obj.value}`); searchSuggestView.filter = (obj, value) => { const result = `${obj.id}: ${obj.value}`.toLowerCase().includes(value.toLowerCase()); @@ -73,7 +73,6 @@ function getConfig(config) { }, onChange() { let searchValue = this.getValue(); - searchValue = searchValue.trim(); searchValue = searchValue.replace(/\s+/g, " "); this.setValue(searchValue); } diff --git a/sources/views/subviews/gallery/parts/filters.js b/sources/views/subviews/gallery/parts/filters.js index dffe316..016e91a 100644 --- a/sources/views/subviews/gallery/parts/filters.js +++ b/sources/views/subviews/gallery/parts/filters.js @@ -50,8 +50,7 @@ function _attachCollapseToTreeFilter(filter, dataForCreatingControl, expandedFil collapseElement.onClick = { "collapssible-filter-tree": collapsibleFilterFunction }; - const filterId = util.getOptionId("diagnosis", dataForCreatingControl.id); - if (!expandedFilters?.includes(filterId)) { + if (expandedFilters?.length === 0) { collapseElement.css = "collapssible-filter-tree hidden-filter"; collapsibleFilter.rows[1].hidden = true; } @@ -71,17 +70,6 @@ function _attachCollapseToTreeFilter(filter, dataForCreatingControl, expandedFil expandedParentsFilters.push(parentId); } } - if (expandedParentsFilters.includes(filterId)) { - collapseElement.css = "collapssible-filter-tree showed-filter"; - collapsibleFilter.rows[1].hidden = false; - if (dataForCreatingControl.parent) { - const parentValue = diagnosisModel.getDiagnosisConcatenateValue( - dataForCreatingControl.parent - ); - const parentId = util.getOptionId("diagnosis", parentValue); - expandedParentsFilters.push(parentId); - } - } return collapsibleFilter; } @@ -368,7 +356,7 @@ function getTreeCheckboxUI(data, collapsed, expandedFilters) { id: "name", template: (obj, common) => { const name = obj.$level < 3 ? obj.name.toUpperCase() : obj.name; - return `${common.space(obj, common)}${common.icon(obj, common)} ${common.treecheckbox(obj, common)}${name}`; + return `${common.space(obj, common)}${common.icon(obj, common)} ${common.treecheckbox(obj, common)}${name}`; }, fillspace: true, select: false diff --git a/sources/views/subviews/gallery/parts/filtersFormElements.js b/sources/views/subviews/gallery/parts/filtersFormElements.js index 6ebb146..441c555 100644 --- a/sources/views/subviews/gallery/parts/filtersFormElements.js +++ b/sources/views/subviews/gallery/parts/filtersFormElements.js @@ -99,12 +99,17 @@ function transformToFormFormat(data, expandedFilters) { case "checkbox": case "rangeCheckbox": filtersConfig = filtersViewHelper.getCheckboxUI(dataForCreatingControl, collapsed); - elems.push(_attachCollapseToFilter(filtersConfig, collapsed, dataForCreatingControl)); + if (filtersConfig) { + elems.push(_attachCollapseToFilter(filtersConfig, collapsed, dataForCreatingControl)); + } break; /* case "range_slider": t = filtersViewHelper.getRangeSliderUI(data[key].data[i]); break; */ case constants.FILTER_ELEMENT_TYPE.TREE_CHECKBOX: { + if (util.isMobilePhone()) { + break; + } const diagnosisRegex = /^diagnosis\|.*/; const diagnosisFilter = expandedFilters.find(f => diagnosisRegex.test(f)); collapsed = !diagnosisFilter; @@ -113,7 +118,9 @@ function transformToFormFormat(data, expandedFilters) { collapsed, expandedFilters ); - elems.push(filtersConfig); + if (filtersConfig) { + elems.push(filtersConfig); + } break; } default: