Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit e666eb2

Browse files
committed
fix sortableBy method
1 parent f0f19d6 commit e666eb2

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/Resources/assets/js/adapter/fancytree.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,10 @@ export class FancytreeAdapter {
129129
fancytreeNode.icon = requestNode.descriptors.icon;
130130
}
131131

132+
if(requestNode.descriptors.hasOwnProperty('position')) {
133+
fancytreeNode.position = requestNode.descriptors.position;
134+
}
135+
132136
for (let actionName in actions) {
133137
var action = actions[actionName];
134138
var url = parseUrl(action.url, requestNode);
@@ -226,11 +230,11 @@ export class FancytreeAdapter {
226230

227231
if (this.sortableBy) {
228232
fancytreeOptions.sortChildren = (a, b) => {
229-
var firstItem = a.descriptors[this.sortableBy];
230-
var secondtItem = b.descriptors[this.sortableBy];
231-
if (firstItem == secondtItem) {
233+
var current = a[this.sortableBy];
234+
var next = b[this.sortableBy];
235+
if (current == next) {
232236
return 0;
233-
} else if (firstItem < secondtItem) {
237+
} else if (current < next) {
234238
return 1;
235239
} else {
236240
return -1;
@@ -269,16 +273,15 @@ export class FancytreeAdapter {
269273
parentNode.addChildren(requestNodeToFancytreeNode(responseData));
270274
};
271275
let onError = (jqxhr, textStatus, errorThrown) => {
272-
console.error(errorThrown);
273-
274276
node._error = { message: 'Failed to move the node.', details: errorThrown };
275277
node.renderStatus();
278+
console.error(errorThrown);
276279

277280
setTimeout(function () {
278281
node._error = null;
279282
node.renderStatus();
280283
}, 1000);
281-
}
284+
};
282285
this.requestData.move(dropNodePath, targetPath).done((responseData) => {
283286
if (this.dndOptions.reorder) {
284287
this.requestData.reorder(parenPath, dropedAtPath, targetPath, data.hitMode).done((responseData) => {

0 commit comments

Comments
 (0)