Merge items in webui

This commit is contained in:
eikek 2021-08-16 12:55:25 +02:00
parent 85085ec173
commit 8099b78b0e
5 changed files with 42 additions and 8 deletions

View File

@ -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

View File

@ -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 =

View File

@ -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"
}

View File

@ -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

View File

@ -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)