Skip to content

Commit

Permalink
fix: bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
volishevko committed Dec 16, 2024
1 parent db4be84 commit eca406a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 30 deletions.
2 changes: 1 addition & 1 deletion sources/services/gallery/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down
14 changes: 12 additions & 2 deletions sources/services/gallery/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down Expand Up @@ -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() {
Expand Down
30 changes: 24 additions & 6 deletions sources/services/gallery/searchSuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
7 changes: 5 additions & 2 deletions sources/services/gallery/suggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions sources/views/subviews/gallery/parts/filterPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -73,7 +73,6 @@ function getConfig(config) {
},
onChange() {
let searchValue = this.getValue();
searchValue = searchValue.trim();
searchValue = searchValue.replace(/\s+/g, " ");
this.setValue(searchValue);
}
Expand Down
16 changes: 2 additions & 14 deletions sources/views/subviews/gallery/parts/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)}<span style="padding-left:5px;">${name}</span>`;
return `${common.space(obj, common)}${common.icon(obj, common)} ${common.treecheckbox(obj, common)}<span style="padding-left:5px;" title="${name}">${name}</span>`;
},
fillspace: true,
select: false
Expand Down
11 changes: 9 additions & 2 deletions sources/views/subviews/gallery/parts/filtersFormElements.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -113,7 +118,9 @@ function transformToFormFormat(data, expandedFilters) {
collapsed,
expandedFilters
);
elems.push(filtersConfig);
if (filtersConfig) {
elems.push(filtersConfig);
}
break;
}
default:
Expand Down

0 comments on commit eca406a

Please sign in to comment.