Skip to content

Commit

Permalink
[Bug]: Relation field wrong dirty detector and "losing" data even wit…
Browse files Browse the repository at this point in the history
…hout any changes (#364)

* Fix: losing data of manyToManyRelation field

* Update public/js/pimcore/asset/metadata/grid.js

Co-authored-by: JiaJia Ji <[email protected]>

* Fix: dirty check in the editor

* Update gridCellEditor.js

---------

Co-authored-by: JiaJia Ji <[email protected]>
  • Loading branch information
robertSt7 and kingjia90 authored Dec 4, 2023
1 parent 14f4470 commit e422dca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions public/js/pimcore/asset/metadata/grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 6 additions & 6 deletions public/js/pimcore/element/helpers/gridCellEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -149,7 +149,7 @@ Ext.define('pimcore.element.helpers.gridCellEditor', {
startValue = me.startValue,
value;

if(fieldInfo.layout.noteditable) {
if (fieldInfo.layout.noteditable) {
return;
}

Expand Down

0 comments on commit e422dca

Please sign in to comment.