UndoChanges for deleted child objects

UndoChanges for deleted child objects

Old forum URL: forums.lhotka.net/forums/t/6386.aspx


Codelines posted on Monday, February 09, 2009

UndoableBase.CopyState doesn't save undoable child objects, only cascade the call to CopyState for this objects. If a child object is deleted there is no way to undo this action. By example, if I have a page object, add a footer child object and delete the footer afterwards, how can I undo this action if I don't have any information stored about the footer?

rsbaker0 replied on Monday, February 09, 2009

I ran into this a week or so ago -- evidently it's not supported yet but it's on the wish list:

http://www.lhotka.net/cslabugs/edit_bug.aspx?id=49

The full thread which led me to this is here: http://forums.lhotka.net/forums/thread/30317.aspx. There are other possible side effects if you are using managed fields.

Codelines replied on Sunday, July 31, 2011

I think this could be addressed with a reference stack for each field/property used to reference an undoable object. CopyState will not only cascade for undoable objects but store their references in the reference stack. If an undoable object reference is removed, UndoChanges could restore that reference from the reference stack. When we have the same undoable object referenced multiple times in the object graph, an attribute could be created for signaling that those extra references will only be stored in the reference stack. As managed fields can't have attributes, a new RelationshipType could be created to signal those cases. Doing so, CopyState will not cascade twice for the same object nor increment multiple times its EditLevel. 

 

Copyright (c) Marimer LLC