Skip to content

Commit 1c7cd94

Browse files
Merge pull request #2960 from coreshop/copilot/add-drag-and-drop-support-again
Add multi-select drag & drop support for objectMultihref condition lists
2 parents cf30fff + dbfac39 commit 1c7cd94

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

src/CoreShop/Bundle/ResourceBundle/Resources/public/pimcore/js/object/objectMultihref.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -153,45 +153,51 @@ coreshop.object.objectMultihref = Class.create(pimcore.object.tags.manyToManyObj
153153
return this.component.getEl().dom;
154154
}.bind(this),
155155
onNodeOver: function (overHtmlNode, ddSource, e, data) {
156-
var record = data.records[0];
157-
var data = record.data;
158156
var fromTree = this.isFromTree(ddSource);
159157

160-
if (data.elementType == 'object' && this.dndAllowed(data, fromTree)) {
161-
return Ext.dd.DropZone.prototype.dropAllowed;
162-
} else {
163-
return Ext.dd.DropZone.prototype.dropNotAllowed;
158+
// Check if any of the records can be dropped
159+
for (var record of data.records) {
160+
var recordData = record.data;
161+
if (recordData.elementType === 'object' && this.dndAllowed(recordData, fromTree)) {
162+
return Ext.dd.DropZone.prototype.dropAllowed;
163+
}
164164
}
165165

166+
return Ext.dd.DropZone.prototype.dropNotAllowed;
166167
}.bind(this),
167168
onNodeDrop: function (target, ddSource, e, data) {
168-
var record = data.records[0];
169-
var data = record.data;
170169
var fromTree = this.isFromTree(ddSource);
171170

172171
// check if data is a treenode, if not allow drop because of the reordering
173172
if (!fromTree) {
174173
return true;
175174
}
176175

177-
if (data.elementType != 'object') {
178-
return false;
179-
}
176+
var addedAny = false;
180177

181-
if (this.dndAllowed(data, fromTree)) {
182-
var initData = {
183-
id: data.id,
184-
path: data.path,
185-
type: data.className
186-
};
178+
// Process all records in the drag selection
179+
for (var record of data.records) {
180+
var recordData = record.data;
181+
182+
if (recordData.elementType !== 'object') {
183+
continue;
184+
}
187185

188-
if (!this.objectAlreadyExists(initData.id)) {
189-
this.store.add(initData);
190-
return true;
186+
if (this.dndAllowed(recordData, fromTree)) {
187+
var initData = {
188+
id: recordData.id,
189+
path: recordData.path,
190+
type: recordData.className
191+
};
192+
193+
if (!this.objectAlreadyExists(initData.id)) {
194+
this.store.add(initData);
195+
addedAny = true;
196+
}
191197
}
192198
}
193199

194-
return false;
200+
return addedAny;
195201
}.bind(this)
196202
});
197203
}.bind(this));

0 commit comments

Comments
 (0)