-
Notifications
You must be signed in to change notification settings - Fork 782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use this.sourceInfo.cloneModel instead #627
Conversation
Instead of again copying the original model value, use the already copied cloneModel that is exposed in the drag events. This way, users can intercept and change the cloned data.
See #628 |
I need this fix too. I made the same fix in my local copy, however, it would be great if it can be part of official release. |
@@ -169,7 +169,7 @@ | |||
|
|||
// cloneEnabled and cross-tree so copy and do not remove from source | |||
if (this.isClone() && this.isForeign()) { | |||
this.parent.insertNode(this.index, angular.copy(nodeData)); | |||
this.parent.insertNode(this.index, this.sourceInfo.cloneModel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.sourceInfo.cloneModel
seems like the right solution. However, in cloneModel()
(L127), we check if cloning is enabled, as well as here (L172). This means we perform the check 2 times (in helper.js
on L127 and here on L172).
Do you have any suggestions on how we can refactor this to prevent double checking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No..we check isClone, not cloneEnabled, right? Isn't it rather the comment that is wrong?
I'd say that is another commit.
See my feedback. Can you add a unit-test for this behaviour? |
Any updates on this, @nicklasb? I'm not sure it's easy to add tests for this with the current codebase, but it would be nice to get your feedback on my comment. Thanks again! |
Hi, strange, I haven't seen any updates for this issue until now. |
Well, probably, but this is a very pretty reasonable and simple change. Currently, the original value, not cloneModel, is inserted into the target, which means that any changes to the cloneModel are disregarded and thus there is no way to intercept and affect what data is inserted into the target tree. The only thing you can insert is exactly the original. |
I got your point, thanks for explaining again. It would be helpful to add this to the documentation for future reference. Thanks! |
Use this.sourceInfo.cloneModel instead
Remove deprecated NOTE, which was fixed with #627
Instead of again copying the original model value, use the already copied cloneModel that is exposed in the drag events.
This way, users can intercept and change the cloned data.