From a1da29f43510007982ba4a35085e752edc43109b Mon Sep 17 00:00:00 2001 From: Ji Jia Jia Date: Thu, 23 Oct 2025 20:33:57 +0200 Subject: [PATCH 1/5] fix --- .../element/helpers/gridColumnConfig.js | 38 ++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/public/js/pimcore/element/helpers/gridColumnConfig.js b/public/js/pimcore/element/helpers/gridColumnConfig.js index 5cb88f4da..1e97aa5b0 100644 --- a/public/js/pimcore/element/helpers/gridColumnConfig.js +++ b/public/js/pimcore/element/helpers/gridColumnConfig.js @@ -418,7 +418,21 @@ pimcore.element.helpers.gridColumnConfig = { containerType: "filterByRelationWindow" }); - editor.fieldConfig.width = 300; + editor.fieldConfig.width = '100%'; + + const activeFilter = this.grid.getStore().getFilters().items; + + for (let i = 0; i < activeFilter.length; i++) { + if (activeFilter[i].dataIndex !== fieldInfo.dataIndex) { + continue; + } + editor.data = activeFilter[i].getValue() + .split(",") + .map(v => ({ id: parseInt(v.trim()) })) + .filter(v => !isNaN(v.id)); + editor.store.loadData(items, false); + break; + } const formPanel = Ext.create('Ext.form.Panel', { xtype: "form", @@ -439,10 +453,20 @@ pimcore.element.helpers.gridColumnConfig = { iconCls: "pimcore_icon_filter pimcore_icon_overlay_add", handler: function () { if (formPanel.isValid() && typeof fieldInfo.getRelationFilter === "function") { - this.grid.filters.getStore().addFilter( - fieldInfo.getRelationFilter(fieldInfo.dataIndex, editor) - ); - this.filterByRelationWindow.close(); + try { + // Sync editor store with its current value (if applicable) + const value = editor.getValue(); + const items = Array.isArray(value) ? value : value ? [value] : []; + editor.store.loadData(items, false); + + this.grid.filters.getStore().addFilter( + fieldInfo.getRelationFilter(fieldInfo.dataIndex, editor) + ); + this.filterByRelationWindow.close(); + } catch (e) { + console.error("Error applying relation filter:", e); + pimcore.helpers.showNotification(t("error"), e.message || e, "error"); + } } }.bind(this) } @@ -954,6 +978,10 @@ pimcore.element.helpers.gridColumnConfig = { params["only_direct_children"] = this.checkboxOnlyDirectChildren.getValue(); } + if (typeof this.selectObjectType !=='undefined') { + params['filter_by_object_type'] = this.selectObjectType.getValue(); + } + //only unreferenced filter if (this.checkboxOnlyUnreferenced) { params["only_unreferenced"] = this.checkboxOnlyUnreferenced.getValue(); From 716717772321257fa0d54919de3025f1ea026eb7 Mon Sep 17 00:00:00 2001 From: Ji Jia Jia Date: Thu, 23 Oct 2025 20:40:52 +0200 Subject: [PATCH 2/5] fix --- public/js/pimcore/element/helpers/gridColumnConfig.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/public/js/pimcore/element/helpers/gridColumnConfig.js b/public/js/pimcore/element/helpers/gridColumnConfig.js index 9b155dc04..2e7a17961 100644 --- a/public/js/pimcore/element/helpers/gridColumnConfig.js +++ b/public/js/pimcore/element/helpers/gridColumnConfig.js @@ -456,7 +456,12 @@ pimcore.element.helpers.gridColumnConfig = { try { // Sync editor store with its current value (if applicable) const value = editor.getValue(); - const items = Array.isArray(value) ? value : value ? [value] : []; + let items = []; + if (Array.isArray(value)) { + items = value; + } else if (value) { + items = [value]; + } editor.store.loadData(items, false); this.grid.filters.getStore().addFilter( From 1f1dfb1178fc660fa5f5a94fd3eaf1606fd8e369 Mon Sep 17 00:00:00 2001 From: Ji Jia Jia Date: Thu, 23 Oct 2025 20:43:05 +0200 Subject: [PATCH 3/5] sonar fix --- public/js/pimcore/element/helpers/gridColumnConfig.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/js/pimcore/element/helpers/gridColumnConfig.js b/public/js/pimcore/element/helpers/gridColumnConfig.js index 2e7a17961..b0589b814 100644 --- a/public/js/pimcore/element/helpers/gridColumnConfig.js +++ b/public/js/pimcore/element/helpers/gridColumnConfig.js @@ -422,14 +422,14 @@ pimcore.element.helpers.gridColumnConfig = { const activeFilter = this.grid.getStore().getFilters().items; - for (let i = 0; i < activeFilter.length; i++) { - if (activeFilter[i].dataIndex !== fieldInfo.dataIndex) { + for (let filter of activeFilter) { + if (filter.dataIndex !== fieldInfo.dataIndex) { continue; } - editor.data = activeFilter[i].getValue() + editor.data = filter.getValue() .split(",") - .map(v => ({ id: parseInt(v.trim()) })) - .filter(v => !isNaN(v.id)); + .map(v => ({ id: Number.parseInt(v.trim()) })) + .filter(v => !Number.isNaN(v.id)); editor.store.loadData(items, false); break; } From eb61743a3c16b8d3626b6f40a68716d206ff11b8 Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Wed, 29 Oct 2025 09:17:45 +0100 Subject: [PATCH 4/5] Change grid column width to 300 --- public/js/pimcore/element/helpers/gridColumnConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/pimcore/element/helpers/gridColumnConfig.js b/public/js/pimcore/element/helpers/gridColumnConfig.js index b0589b814..d86021b7b 100644 --- a/public/js/pimcore/element/helpers/gridColumnConfig.js +++ b/public/js/pimcore/element/helpers/gridColumnConfig.js @@ -418,7 +418,7 @@ pimcore.element.helpers.gridColumnConfig = { containerType: "filterByRelationWindow" }); - editor.fieldConfig.width = '100%'; + editor.fieldConfig.width = '300'; const activeFilter = this.grid.getStore().getFilters().items; From dac00f76859d059b426c811e89bf8c291ffc873a Mon Sep 17 00:00:00 2001 From: JiaJia Ji Date: Wed, 29 Oct 2025 09:18:02 +0100 Subject: [PATCH 5/5] Update gridColumnConfig.js --- public/js/pimcore/element/helpers/gridColumnConfig.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/pimcore/element/helpers/gridColumnConfig.js b/public/js/pimcore/element/helpers/gridColumnConfig.js index d86021b7b..fa72b2179 100644 --- a/public/js/pimcore/element/helpers/gridColumnConfig.js +++ b/public/js/pimcore/element/helpers/gridColumnConfig.js @@ -418,7 +418,7 @@ pimcore.element.helpers.gridColumnConfig = { containerType: "filterByRelationWindow" }); - editor.fieldConfig.width = '300'; + editor.fieldConfig.width = 300; const activeFilter = this.grid.getStore().getFilters().items;