From e422dca4b5c48bd60da96e06f9da256190c08e36 Mon Sep 17 00:00:00 2001 From: robertSt7 <104770750+robertSt7@users.noreply.github.com> Date: Mon, 4 Dec 2023 11:29:46 +0100 Subject: [PATCH] [Bug]: Relation field wrong dirty detector and "losing" data even without any changes (#364) * Fix: losing data of manyToManyRelation field * Update public/js/pimcore/asset/metadata/grid.js Co-authored-by: JiaJia Ji * Fix: dirty check in the editor * Update gridCellEditor.js --------- Co-authored-by: JiaJia Ji --- public/js/pimcore/asset/metadata/grid.js | 3 +++ public/js/pimcore/element/helpers/gridCellEditor.js | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/public/js/pimcore/asset/metadata/grid.js b/public/js/pimcore/asset/metadata/grid.js index 47365ea780..922f01281d 100644 --- a/public/js/pimcore/asset/metadata/grid.js +++ b/public/js/pimcore/asset/metadata/grid.js @@ -246,6 +246,9 @@ pimcore.asset.metadata.grid = Class.create({ //enable different editors per row editor.editors.each(function (e) { try { + if (e.fieldInfo?.layout?.fieldtype === 'manyToManyRelation') { + return; + } // complete edit, so the value is stored when hopping around with TAB e.completeEdit(); Ext.destroy(e); diff --git a/public/js/pimcore/element/helpers/gridCellEditor.js b/public/js/pimcore/element/helpers/gridCellEditor.js index 37d33643b1..8adfdf4ea5 100644 --- a/public/js/pimcore/element/helpers/gridCellEditor.js +++ b/public/js/pimcore/element/helpers/gridCellEditor.js @@ -25,10 +25,6 @@ Ext.define('pimcore.element.helpers.gridCellEditor', { this.callParent(); }, - getValue: function() { - return Math.random(); - }, - startEdit: function(el, value, /* private: false means don't focus*/ doFocus) { @@ -121,7 +117,11 @@ Ext.define('pimcore.element.helpers.gridCellEditor', { text: t("save"), iconCls: 'pimcore_icon_save', handler: function() { - var newValue = tag.getCellEditValue(); + if (typeof tag.isDirty === 'function' && tag.isDirty() === false) { + this.editWin.close(); + return; + } + const newValue = tag.getCellEditValue(); this.setValue(newValue); this.completeEdit(false); this.editWin.close(); @@ -149,7 +149,7 @@ Ext.define('pimcore.element.helpers.gridCellEditor', { startValue = me.startValue, value; - if(fieldInfo.layout.noteditable) { + if (fieldInfo.layout.noteditable) { return; }