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

Commit 02afc2c

Browse files
committed
enable way to trigger reorder after move
1 parent eca77ed commit 02afc2c

File tree

2 files changed

+28
-25
lines changed

2 files changed

+28
-25
lines changed

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

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -244,31 +244,34 @@ export class FancytreeAdapter {
244244
var dropNodePath = data.otherNode.data.refPath;
245245
var targetPath = targetParentKeyPath + '/' + dropNodePath.substr(1 + dropNodePath.lastIndexOf('/'));
246246

247-
var oldIcon = data.otherNode.icon;
248247
data.otherNode.icon = 'fa fa-spinner fa-spin';
249248
data.otherNode.renderTitle();
250-
this.requestData.move(dropNodePath, targetPath)
251-
.done(function (responseData) {
252-
data.otherNode.remove();
253-
254-
if ('over' != data.hitMode) {
255-
node = node.parent;
256-
}
257-
258-
node.addChildren(requestNodeToFancytreeNode(responseData));
259-
})
260-
.fail(function (jqxhr, textStatus, errorThrown) {
261-
console.error(errorThrown);
262-
263-
node._error = { message: 'Failed to move the node.', details: errorThrown };
249+
var moveNodeInTree = function (data, node, responseData) {
250+
data.otherNode.remove();
251+
if ('over' != data.hitMode) {
252+
node = node.parent;
253+
}
254+
node.addChildren(requestNodeToFancytreeNode(responseData));
255+
};
256+
_this.requestData.move(dropNodePath, targetPath).done(function (responseData) {
257+
if (_this.dndOptions.reorder) {
258+
_this.requestData.reorder(targetParentKeyPath, targetPath, dropNodePath, data.hitMode).done(function (responseData) {
259+
moveNodeInTree(data, node, responseData);
260+
});
261+
} else {
262+
moveNodeInTree(data, node, responseData);
263+
}
264+
}).fail(function (jqxhr, textStatus, errorThrown) {
265+
console.error(errorThrown);
266+
267+
node._error = { message: 'Failed to move the node.', details: errorThrown };
268+
node.renderStatus();
269+
270+
setTimeout(function () {
271+
node._error = null;
264272
node.renderStatus();
265-
266-
setTimeout(function () {
267-
node._error = null;
268-
node.renderStatus();
269-
}, 1000);
270-
})
271-
;
273+
}, 1000);
274+
});
272275
}
273276
};
274277
}

0 commit comments

Comments
 (0)