-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add ability to rollback specific attributes #3705
Comments
Another situation to be aware of, if |
Interesting idea @Panman8201. Would you be interested in working on an implementation? |
@bmac I took a look at the |
I'd be interested in taking a stab at this. I propose the following:
|
@courajs I'd still love to have this feature. While I'm not part of the ember-data team at all, I wouldn't mind if you took a stab at it! |
@courajs Do you know if this made it in ember data 2.8.0-beta.1? I just tried and it seems like it didn't, but it is in the changelog... Perhaps it's still under a feature flag and needs to be enabled explicitly? |
Yeah - the commits are included, but the feature is still behind a disabled feature flag: https://github.com/emberjs/data/blob/v2.8.0-beta.1/config/features.json#L10 |
@Panman8201 @courajs I will bring this up in the next ember-data weekly call to discuss if this should be enabled in the next beta release. For now you'd need a |
I had the same issue and managed to create a little workaround via changedAttributes like so: |
@bluscreen That's pretty close to what has been implemented behind the |
@pangratz Did this fall off the agenda? |
@courajs 😔 yes, unfortunately it did. I am sorry. We discussed this recently and despite our initial idea about naming this @courajs can I get you one more time to change this back to |
+1 |
@courajs it has been for some time. Any status update for when this might be enabled and available in release? (from the ED team obviously) |
Any specific reason for closing @stefanpenner ? I realize the feature has been merged but it's not yet enabled for beta/production. I was hoping to use this issue to keep track of status updates.. |
2 years later and this is still behind a feature flag :( What needs to happen to get this into ember stable? |
a solution is to create a new model every time when the user hits discard changes:
|
@stefanpenner can we get some more info on this? Why is this still behind a Canary Build? Why was this issue closed? I was really hoping this would be released with Ember 3.0. This feature is particularly relevant for having an attribute on a model that has it's own modify/rollback mechanism (i.e. edit and cancel buttons). For example, I have a Truck model, that has a Mapping attribute. On the Truck Edit form, the user can modify most simple attributes normally (eg type, color, icon, etc.), but there is a 'Change Mapping' button for if they want to show & modify the mapping attr, along with a Cancel button. I need this Cancel button to rollback this single attribute to its original state. This Mapping attribute is fairly simple and isn't complex enough to require full blown ember-data-model-fragments which relies on private APIs. This is just one of many uses for model.rollbackAttribute() |
We recently removed the feature flag. With the impending merge of the |
@stefanpenner @runspired Revisiting this after a couple years. Any update on this front? Is there a better/alternative way to do this or is it on the roadmap? |
TL;DR
model.rollbackAttributes(['attrA','attrC'])
It would be nice if the
.rollbackAttributes()
method accepted an array of attribute names that would be rolled back, leaving the others as-is. Ex:model.rollbackAttributes(['attrA','attrC'])
So in the example above, attributes 'attrA' and 'attrC' would have their values reverted to the previous, if changed. Other attributes, such as 'attrB', would retain their new value, if changed.
Related state information should properly reflect the rollback;
hasDirtyAttributes
andchangedAttributes()
. If there are other attributes not rolled back ('attrB') that have changed values, thenhasDirtyAttributes
would remain true. And calls tochangedAttributes()
would not return the rolled back attributes, but would return others that were changed.Passing in an empty array should trigger the default behavior, as though no array was passed in at all, rolling back all attributes.
The text was updated successfully, but these errors were encountered: