From bdfc151272bd5d438bc06f57bbba33481a95f355 Mon Sep 17 00:00:00 2001 From: Eike Kettner Date: Sat, 13 Jun 2020 14:40:13 +0200 Subject: [PATCH] Close task form after submitting and return to list view --- .../src/main/elm/Comp/NotificationManage.elm | 28 +++++++++++++------ .../src/main/elm/Comp/ScanMailboxManage.elm | 28 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/modules/webapp/src/main/elm/Comp/NotificationManage.elm b/modules/webapp/src/main/elm/Comp/NotificationManage.elm index f773be86..b0851751 100644 --- a/modules/webapp/src/main/elm/Comp/NotificationManage.elm +++ b/modules/webapp/src/main/elm/Comp/NotificationManage.elm @@ -34,7 +34,7 @@ type Msg | DetailMsg Comp.NotificationForm.Msg | GetDataResp (Result Http.Error NotificationSettingsList) | NewTask - | SubmitResp (Result Http.Error BasicResult) + | SubmitResp Bool (Result Http.Error BasicResult) | DeleteResp (Result Http.Error BasicResult) @@ -121,10 +121,10 @@ update flags msg model = , result = Nothing } , if settings.id == "" then - Api.createNotifyDueItems flags settings SubmitResp + Api.createNotifyDueItems flags settings (SubmitResp True) else - Api.updateNotifyDueItems flags settings SubmitResp + Api.updateNotifyDueItems flags settings (SubmitResp True) ) Comp.NotificationForm.CancelAction -> @@ -140,7 +140,7 @@ update flags msg model = | detailModel = Just mm , result = Nothing } - , Api.startOnceNotifyDueItems flags settings SubmitResp + , Api.startOnceNotifyDueItems flags settings (SubmitResp False) ) Comp.NotificationForm.DeleteAction id -> @@ -168,12 +168,24 @@ update flags msg model = in ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc ) - SubmitResp (Ok res) -> - ( { model | result = Just res } - , Cmd.none + SubmitResp close (Ok res) -> + ( { model + | result = Just res + , detailModel = + if close then + Nothing + + else + model.detailModel + } + , if close then + initCmd flags + + else + Cmd.none ) - SubmitResp (Err err) -> + SubmitResp _ (Err err) -> ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } , Cmd.none ) diff --git a/modules/webapp/src/main/elm/Comp/ScanMailboxManage.elm b/modules/webapp/src/main/elm/Comp/ScanMailboxManage.elm index 164d831a..9bbd854a 100644 --- a/modules/webapp/src/main/elm/Comp/ScanMailboxManage.elm +++ b/modules/webapp/src/main/elm/Comp/ScanMailboxManage.elm @@ -34,7 +34,7 @@ type Msg | DetailMsg Comp.ScanMailboxForm.Msg | GetDataResp (Result Http.Error ScanMailboxSettingsList) | NewTask - | SubmitResp (Result Http.Error BasicResult) + | SubmitResp Bool (Result Http.Error BasicResult) | DeleteResp (Result Http.Error BasicResult) @@ -121,10 +121,10 @@ update flags msg model = , result = Nothing } , if settings.id == "" then - Api.createScanMailbox flags settings SubmitResp + Api.createScanMailbox flags settings (SubmitResp True) else - Api.updateScanMailbox flags settings SubmitResp + Api.updateScanMailbox flags settings (SubmitResp True) ) Comp.ScanMailboxForm.CancelAction -> @@ -140,7 +140,7 @@ update flags msg model = | detailModel = Just mm , result = Nothing } - , Api.startOnceScanMailbox flags settings SubmitResp + , Api.startOnceScanMailbox flags settings (SubmitResp False) ) Comp.ScanMailboxForm.DeleteAction id -> @@ -168,12 +168,24 @@ update flags msg model = in ( { model | detailModel = Just mm }, Cmd.map DetailMsg mc ) - SubmitResp (Ok res) -> - ( { model | result = Just res } - , Cmd.none + SubmitResp close (Ok res) -> + ( { model + | result = Just res + , detailModel = + if close then + Nothing + + else + model.detailModel + } + , if close then + initCmd flags + + else + Cmd.none ) - SubmitResp (Err err) -> + SubmitResp _ (Err err) -> ( { model | result = Just (BasicResult False (Util.Http.errorToString err)) } , Cmd.none )