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
DS#revert should ignore omitted fields #205
Comments
This is a good point.
|
I'm not too familiar with the js-data codebase, but I can try to draft up a pull-request in the next few days if you're interested in incorporating this? I imagine something like var item = Item.get(5);
item.DSRevert({
skipOmittedFields: true
}); would be enough. I asked about skipping over fields in the gitter channel for an unrelated use case where I have two forms responsible for editing different parts of an item in the store, and I'd like to be able to cancel changes from one form without reverting the changes in the other form. I understand that this use case is a bit more unique than the one that I've described above, but I imagine this would be a good opportunity to add functionality that would cover both cases. In my mind something like var item = Item.get(5);
item.DSRevert({
skip: ['title', 'author']
}); would get us there, and the |
Both of those suggestions sound good
|
I retract my argument. Looks like this preserves existing functionality. 👍 |
Oh, I also used the term "preserve" I thought it best described what it did. Comments? |
item.DSRevert({
preserve: ['title', 'author']
}); |
Just as the title says. The docs say:
I know it can be interpreted several ways, but I take this to mean revert the item back to the last "true" state, as defined by the external backend. Since the backend is blind to the omitted fields, I'd expect the omitted fields to be... omitted from the state.
In my specific use case, I'm using an omitted field to keep track of whether the user has selected an item. If the user makes a change to the item while it is selected, saves the change to the server, and deselects the item, the next time the user reverts a change, the item will be selected again.
The text was updated successfully, but these errors were encountered: