Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Grid view configuration: Performance problems when searching for object definition fields #766

Open
wants to merge 1 commit into
base: 1.6
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 26 additions & 27 deletions public/js/pimcore/object/helpers/classTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,40 +29,36 @@ pimcore.object.helpers.classTree = Class.create({
},

updateFilter: function (tree, filterField) {
const store = tree.getStore();
const filterValue = filterField.getValue().toLowerCase();

tree.getStore().clearFilter();
var currentFilterValue = filterField.getValue().toLowerCase();
store.clearFilter();

tree.getStore().filterBy(function (item) {
if (item.data.text.toLowerCase().indexOf(currentFilterValue) !== -1) {
const searchFilter = (node) => {
if (node.data.text.toLowerCase().includes(filterValue)) {
return true;
}

if (!item.data.leaf) {
if (item.data.root) {
return true;
}
return !node.data.leaf && node.childNodes.some(searchFilter);
};

var childNodes = item.childNodes;
var hide = true;
if (childNodes) {
var i;
for (i = 0; i < childNodes.length; i++) {
var childNode = childNodes[i];
if (childNode.get("visible")) {
hide = false;
break;
}
}
}
store.filterBy(searchFilter);

return !hide;
}
}.bind(this));
const rootNode = tree.getRootNode();

var rootNode = tree.getRootNode()
rootNode.set('text', currentFilterValue ? t('element_tag_filtered_tags') : t('element_tag_all_tags'));
rootNode.expand(true);
rootNode.set(
'text',
filterValue ? t('element_tag_filtered_tags') : t('element_tag_all_tags')
);

if (filterValue) {
rootNode.expand(false);
rootNode.eachChild((child) => {
if (searchFilter(child)) {
child.expand(false);
}
});
}
},

getClassTree: function (url, classId, objectId) {
Expand Down Expand Up @@ -124,7 +120,10 @@ pimcore.object.helpers.classTree = Class.create({
success: this.initLayoutFields.bind(this, tree)
});

filterField.on("keyup", this.updateFilter.bind(this, tree, filterField));
filterField.on(
"keyup",
Ext.Function.createBuffered(this.updateFilter.bind(this, tree, filterField), 300)
);
filterButton.on("click", this.updateFilter.bind(this, tree, filterField));

return tree;
Expand Down
Loading