We spent quite some time thinking about this in task breakdown. @Pablo-WMDE will probably pick this up on 15/04/19 but if not then this task description will need improving.
In task breakdown we discussed 3 possible solutions to rolling back to the pre-editmode state of the entity. They are:
- Re-request the revision ID from one of our repositories and recall the ENTITY_UPDATE action. We know this won't work out of the box after having done a successful save action. In this case we could either cache each revision and have the reposity reply with that or we could just remake the request.
- keep a copy of the "clean" entity in the store and use this. In this case at most 2 copies of an entity would be there (1 the version bound to the input fields and 2 the clean base copy)
- roll back each atomic mutation until we're back where we started
- either using an external library (e.g. something like https://vuejsdevelopers.com/2017/11/13/vue-js-vuex-undo-redo/)
- create our own implementation of this (perhaps leveraging existing vuex functionality?)
After this timebox we'd like to know for each of the options (1-3):
- How much effort is involved in creating a revision aware entity repository in the client
- should this implementation come with caching or is it premature optimisation
- Should this be portable to any part of the store or is it encapsulated within the entity namespace
- how much effort is involved in the atomic rollbacks
- how much code we would then need to maintain
- how much we would bloat out production bundle with this