diff --git a/modules/webapp/src/main/elm/Api.elm b/modules/webapp/src/main/elm/Api.elm index 1e167e5b..d816f551 100644 --- a/modules/webapp/src/main/elm/Api.elm +++ b/modules/webapp/src/main/elm/Api.elm @@ -80,6 +80,7 @@ module Api exposing , login , loginSession , logout + , mergeItems , moveAttachmentBefore , newInvite , postCustomField @@ -1470,6 +1471,20 @@ getJobQueueStateTask flags = --- Item (Mulit Edit) +mergeItems : + Flags + -> List String + -> (Result Http.Error BasicResult -> msg) + -> Cmd msg +mergeItems flags items receive = + Http2.authPost + { url = flags.config.baseUrl ++ "/api/v1/sec/items/merge" + , account = getAccount flags + , body = Http.jsonBody (Api.Model.IdList.encode (IdList items)) + , expect = Http.expectJson receive Api.Model.BasicResult.decoder + } + + reprocessMultiple : Flags -> Set String diff --git a/modules/webapp/src/main/elm/Comp/ItemMerge.elm b/modules/webapp/src/main/elm/Comp/ItemMerge.elm index 5498b5ba..a5ba33e1 100644 --- a/modules/webapp/src/main/elm/Comp/ItemMerge.elm +++ b/modules/webapp/src/main/elm/Comp/ItemMerge.elm @@ -18,6 +18,7 @@ import Api import Api.Model.BasicResult exposing (BasicResult) import Api.Model.ItemLight exposing (ItemLight) import Api.Model.ItemLightList exposing (ItemLightList) +import Comp.Basic import Comp.MenuBar as MB import Data.Direction import Data.Fields @@ -89,6 +90,7 @@ type FormState | FormStateHttp Http.Error | FormStateMergeSuccessful | FormStateError String + | FormStateMergeInProcess @@ -119,8 +121,8 @@ type Msg | MergeResp (Result Http.Error BasicResult) -update : Msg -> Model -> UpdateResult -update msg model = +update : Flags -> Msg -> Model -> UpdateResult +update flags msg model = case msg of ItemResp (Ok list) -> notDoneResult ( init (flatten list), Cmd.none ) @@ -176,7 +178,14 @@ update msg model = notDoneResult ( model_, Cmd.none ) SubmitMerge -> - notDoneResult ( model, Cmd.none ) + let + ids = + List.map .id model.items + in + notDoneResult + ( { model | formState = FormStateMergeInProcess } + , Api.mergeItems flags ids MergeResp + ) CancelMerge -> { model = model @@ -429,7 +438,7 @@ renderFormState texts model = FormStateError msg -> div [ class S.errorMessage - , class "py-2" + , class "my-2" ] [ text msg ] @@ -437,7 +446,7 @@ renderFormState texts model = FormStateHttp err -> div [ class S.errorMessage - , class "py-2" + , class "my-2" ] [ text (texts.httpError err) ] @@ -445,11 +454,17 @@ renderFormState texts model = FormStateMergeSuccessful -> div [ class S.successMessage - , class "py-2" + , class "my-2" ] [ text texts.mergeSuccessful ] + FormStateMergeInProcess -> + Comp.Basic.loadingDimmer + { active = True + , label = texts.mergeInProcess + } + templateCtx : Texts -> IT.TemplateContext templateCtx texts = diff --git a/modules/webapp/src/main/elm/Messages/Comp/ItemMerge.elm b/modules/webapp/src/main/elm/Messages/Comp/ItemMerge.elm index 2aa9d4c5..8d144214 100644 --- a/modules/webapp/src/main/elm/Messages/Comp/ItemMerge.elm +++ b/modules/webapp/src/main/elm/Messages/Comp/ItemMerge.elm @@ -31,6 +31,7 @@ type alias Texts = , submitMergeTitle : String , cancelMergeTitle : String , mergeSuccessful : String + , mergeInProcess : String } @@ -48,6 +49,7 @@ gb = , cancelMerge = "Cancel" , cancelMergeTitle = "Back to select view" , mergeSuccessful = "Items merged successfully" + , mergeInProcess = "Items are merged …" } @@ -65,4 +67,5 @@ de = , cancelMerge = "Abbrechen" , cancelMergeTitle = "Zurück zur Auswahl" , mergeSuccessful = "Die Dokumente wurden erfolgreich zusammengeführt." + , mergeInProcess = "Dokumente werden zusammengeführt…" } diff --git a/modules/webapp/src/main/elm/Page/Home/Update.elm b/modules/webapp/src/main/elm/Page/Home/Update.elm index 15ec2b7c..a47db78b 100644 --- a/modules/webapp/src/main/elm/Page/Home/Update.elm +++ b/modules/webapp/src/main/elm/Page/Home/Update.elm @@ -583,7 +583,7 @@ update mId key flags settings msg model = SelectView svm -> let result = - Comp.ItemMerge.update lmsg svm.mergeModel + Comp.ItemMerge.update flags lmsg svm.mergeModel nextView = if result.done then diff --git a/modules/webapp/src/main/elm/Page/Home/View2.elm b/modules/webapp/src/main/elm/Page/Home/View2.elm index ca287b23..0bf0711a 100644 --- a/modules/webapp/src/main/elm/Page/Home/View2.elm +++ b/modules/webapp/src/main/elm/Page/Home/View2.elm @@ -51,7 +51,7 @@ viewContent texts flags settings model = ] (searchStats texts flags settings model ++ itemsBar texts flags settings model - ++ [ div [ class "relative" ] + ++ [ div [ class "sm:relative" ] (itemMergeView texts settings model ++ itemCardList texts flags settings model ) @@ -72,6 +72,7 @@ itemMergeView texts settings model = MergeSelected -> [ div [ class S.dimmerMerge + , class "mt-10 sm:mt-0" ] [ Html.map MergeItemsMsg (Comp.ItemMerge.view texts.itemMerge settings svm.mergeModel)