what is the best way to change user proposed transform steps with other steps?
If I entirely want to prohibit a set of steps, I use the
filterTransform. If I want to add steps, I use
beforeTransform. But to replace such transforms with others? Do I:
A) listen to beforeTransform, add steps reverting the action the user proposed and add even more steps that correspond to what the real edit should be?
B) listen to filterTransform, and don’t let the transform happen, but I record the fact that the user asked for the transform to happen and then create new transform that represent the change I really want which I time to be applied after the filtertransform is done?
Or is there a way to replace the steps of the beforeTransform?
This isn’t really possible yet (though A might work). What is it you’re trying to accomplish? Having a schema that prevents the kind of things you don’t allow is probably a better approach.
User is trying to delete something, but instead of actually deleting it, we are just marking it as being deleted.
A should work, but if in addition on the server I have something that checks for deletion of content in every step (in order to prevent that), it may create more issues.
One solution may be something like this:
User A tries to delete an Image. A beforetransform event is triggered with just one step. Our code adds a second step which reinstates the image and a third step which adds a deletion mark to that image. Before sending the steps to the server, the image-deletion and image-creation steps are exchanged for null-steps (steps that don’t do anything except increase the version number) so that only the third step (adding the deletion mark) is applied by collaborators.
The question is then just how to mark steps 1 and 2 in ways that make it clear they should be replaced with null-steps before sending them out.