-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc37697
commit 1186b1a
Showing
2 changed files
with
13 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1186b1a
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.
Yes, but if you set a 'company', it will not be 'rolled back'.
As well, the user is new before the rollback, why is it not new after the rollback?
1186b1a
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.
ember data rollbackAttributes does the isNew back to false .. which is odd ( your right )
and yes, your right , the belongs to can't be rolled back. I could probably fix that ( but it would be hacky )
and I would have to see the use case your doing.
for example with a new record that you set up, if you want to throw it away .. don't call rollback call unloadRecord .. right ?
1186b1a
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.
Yeah, the rollbackAttributes definitely seems like an ember-data bug.
Our use case is odd for sure.
We have a 'new dialog' and we allow the user to 'clear' and start again (odd I know, I don't make the requirements). Could definitely discard the record and create a new one if that's the only way.
2nd case is a bit of a workaround as well.
If we have a record that has tried to save, and and the adapter returns an error, the error is in the 'errors' on the record (which is good). If the user then 'reverts' their change (puts the original value back in), the record is really no longer dirty and we are trying to 'rollback' to get rid of the errors (can't seems to find any ember-data way of clearing errors without saving again).
Thanks!
1186b1a
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.
For 1st case, I think discard and replace with new one is easiest answer
For case 2 , I am confused because would not rollback / rollbackAtrributes fix the errors? I have not used the ember data errors to show the user, because what I do is use validations ( like ember-cp-validations ) before they can even submit it to prevent the save even happening. That solves this issue for 99.9999% of the time.
1186b1a
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.
for case 2, the errors are on fields which are not changed (ie, this field is required).
rollbackAttributes only rolls back things which have changed.
All of the that doesn't matter because rollbackAttributes is broken in my view (on a new record). It changes it to 'not new' and marks it as 'deleted', which i really don't understand. So in my scenario, I can't use it. Thanks!