mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-05 22:55:58 +00:00
Allow to add remaining metadata in item edit view
This commit is contained in:
parent
363eb81aff
commit
936177a910
@ -1,5 +1,8 @@
|
|||||||
module Api exposing
|
module Api exposing
|
||||||
( addCorrOrg
|
( addConcEquip
|
||||||
|
, addConcPerson
|
||||||
|
, addCorrOrg
|
||||||
|
, addCorrPerson
|
||||||
, addTag
|
, addTag
|
||||||
, cancelJob
|
, cancelJob
|
||||||
, changePassword
|
, 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 -> String -> OptionalId -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||||
setConcPerson flags item id receive =
|
setConcPerson flags item id receive =
|
||||||
Http2.authPut
|
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 -> String -> OptionalId -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||||
setConcEquip flags item id receive =
|
setConcEquip flags item id receive =
|
||||||
Http2.authPut
|
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 -> String -> OptionalText -> (Result Http.Error BasicResult -> msg) -> Cmd msg
|
||||||
setItemName flags item text receive =
|
setItemName flags item text receive =
|
||||||
Http2.authPut
|
Http2.authPut
|
||||||
|
@ -2,10 +2,10 @@ module Comp.DetailEdit exposing
|
|||||||
( Model
|
( Model
|
||||||
, Msg
|
, Msg
|
||||||
, Value(..)
|
, Value(..)
|
||||||
, fold
|
, initConcPerson
|
||||||
|
, initCorrPerson
|
||||||
, initEquip
|
, initEquip
|
||||||
, initOrg
|
, initOrg
|
||||||
, initPerson
|
|
||||||
, initTag
|
, initTag
|
||||||
, initTagByName
|
, initTagByName
|
||||||
, update
|
, update
|
||||||
@ -50,7 +50,8 @@ type alias Model =
|
|||||||
|
|
||||||
type FormModel
|
type FormModel
|
||||||
= TM Comp.TagForm.Model
|
= TM Comp.TagForm.Model
|
||||||
| PM Comp.PersonForm.Model
|
| PMR Comp.PersonForm.Model
|
||||||
|
| PMC Comp.PersonForm.Model
|
||||||
| OM Comp.OrgForm.Model
|
| OM Comp.OrgForm.Model
|
||||||
| EM Comp.EquipmentForm.Model
|
| EM Comp.EquipmentForm.Model
|
||||||
|
|
||||||
@ -67,7 +68,10 @@ fold ft fp fo fe model =
|
|||||||
TM tm ->
|
TM tm ->
|
||||||
ft tm
|
ft tm
|
||||||
|
|
||||||
PM pm ->
|
PMR pm ->
|
||||||
|
fp pm
|
||||||
|
|
||||||
|
PMC pm ->
|
||||||
fp pm
|
fp pm
|
||||||
|
|
||||||
OM om ->
|
OM om ->
|
||||||
@ -96,9 +100,14 @@ initOrg itemId om =
|
|||||||
init itemId (OM om)
|
init itemId (OM om)
|
||||||
|
|
||||||
|
|
||||||
initPerson : String -> Comp.PersonForm.Model -> Model
|
initCorrPerson : String -> Comp.PersonForm.Model -> Model
|
||||||
initPerson itemId pm =
|
initCorrPerson itemId pm =
|
||||||
init itemId (PM pm)
|
init itemId (PMR pm)
|
||||||
|
|
||||||
|
|
||||||
|
initConcPerson : String -> Comp.PersonForm.Model -> Model
|
||||||
|
initConcPerson itemId pm =
|
||||||
|
init itemId (PMC pm)
|
||||||
|
|
||||||
|
|
||||||
initTag : String -> Comp.TagForm.Model -> Model
|
initTag : String -> Comp.TagForm.Model -> Model
|
||||||
@ -142,7 +151,10 @@ makeValue fm =
|
|||||||
TM tm ->
|
TM tm ->
|
||||||
SubmitTag (Comp.TagForm.getTag tm)
|
SubmitTag (Comp.TagForm.getTag tm)
|
||||||
|
|
||||||
PM pm ->
|
PMR pm ->
|
||||||
|
SubmitPerson (Comp.PersonForm.getPerson pm)
|
||||||
|
|
||||||
|
PMC pm ->
|
||||||
SubmitPerson (Comp.PersonForm.getPerson pm)
|
SubmitPerson (Comp.PersonForm.getPerson pm)
|
||||||
|
|
||||||
OM om ->
|
OM om ->
|
||||||
@ -210,8 +222,47 @@ update flags msg model =
|
|||||||
else
|
else
|
||||||
( model, Cmd.none, Nothing )
|
( model, Cmd.none, Nothing )
|
||||||
|
|
||||||
_ ->
|
PMC pm ->
|
||||||
Debug.todo "implement"
|
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 ->
|
TagMsg lm ->
|
||||||
case model.form of
|
case model.form of
|
||||||
@ -230,12 +281,22 @@ update flags msg model =
|
|||||||
|
|
||||||
PersonMsg lm ->
|
PersonMsg lm ->
|
||||||
case model.form of
|
case model.form of
|
||||||
PM pm ->
|
PMR pm ->
|
||||||
let
|
let
|
||||||
( pm_, pc_ ) =
|
( pm_, pc_ ) =
|
||||||
Comp.PersonForm.update flags lm pm
|
Comp.PersonForm.update flags lm pm
|
||||||
in
|
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_
|
, Cmd.map PersonMsg pc_
|
||||||
, Nothing
|
, Nothing
|
||||||
)
|
)
|
||||||
@ -285,7 +346,10 @@ view settings model =
|
|||||||
TM tm ->
|
TM tm ->
|
||||||
Html.map TagMsg (Comp.TagForm.view 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)
|
Html.map PersonMsg (Comp.PersonForm.view settings pm)
|
||||||
|
|
||||||
OM om ->
|
OM om ->
|
||||||
|
@ -28,9 +28,11 @@ import Comp.DatePicker
|
|||||||
import Comp.DetailEdit
|
import Comp.DetailEdit
|
||||||
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
||||||
import Comp.Dropzone
|
import Comp.Dropzone
|
||||||
|
import Comp.EquipmentForm
|
||||||
import Comp.ItemMail
|
import Comp.ItemMail
|
||||||
import Comp.MarkdownInput
|
import Comp.MarkdownInput
|
||||||
import Comp.OrgForm
|
import Comp.OrgForm
|
||||||
|
import Comp.PersonForm
|
||||||
import Comp.SentMails
|
import Comp.SentMails
|
||||||
import Comp.YesNoDimmer
|
import Comp.YesNoDimmer
|
||||||
import Data.Direction exposing (Direction)
|
import Data.Direction exposing (Direction)
|
||||||
@ -249,6 +251,9 @@ type Msg
|
|||||||
| ModalEditMsg Comp.DetailEdit.Msg
|
| ModalEditMsg Comp.DetailEdit.Msg
|
||||||
| StartTagModal
|
| StartTagModal
|
||||||
| StartCorrOrgModal
|
| StartCorrOrgModal
|
||||||
|
| StartCorrPersonModal
|
||||||
|
| StartConcPersonModal
|
||||||
|
| StartEquipModal
|
||||||
| CloseModal
|
| CloseModal
|
||||||
|
|
||||||
|
|
||||||
@ -1245,7 +1250,51 @@ update key flags next msg model =
|
|||||||
StartCorrOrgModal ->
|
StartCorrOrgModal ->
|
||||||
noSub
|
noSub
|
||||||
( { model
|
( { 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
|
, Cmd.none
|
||||||
)
|
)
|
||||||
@ -1874,14 +1923,12 @@ renderEditForm settings model =
|
|||||||
[ label []
|
[ label []
|
||||||
[ Icons.tagsIcon
|
[ Icons.tagsIcon
|
||||||
, text "Tags"
|
, text "Tags"
|
||||||
, span [ class "right-float" ]
|
, a
|
||||||
[ a
|
[ class "right-float"
|
||||||
[ class "icon link"
|
, href "#"
|
||||||
, href "#"
|
, onClick StartTagModal
|
||||||
, onClick StartTagModal
|
]
|
||||||
]
|
[ i [ class "add link icon" ] []
|
||||||
[ i [ class "add link icon" ] []
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
|
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
|
||||||
@ -1963,6 +2010,13 @@ renderEditForm settings model =
|
|||||||
[ label []
|
[ label []
|
||||||
[ Icons.personIcon
|
[ Icons.personIcon
|
||||||
, text "Person"
|
, text "Person"
|
||||||
|
, a
|
||||||
|
[ class "right-float"
|
||||||
|
, href "#"
|
||||||
|
, onClick StartCorrPersonModal
|
||||||
|
]
|
||||||
|
[ i [ class "add link icon" ] []
|
||||||
|
]
|
||||||
]
|
]
|
||||||
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
||||||
, renderCorrPersonSuggestions model
|
, renderCorrPersonSuggestions model
|
||||||
@ -1975,6 +2029,13 @@ renderEditForm settings model =
|
|||||||
[ label []
|
[ label []
|
||||||
[ Icons.personIcon
|
[ Icons.personIcon
|
||||||
, text "Person"
|
, text "Person"
|
||||||
|
, a
|
||||||
|
[ class "right-float"
|
||||||
|
, href "#"
|
||||||
|
, onClick StartConcPersonModal
|
||||||
|
]
|
||||||
|
[ i [ class "add link icon" ] []
|
||||||
|
]
|
||||||
]
|
]
|
||||||
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
||||||
, renderConcPersonSuggestions model
|
, renderConcPersonSuggestions model
|
||||||
@ -1983,6 +2044,13 @@ renderEditForm settings model =
|
|||||||
[ label []
|
[ label []
|
||||||
[ Icons.equipmentIcon
|
[ Icons.equipmentIcon
|
||||||
, text "Equipment"
|
, text "Equipment"
|
||||||
|
, a
|
||||||
|
[ class "right-float"
|
||||||
|
, href "#"
|
||||||
|
, onClick StartEquipModal
|
||||||
|
]
|
||||||
|
[ i [ class "add link icon" ] []
|
||||||
|
]
|
||||||
]
|
]
|
||||||
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
||||||
, renderConcEquipSuggestions model
|
, renderConcEquipSuggestions model
|
||||||
|
Loading…
x
Reference in New Issue
Block a user