From 0301fc6905c2ed982365cdaaf47f5a3b6c9c5c35 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 26 Mar 2020 11:47:18 -0700 Subject: mobile UI: undo partial dive add when canceling When we start adding a dive, we actually create a diveAdd undo command so we have a dive that the user can edit. Which means we need to undo this action if we cancel. Also, for a more consistent UI, we should pop the dive details page that we used to edit this dive and bring the user back to the dive list. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveDetails.qml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index 57ef6c884..b70bb0045 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -260,7 +260,15 @@ Kirigami.Page { } function endEditMode() { - // just cancel the edit/add state + // we need to clean up either an edit or an add - and in case this + // was an add, we need to undo the addDive action that created the empty dive + // and we should also go back to the DiveDetails where we came from... + manager.appendTextToLog("endEditMode called with state " + state) + if (state === "add") { + manager.undo() + pageStack.pop() + } + // now all that is left is to cancel the edit/add state state = "view"; focus = false; Qt.inputMethod.hide(); -- cgit v1.2.3-70-g09d2