MarimerLLC / cslaforum

Discussion forum for CSLA .NET
https://cslanet.com
Other
31 stars 6 forks source link

UndoEdit on child list without undoing parent #789

Open GreatBarrier86 opened 5 years ago

GreatBarrier86 commented 5 years ago

Question I'm in somewhat of a sticky situation. In my app, i have the following layout.

-Root: MyItemList
---Child: MyItem
-----ChildList: MyChildItemList
-------ChildListItem: MyChildItem

Imagine the following scenario

Given that MyChildItemList is a child of MyItem and BeginEdit cannot be called on a child list, how would I Cancel the change to MyChildItemList[0] without undoing the changes to MyItem.Comments as well? To the same point, imagine that instead of editing an existing item in MyChildItemList, we were adding a new item to it, so we'd want to remove it when Cancel is called.

The overall issue I have is that i can't undo child changes directly, so any undos affect the entire object graph when i dont want them to.

Version and Platform CSLA version: 4.11.2 OS: iOS, Android Platform: Xamarin

kcabral817 commented 5 years ago

Good question.

Get Outlook for Androidhttps://aka.ms/ghei36


From: Jason Soby notifications@github.com Sent: Tuesday, August 6, 2019 11:55:24 AM To: MarimerLLC/cslaforum cslaforum@noreply.github.com Cc: Subscribed subscribed@noreply.github.com Subject: [MarimerLLC/cslaforum] UndoEdit on child list without undoing parent (#789)

Question I'm in somewhat of a sticky situation. In my app, i have the following layout.

-Root: MyItemList ---Child: MyItem -----ChildList: MyChildItemList -------ChildListItem: MyChildItem

Imagine the following scenario

Given that MyChildItemList is a child of MyItem and BeginEdit cannot be called on a child list, how would I Cancel the change to MyChildItemList[0] without undoing the changes to MyItem.Comments as well? To the same point, imagine that instead of editing an existing item in MyChildItemList, we were adding a new item to it, so we'd want to remove it when Cancel is called.

Version and Platform CSLA version: 4.11.2 OS: iOS, Android Platform: Xamarin

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMarimerLLC%2Fcslaforum%2Fissues%2F789%3Femail_source%3Dnotifications%26email_token%3DAGJTVDQYCCI6TN3B25INWJDQDGNGZA5CNFSM4IJX3IF2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HDVQFHA&data=02%7C01%7C%7C43abd1b1b4da4245a10808d71a867e7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637007037250855353&sdata=KOZvyxvkfFdKYDWGe2%2BsXVC%2FquyJCBLSpCwRQxjKA84%3D&reserved=0, or mute the threadhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAGJTVDTPKQLGGHQQIZJMV7LQDGNGZANCNFSM4IJX3IFQ&data=02%7C01%7C%7C43abd1b1b4da4245a10808d71a867e7b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637007037250865358&sdata=1sC0k%2FBiE8SVaCHUtKPocGWkvgtK5WWJQvUA4FdGHHE%3D&reserved=0.

GreatBarrier86 commented 5 years ago

Glad i explained it well enough to make sense. Hopefully there is a good solution.

rockfordlhotka commented 5 years ago

I don't know if there's a good solution.

The n-level undo behavior was designed around Windows Forms and the common UI patterns in use within that framework. Windows Forms really had no way to do some of the more advanced UI concepts that exist today in XAML.

GreatBarrier86 commented 5 years ago

To both @rockfordlhotka and @kcabral817, my thinking that if the CSLA framework doesn't officially support this, then the only thing i can think of is that the MyItemList must not be dirty before the child is added. That way, you can undo the entire object graph and not undo any of the other changes, since they will already have been committed.

Do either of you have any other ideas? I'm not claiming this is ideal, but i'm not sure of a better solution.

For example

Chicagoan2016 commented 5 years ago

@GreatBarrier86 , it appears your root list and child list have different 'undo' requirements. I would create separate root lists, the problem I can see is the current childitemlist might need some value(s) from rootItemlist for 'creation' but that can be taken care of in DataPortal_Create of childitemlist. just my two cents.

GreatBarrier86 commented 5 years ago

@Chicagoan2016, i'm not sure how that helps me. Can you give me an example of how you'd use what you're talking about?

Chicagoan2016 commented 5 years ago

@GreatBarrier86 , I was reading your reply , in the third step you are saving MyItemlist 'independent' of myChildItemlist.

For example

BeginEdit is called on MyItemList User edits MyItem.Comments from ABC to DEF User saves MyItemList, which will call ApplyEdit User edits MyChildItemList[0].Amount from 1.2 to 2.4 User cancels MyChildItemList[0]'s change, calling MyItemList.CancelEdit The only change undone is the child since everything else was committed during step 3.