If a user deletes units on an item, the delete happens immediately. If they then decide not to save the item changes, but discard them, then we revert to the server's saved values. (Which are units that no longer exist.)
Steps to reproduce:
- Create an item with two units, Unit A and Unit B.
- Make Unit A the primary unit, and use Unit B in the planning section.
- Save the item.
- Edit the item.
- Change the planning section to use Unit A.
- Delete Unit B.
- Click the home button, discarding changes to the item. (DON'T SAVE IT)
The home screen, as well as that unit's screen, is now busted, since the item still has references to units that were deleted.
Changes on the item screen should happen atomically, all at once, or not at all, in order to prevent this.
Since the page may be refreshed as well, I can't just undo the adds or deletes during the revert at the end, as it may never be called. A refresh should leave the data in the exact same state it was before editing the item.
If a user deletes units on an item, the delete happens immediately. If they then decide not to save the item changes, but discard them, then we revert to the server's saved values. (Which are units that no longer exist.)
Steps to reproduce:
The home screen, as well as that unit's screen, is now busted, since the item still has references to units that were deleted.
Changes on the item screen should happen atomically, all at once, or not at all, in order to prevent this.
Since the page may be refreshed as well, I can't just undo the adds or deletes during the revert at the end, as it may never be called. A refresh should leave the data in the exact same state it was before editing the item.