Skip to content

Commit 656cfe6

Browse files
authored
[Bug]: Newly added operators not working anymore (#917)
* Fix operators * Removed isOperator variable * Removed debug info
1 parent 1392c77 commit 656cfe6

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

src/Resources/public/js/fieldConfigDialog.js

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ pimcore.plugin.datahub.fieldConfigDialog = Class.create({
141141
doGetRecursiveData: function (node) {
142142
var children = [];
143143
node.eachChild(function (child) {
144-
var attributes = child.data.configAttributes;
144+
var attributes = child.data.configAttributes ?? [];
145145
attributes.children = this.doGetRecursiveData(child);
146146
var childConfig = {
147147
"isOperator": child.data.isOperator ? true : false,
@@ -265,6 +265,22 @@ pimcore.plugin.datahub.fieldConfigDialog = Class.create({
265265
}
266266
},
267267

268+
addToDragData: function (record, dragData, removeFromParent = false) {
269+
if (!this.checkSupported(record)) {
270+
return;
271+
}
272+
273+
let copy = Ext.apply({}, record.data);
274+
delete copy.id;
275+
dragData.push(
276+
record.createNode(copy)
277+
);
278+
279+
if(removeFromParent) {
280+
record.parentNode.removeChild(record);
281+
}
282+
},
283+
268284
getSelectionPanel: function () {
269285
if (!this.selectionPanel) {
270286
this.selectedConfigItems = [];
@@ -340,15 +356,54 @@ pimcore.plugin.datahub.fieldConfigDialog = Class.create({
340356

341357
var dragData = [];
342358
records.forEach(function (record) {
343-
if (!this.selectionPanel.getRootNode().findChild("key", record.data.key)) {
344-
if (!this.checkSupported(record)) {
359+
let realOverModel = overModel;
360+
361+
if(target !== source) {
362+
if (record.data.isOperator || this.parentIsOperator(realOverModel)) {
363+
let attr = record.data;
364+
if (record.data.configAttributes) {
365+
attr = record.data.configAttributes;
366+
}
367+
let elementConfig = {
368+
"isOperator": true,
369+
"attributes": attr
370+
}
371+
372+
let element = this.getConfigElement(elementConfig);
373+
let copy = element.getCopyNode(record);
374+
dragData.push(copy);
375+
this.openConfigDialog(element, copy);
376+
377+
return;
378+
}
379+
380+
this.addToDragData(record, dragData);
381+
return;
382+
}
383+
384+
if (dropPosition === "before" || dropPosition === "after") {
385+
realOverModel = overModel.parentNode;
386+
}
387+
388+
if (record.data.isOperator || this.parentIsOperator(realOverModel)) {
389+
let attr = record.data;
390+
if (record.data.isOperator && record.data.configAttributes) {
345391
return;
346392
}
347-
var copy = Ext.apply({}, record.data);
348-
delete copy.id;
349-
copy = record.createNode(copy);
393+
let element = this.getConfigElement(attr);
394+
395+
let copy = element.getCopyNode(record);
350396
dragData.push(copy);
397+
398+
this.openConfigDialog(element, copy);
399+
400+
record.parentNode.removeChild(record);
401+
402+
return;
351403
}
404+
405+
this.addToDragData(record, dragData, true);
406+
352407
}.bind(this));
353408

354409
if (dragData.length === 0) {

src/Resources/public/js/queryvalue/DefaultValue.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ pimcore.plugin.datahub.queryvalue.defaultvalue = Class.create(pimcore.plugin.dat
3636
},
3737

3838
getCopyNode: function(source) {
39-
4039
var copy = source.createNode({
4140
iconCls: source.data.iconCls,
4241
text: source.data.text,
4342
isTarget: true,
4443
leaf: true,
4544
dataType: source.data.dataType,
4645
qtip: source.data.key,
46+
key: source.data.key,
47+
isOperator: source.data.isOperator ?? false,
4748
configAttributes: {
4849
label: source.data.text,
4950
type: this.type,

0 commit comments

Comments
 (0)