mirror of
				https://github.com/TheAnachronism/docspell.git
				synced 2025-11-03 18:00:11 +00:00 
			
		
		
		
	Allow to add remaining metadata in item edit view
This commit is contained in:
		@@ -1,5 +1,8 @@
 | 
			
		||||
module Api exposing
 | 
			
		||||
    ( addCorrOrg
 | 
			
		||||
    ( addConcEquip
 | 
			
		||||
    , addConcPerson
 | 
			
		||||
    , addCorrOrg
 | 
			
		||||
    , addCorrPerson
 | 
			
		||||
    , addTag
 | 
			
		||||
    , cancelJob
 | 
			
		||||
    , changePassword
 | 
			
		||||
@@ -1107,6 +1110,16 @@ setCorrPerson flags item id receive =
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
addCorrPerson : Flags -> String -> Person -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
addCorrPerson flags item person receive =
 | 
			
		||||
    Http2.authPost
 | 
			
		||||
        { url = flags.config.baseUrl ++ "/api/v1/sec/item/" ++ item ++ "/corrPerson"
 | 
			
		||||
        , account = getAccount flags
 | 
			
		||||
        , body = Http.jsonBody (Api.Model.Person.encode person)
 | 
			
		||||
        , expect = Http.expectJson receive Api.Model.BasicResult.decoder
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
setConcPerson : Flags -> String -> OptionalId -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
setConcPerson flags item id receive =
 | 
			
		||||
    Http2.authPut
 | 
			
		||||
@@ -1117,6 +1130,16 @@ setConcPerson flags item id receive =
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
addConcPerson : Flags -> String -> Person -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
addConcPerson flags item person receive =
 | 
			
		||||
    Http2.authPost
 | 
			
		||||
        { url = flags.config.baseUrl ++ "/api/v1/sec/item/" ++ item ++ "/concPerson"
 | 
			
		||||
        , account = getAccount flags
 | 
			
		||||
        , body = Http.jsonBody (Api.Model.Person.encode person)
 | 
			
		||||
        , expect = Http.expectJson receive Api.Model.BasicResult.decoder
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
setConcEquip : Flags -> String -> OptionalId -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
setConcEquip flags item id receive =
 | 
			
		||||
    Http2.authPut
 | 
			
		||||
@@ -1127,6 +1150,16 @@ setConcEquip flags item id receive =
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
addConcEquip : Flags -> String -> Equipment -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
addConcEquip flags item equip receive =
 | 
			
		||||
    Http2.authPost
 | 
			
		||||
        { url = flags.config.baseUrl ++ "/api/v1/sec/item/" ++ item ++ "/concEquipment"
 | 
			
		||||
        , account = getAccount flags
 | 
			
		||||
        , body = Http.jsonBody (Api.Model.Equipment.encode equip)
 | 
			
		||||
        , expect = Http.expectJson receive Api.Model.BasicResult.decoder
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
setItemName : Flags -> String -> OptionalText -> (Result Http.Error BasicResult -> msg) -> Cmd msg
 | 
			
		||||
setItemName flags item text receive =
 | 
			
		||||
    Http2.authPut
 | 
			
		||||
 
 | 
			
		||||
@@ -2,10 +2,10 @@ module Comp.DetailEdit exposing
 | 
			
		||||
    ( Model
 | 
			
		||||
    , Msg
 | 
			
		||||
    , Value(..)
 | 
			
		||||
    , fold
 | 
			
		||||
    , initConcPerson
 | 
			
		||||
    , initCorrPerson
 | 
			
		||||
    , initEquip
 | 
			
		||||
    , initOrg
 | 
			
		||||
    , initPerson
 | 
			
		||||
    , initTag
 | 
			
		||||
    , initTagByName
 | 
			
		||||
    , update
 | 
			
		||||
@@ -50,7 +50,8 @@ type alias Model =
 | 
			
		||||
 | 
			
		||||
type FormModel
 | 
			
		||||
    = TM Comp.TagForm.Model
 | 
			
		||||
    | PM Comp.PersonForm.Model
 | 
			
		||||
    | PMR Comp.PersonForm.Model
 | 
			
		||||
    | PMC Comp.PersonForm.Model
 | 
			
		||||
    | OM Comp.OrgForm.Model
 | 
			
		||||
    | EM Comp.EquipmentForm.Model
 | 
			
		||||
 | 
			
		||||
@@ -67,7 +68,10 @@ fold ft fp fo fe model =
 | 
			
		||||
        TM tm ->
 | 
			
		||||
            ft tm
 | 
			
		||||
 | 
			
		||||
        PM pm ->
 | 
			
		||||
        PMR pm ->
 | 
			
		||||
            fp pm
 | 
			
		||||
 | 
			
		||||
        PMC pm ->
 | 
			
		||||
            fp pm
 | 
			
		||||
 | 
			
		||||
        OM om ->
 | 
			
		||||
@@ -96,9 +100,14 @@ initOrg itemId om =
 | 
			
		||||
    init itemId (OM om)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initPerson : String -> Comp.PersonForm.Model -> Model
 | 
			
		||||
initPerson itemId pm =
 | 
			
		||||
    init itemId (PM pm)
 | 
			
		||||
initCorrPerson : String -> Comp.PersonForm.Model -> Model
 | 
			
		||||
initCorrPerson itemId pm =
 | 
			
		||||
    init itemId (PMR pm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initConcPerson : String -> Comp.PersonForm.Model -> Model
 | 
			
		||||
initConcPerson itemId pm =
 | 
			
		||||
    init itemId (PMC pm)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
initTag : String -> Comp.TagForm.Model -> Model
 | 
			
		||||
@@ -142,7 +151,10 @@ makeValue fm =
 | 
			
		||||
        TM tm ->
 | 
			
		||||
            SubmitTag (Comp.TagForm.getTag tm)
 | 
			
		||||
 | 
			
		||||
        PM pm ->
 | 
			
		||||
        PMR pm ->
 | 
			
		||||
            SubmitPerson (Comp.PersonForm.getPerson pm)
 | 
			
		||||
 | 
			
		||||
        PMC pm ->
 | 
			
		||||
            SubmitPerson (Comp.PersonForm.getPerson pm)
 | 
			
		||||
 | 
			
		||||
        OM om ->
 | 
			
		||||
@@ -210,8 +222,47 @@ update flags msg model =
 | 
			
		||||
                    else
 | 
			
		||||
                        ( model, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
                _ ->
 | 
			
		||||
                    Debug.todo "implement"
 | 
			
		||||
                PMC pm ->
 | 
			
		||||
                    let
 | 
			
		||||
                        pers =
 | 
			
		||||
                            Comp.PersonForm.getPerson pm
 | 
			
		||||
                    in
 | 
			
		||||
                    if Comp.PersonForm.isValid pm then
 | 
			
		||||
                        ( { model | submitting = True }
 | 
			
		||||
                        , Api.addConcPerson flags model.itemId pers SubmitResp
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( model, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
                PMR pm ->
 | 
			
		||||
                    let
 | 
			
		||||
                        pers =
 | 
			
		||||
                            Comp.PersonForm.getPerson pm
 | 
			
		||||
                    in
 | 
			
		||||
                    if Comp.PersonForm.isValid pm then
 | 
			
		||||
                        ( { model | submitting = True }
 | 
			
		||||
                        , Api.addCorrPerson flags model.itemId pers SubmitResp
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( model, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
                EM em ->
 | 
			
		||||
                    let
 | 
			
		||||
                        equip =
 | 
			
		||||
                            Comp.EquipmentForm.getEquipment em
 | 
			
		||||
                    in
 | 
			
		||||
                    if Comp.EquipmentForm.isValid em then
 | 
			
		||||
                        ( { model | submitting = True }
 | 
			
		||||
                        , Api.addConcEquip flags model.itemId equip SubmitResp
 | 
			
		||||
                        , Nothing
 | 
			
		||||
                        )
 | 
			
		||||
 | 
			
		||||
                    else
 | 
			
		||||
                        ( model, Cmd.none, Nothing )
 | 
			
		||||
 | 
			
		||||
        TagMsg lm ->
 | 
			
		||||
            case model.form of
 | 
			
		||||
@@ -230,12 +281,22 @@ update flags msg model =
 | 
			
		||||
 | 
			
		||||
        PersonMsg lm ->
 | 
			
		||||
            case model.form of
 | 
			
		||||
                PM pm ->
 | 
			
		||||
                PMR pm ->
 | 
			
		||||
                    let
 | 
			
		||||
                        ( pm_, pc_ ) =
 | 
			
		||||
                            Comp.PersonForm.update flags lm pm
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model | form = PM pm_ }
 | 
			
		||||
                    ( { model | form = PMR pm_ }
 | 
			
		||||
                    , Cmd.map PersonMsg pc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
                    )
 | 
			
		||||
 | 
			
		||||
                PMC pm ->
 | 
			
		||||
                    let
 | 
			
		||||
                        ( pm_, pc_ ) =
 | 
			
		||||
                            Comp.PersonForm.update flags lm pm
 | 
			
		||||
                    in
 | 
			
		||||
                    ( { model | form = PMC pm_ }
 | 
			
		||||
                    , Cmd.map PersonMsg pc_
 | 
			
		||||
                    , Nothing
 | 
			
		||||
                    )
 | 
			
		||||
@@ -285,7 +346,10 @@ view settings model =
 | 
			
		||||
            TM tm ->
 | 
			
		||||
                Html.map TagMsg (Comp.TagForm.view tm)
 | 
			
		||||
 | 
			
		||||
            PM pm ->
 | 
			
		||||
            PMR pm ->
 | 
			
		||||
                Html.map PersonMsg (Comp.PersonForm.view settings pm)
 | 
			
		||||
 | 
			
		||||
            PMC pm ->
 | 
			
		||||
                Html.map PersonMsg (Comp.PersonForm.view settings pm)
 | 
			
		||||
 | 
			
		||||
            OM om ->
 | 
			
		||||
 
 | 
			
		||||
@@ -28,9 +28,11 @@ import Comp.DatePicker
 | 
			
		||||
import Comp.DetailEdit
 | 
			
		||||
import Comp.Dropdown exposing (isDropdownChangeMsg)
 | 
			
		||||
import Comp.Dropzone
 | 
			
		||||
import Comp.EquipmentForm
 | 
			
		||||
import Comp.ItemMail
 | 
			
		||||
import Comp.MarkdownInput
 | 
			
		||||
import Comp.OrgForm
 | 
			
		||||
import Comp.PersonForm
 | 
			
		||||
import Comp.SentMails
 | 
			
		||||
import Comp.YesNoDimmer
 | 
			
		||||
import Data.Direction exposing (Direction)
 | 
			
		||||
@@ -249,6 +251,9 @@ type Msg
 | 
			
		||||
    | ModalEditMsg Comp.DetailEdit.Msg
 | 
			
		||||
    | StartTagModal
 | 
			
		||||
    | StartCorrOrgModal
 | 
			
		||||
    | StartCorrPersonModal
 | 
			
		||||
    | StartConcPersonModal
 | 
			
		||||
    | StartEquipModal
 | 
			
		||||
    | CloseModal
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -1245,7 +1250,51 @@ update key flags next msg model =
 | 
			
		||||
        StartCorrOrgModal ->
 | 
			
		||||
            noSub
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | modalEdit = Just (Comp.DetailEdit.initOrg model.item.id Comp.OrgForm.emptyModel)
 | 
			
		||||
                    | modalEdit =
 | 
			
		||||
                        Just
 | 
			
		||||
                            (Comp.DetailEdit.initOrg
 | 
			
		||||
                                model.item.id
 | 
			
		||||
                                Comp.OrgForm.emptyModel
 | 
			
		||||
                            )
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        StartCorrPersonModal ->
 | 
			
		||||
            noSub
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | modalEdit =
 | 
			
		||||
                        Just
 | 
			
		||||
                            (Comp.DetailEdit.initCorrPerson
 | 
			
		||||
                                model.item.id
 | 
			
		||||
                                Comp.PersonForm.emptyModel
 | 
			
		||||
                            )
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        StartConcPersonModal ->
 | 
			
		||||
            noSub
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | modalEdit =
 | 
			
		||||
                        Just
 | 
			
		||||
                            (Comp.DetailEdit.initConcPerson
 | 
			
		||||
                                model.item.id
 | 
			
		||||
                                Comp.PersonForm.emptyModel
 | 
			
		||||
                            )
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
 | 
			
		||||
        StartEquipModal ->
 | 
			
		||||
            noSub
 | 
			
		||||
                ( { model
 | 
			
		||||
                    | modalEdit =
 | 
			
		||||
                        Just
 | 
			
		||||
                            (Comp.DetailEdit.initEquip
 | 
			
		||||
                                model.item.id
 | 
			
		||||
                                Comp.EquipmentForm.emptyModel
 | 
			
		||||
                            )
 | 
			
		||||
                  }
 | 
			
		||||
                , Cmd.none
 | 
			
		||||
                )
 | 
			
		||||
@@ -1874,14 +1923,12 @@ renderEditForm settings model =
 | 
			
		||||
                [ label []
 | 
			
		||||
                    [ Icons.tagsIcon
 | 
			
		||||
                    , text "Tags"
 | 
			
		||||
                    , span [ class "right-float" ]
 | 
			
		||||
                        [ a
 | 
			
		||||
                            [ class "icon link"
 | 
			
		||||
                            , href "#"
 | 
			
		||||
                            , onClick StartTagModal
 | 
			
		||||
                            ]
 | 
			
		||||
                            [ i [ class "add link icon" ] []
 | 
			
		||||
                            ]
 | 
			
		||||
                    , a
 | 
			
		||||
                        [ class "right-float"
 | 
			
		||||
                        , href "#"
 | 
			
		||||
                        , onClick StartTagModal
 | 
			
		||||
                        ]
 | 
			
		||||
                        [ i [ class "add link icon" ] []
 | 
			
		||||
                        ]
 | 
			
		||||
                    ]
 | 
			
		||||
                , Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
 | 
			
		||||
@@ -1963,6 +2010,13 @@ renderEditForm settings model =
 | 
			
		||||
                [ label []
 | 
			
		||||
                    [ Icons.personIcon
 | 
			
		||||
                    , text "Person"
 | 
			
		||||
                    , a
 | 
			
		||||
                        [ class "right-float"
 | 
			
		||||
                        , href "#"
 | 
			
		||||
                        , onClick StartCorrPersonModal
 | 
			
		||||
                        ]
 | 
			
		||||
                        [ i [ class "add link icon" ] []
 | 
			
		||||
                        ]
 | 
			
		||||
                    ]
 | 
			
		||||
                , Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
 | 
			
		||||
                , renderCorrPersonSuggestions model
 | 
			
		||||
@@ -1975,6 +2029,13 @@ renderEditForm settings model =
 | 
			
		||||
                [ label []
 | 
			
		||||
                    [ Icons.personIcon
 | 
			
		||||
                    , text "Person"
 | 
			
		||||
                    , a
 | 
			
		||||
                        [ class "right-float"
 | 
			
		||||
                        , href "#"
 | 
			
		||||
                        , onClick StartConcPersonModal
 | 
			
		||||
                        ]
 | 
			
		||||
                        [ i [ class "add link icon" ] []
 | 
			
		||||
                        ]
 | 
			
		||||
                    ]
 | 
			
		||||
                , Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
 | 
			
		||||
                , renderConcPersonSuggestions model
 | 
			
		||||
@@ -1983,6 +2044,13 @@ renderEditForm settings model =
 | 
			
		||||
                [ label []
 | 
			
		||||
                    [ Icons.equipmentIcon
 | 
			
		||||
                    , text "Equipment"
 | 
			
		||||
                    , a
 | 
			
		||||
                        [ class "right-float"
 | 
			
		||||
                        , href "#"
 | 
			
		||||
                        , onClick StartEquipModal
 | 
			
		||||
                        ]
 | 
			
		||||
                        [ i [ class "add link icon" ] []
 | 
			
		||||
                        ]
 | 
			
		||||
                    ]
 | 
			
		||||
                , Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
 | 
			
		||||
                , renderConcEquipSuggestions model
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user