mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-06 07:05:59 +00:00
Add custom fields to multi-edit form
This commit is contained in:
parent
76647d132f
commit
ff30ed5558
@ -21,6 +21,7 @@ module Api exposing
|
|||||||
, deleteAttachment
|
, deleteAttachment
|
||||||
, deleteCustomField
|
, deleteCustomField
|
||||||
, deleteCustomValue
|
, deleteCustomValue
|
||||||
|
, deleteCustomValueMultiple
|
||||||
, deleteEquip
|
, deleteEquip
|
||||||
, deleteFolder
|
, deleteFolder
|
||||||
, deleteImapSettings
|
, deleteImapSettings
|
||||||
@ -80,6 +81,7 @@ module Api exposing
|
|||||||
, postTag
|
, postTag
|
||||||
, putCustomField
|
, putCustomField
|
||||||
, putCustomValue
|
, putCustomValue
|
||||||
|
, putCustomValueMultiple
|
||||||
, putUser
|
, putUser
|
||||||
, refreshSession
|
, refreshSession
|
||||||
, register
|
, register
|
||||||
@ -159,6 +161,7 @@ import Api.Model.ItemSearch exposing (ItemSearch)
|
|||||||
import Api.Model.ItemUploadMeta exposing (ItemUploadMeta)
|
import Api.Model.ItemUploadMeta exposing (ItemUploadMeta)
|
||||||
import Api.Model.ItemsAndDate exposing (ItemsAndDate)
|
import Api.Model.ItemsAndDate exposing (ItemsAndDate)
|
||||||
import Api.Model.ItemsAndDirection exposing (ItemsAndDirection)
|
import Api.Model.ItemsAndDirection exposing (ItemsAndDirection)
|
||||||
|
import Api.Model.ItemsAndFieldValue exposing (ItemsAndFieldValue)
|
||||||
import Api.Model.ItemsAndName exposing (ItemsAndName)
|
import Api.Model.ItemsAndName exposing (ItemsAndName)
|
||||||
import Api.Model.ItemsAndRef exposing (ItemsAndRef)
|
import Api.Model.ItemsAndRef exposing (ItemsAndRef)
|
||||||
import Api.Model.ItemsAndRefs exposing (ItemsAndRefs)
|
import Api.Model.ItemsAndRefs exposing (ItemsAndRefs)
|
||||||
@ -211,6 +214,34 @@ import Util.Http as Http2
|
|||||||
--- Custom Fields
|
--- Custom Fields
|
||||||
|
|
||||||
|
|
||||||
|
putCustomValueMultiple :
|
||||||
|
Flags
|
||||||
|
-> ItemsAndFieldValue
|
||||||
|
-> (Result Http.Error BasicResult -> msg)
|
||||||
|
-> Cmd msg
|
||||||
|
putCustomValueMultiple flags data receive =
|
||||||
|
Http2.authPut
|
||||||
|
{ url = flags.config.baseUrl ++ "/api/v1/sec/items/customfield"
|
||||||
|
, account = getAccount flags
|
||||||
|
, body = Http.jsonBody (Api.Model.ItemsAndFieldValue.encode data)
|
||||||
|
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
deleteCustomValueMultiple :
|
||||||
|
Flags
|
||||||
|
-> ItemsAndName
|
||||||
|
-> (Result Http.Error BasicResult -> msg)
|
||||||
|
-> Cmd msg
|
||||||
|
deleteCustomValueMultiple flags data receive =
|
||||||
|
Http2.authPost
|
||||||
|
{ url = flags.config.baseUrl ++ "/api/v1/sec/items/customfieldremove"
|
||||||
|
, account = getAccount flags
|
||||||
|
, body = Http.jsonBody (Api.Model.ItemsAndName.encode data)
|
||||||
|
, expect = Http.expectJson receive Api.Model.BasicResult.decoder
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
deleteCustomValue :
|
deleteCustomValue :
|
||||||
Flags
|
Flags
|
||||||
-> String
|
-> String
|
||||||
|
@ -3,6 +3,7 @@ module Comp.CustomFieldMultiInput exposing
|
|||||||
, Model
|
, Model
|
||||||
, Msg
|
, Msg
|
||||||
, UpdateResult
|
, UpdateResult
|
||||||
|
, ViewSettings
|
||||||
, init
|
, init
|
||||||
, initCmd
|
, initCmd
|
||||||
, initWith
|
, initWith
|
||||||
@ -287,25 +288,46 @@ update msg model =
|
|||||||
UpdateResult model_ (Cmd.batch cmdList) Sub.none NoResult
|
UpdateResult model_ (Cmd.batch cmdList) Sub.none NoResult
|
||||||
|
|
||||||
|
|
||||||
view : String -> Model -> Html Msg
|
|
||||||
view classes model =
|
--- View
|
||||||
div [ class classes ]
|
|
||||||
(viewMenuBar model
|
|
||||||
|
type alias ViewSettings =
|
||||||
|
{ showAddButton : Bool
|
||||||
|
, classes : String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
view : ViewSettings -> Model -> Html Msg
|
||||||
|
view viewSettings model =
|
||||||
|
div [ class viewSettings.classes ]
|
||||||
|
(viewMenuBar viewSettings model
|
||||||
:: List.map (viewCustomField model) model.visibleFields
|
:: List.map (viewCustomField model) model.visibleFields
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
viewMenuBar : Model -> Html Msg
|
viewMenuBar : ViewSettings -> Model -> Html Msg
|
||||||
viewMenuBar model =
|
viewMenuBar viewSettings model =
|
||||||
let
|
let
|
||||||
{ dropdown, selected } =
|
{ dropdown, selected } =
|
||||||
model.fieldSelect
|
model.fieldSelect
|
||||||
in
|
in
|
||||||
div [ class "ui action input field" ]
|
div
|
||||||
[ Html.map FieldSelectMsg
|
[ classList
|
||||||
(Comp.FixedDropdown.viewStyled "fluid" (Maybe.map mkItem selected) dropdown)
|
[ ( "field", True )
|
||||||
, addFieldLink "" model
|
, ( "ui action input", viewSettings.showAddButton )
|
||||||
|
]
|
||||||
]
|
]
|
||||||
|
(Html.map FieldSelectMsg
|
||||||
|
(Comp.FixedDropdown.viewStyled "fluid" (Maybe.map mkItem selected) dropdown)
|
||||||
|
:: (if viewSettings.showAddButton then
|
||||||
|
[ addFieldLink "" model
|
||||||
|
]
|
||||||
|
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
viewCustomField : Model -> CustomField -> Html Msg
|
viewCustomField : Model -> CustomField -> Html Msg
|
||||||
|
@ -18,6 +18,7 @@ import Api.Model.ItemProposals exposing (ItemProposals)
|
|||||||
import Api.Model.ReferenceList exposing (ReferenceList)
|
import Api.Model.ReferenceList exposing (ReferenceList)
|
||||||
import Api.Model.Tag exposing (Tag)
|
import Api.Model.Tag exposing (Tag)
|
||||||
import Api.Model.TagList exposing (TagList)
|
import Api.Model.TagList exposing (TagList)
|
||||||
|
import Comp.CustomFieldMultiInput exposing (FieldResult(..))
|
||||||
import Comp.DatePicker
|
import Comp.DatePicker
|
||||||
import Comp.DetailEdit
|
import Comp.DetailEdit
|
||||||
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
import Comp.Dropdown exposing (isDropdownChangeMsg)
|
||||||
@ -77,6 +78,7 @@ type alias Model =
|
|||||||
, concEquipModel : Comp.Dropdown.Model IdName
|
, concEquipModel : Comp.Dropdown.Model IdName
|
||||||
, modalEdit : Maybe Comp.DetailEdit.Model
|
, modalEdit : Maybe Comp.DetailEdit.Model
|
||||||
, tagEditMode : TagEditMode
|
, tagEditMode : TagEditMode
|
||||||
|
, customFieldModel : Comp.CustomFieldMultiInput.Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -102,6 +104,7 @@ type Msg
|
|||||||
| GetPersonResp (Result Http.Error ReferenceList)
|
| GetPersonResp (Result Http.Error ReferenceList)
|
||||||
| GetEquipResp (Result Http.Error EquipmentList)
|
| GetEquipResp (Result Http.Error EquipmentList)
|
||||||
| GetFolderResp (Result Http.Error FolderList)
|
| GetFolderResp (Result Http.Error FolderList)
|
||||||
|
| CustomFieldMsg Comp.CustomFieldMultiInput.Msg
|
||||||
|
|
||||||
|
|
||||||
init : Model
|
init : Model
|
||||||
@ -155,6 +158,7 @@ init =
|
|||||||
, dueDatePicker = Comp.DatePicker.emptyModel
|
, dueDatePicker = Comp.DatePicker.emptyModel
|
||||||
, modalEdit = Nothing
|
, modalEdit = Nothing
|
||||||
, tagEditMode = AddTags
|
, tagEditMode = AddTags
|
||||||
|
, customFieldModel = Comp.CustomFieldMultiInput.initWith []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -170,6 +174,7 @@ loadModel flags =
|
|||||||
, Api.getPersonsLight flags GetPersonResp
|
, Api.getPersonsLight flags GetPersonResp
|
||||||
, Api.getEquipments flags "" GetEquipResp
|
, Api.getEquipments flags "" GetEquipResp
|
||||||
, Api.getFolders flags "" False GetFolderResp
|
, Api.getFolders flags "" False GetFolderResp
|
||||||
|
, Cmd.map CustomFieldMsg (Comp.CustomFieldMultiInput.initCmd flags)
|
||||||
, Cmd.map ItemDatePickerMsg dpc
|
, Cmd.map ItemDatePickerMsg dpc
|
||||||
, Cmd.map DueDatePickerMsg dpc
|
, Cmd.map DueDatePickerMsg dpc
|
||||||
]
|
]
|
||||||
@ -547,6 +552,36 @@ update flags msg model =
|
|||||||
in
|
in
|
||||||
UpdateResult newModel cmd sub NoFormChange
|
UpdateResult newModel cmd sub NoFormChange
|
||||||
|
|
||||||
|
CustomFieldMsg lm ->
|
||||||
|
let
|
||||||
|
res =
|
||||||
|
Comp.CustomFieldMultiInput.update lm model.customFieldModel
|
||||||
|
|
||||||
|
model_ =
|
||||||
|
{ model | customFieldModel = res.model }
|
||||||
|
|
||||||
|
cmd_ =
|
||||||
|
Cmd.map CustomFieldMsg res.cmd
|
||||||
|
|
||||||
|
sub_ =
|
||||||
|
Sub.map CustomFieldMsg res.subs
|
||||||
|
|
||||||
|
change =
|
||||||
|
case res.result of
|
||||||
|
NoResult ->
|
||||||
|
NoFormChange
|
||||||
|
|
||||||
|
FieldValueRemove cf ->
|
||||||
|
RemoveCustomValue cf
|
||||||
|
|
||||||
|
FieldValueChange cf value ->
|
||||||
|
CustomValueChange cf value
|
||||||
|
|
||||||
|
FieldCreateNew ->
|
||||||
|
NoFormChange
|
||||||
|
in
|
||||||
|
UpdateResult model_ cmd_ sub_ change
|
||||||
|
|
||||||
|
|
||||||
nameThrottleSub : Model -> Sub Msg
|
nameThrottleSub : Model -> Sub Msg
|
||||||
nameThrottleSub model =
|
nameThrottleSub model =
|
||||||
@ -614,6 +649,9 @@ renderEditForm cfg settings model =
|
|||||||
|
|
||||||
ReplaceTags ->
|
ReplaceTags ->
|
||||||
"Tags chosen here *replace* those on selected items."
|
"Tags chosen here *replace* those on selected items."
|
||||||
|
|
||||||
|
customFieldSettings =
|
||||||
|
Comp.CustomFieldMultiInput.ViewSettings False "field"
|
||||||
in
|
in
|
||||||
div [ class cfg.menuClass ]
|
div [ class cfg.menuClass ]
|
||||||
[ div [ class "ui form warning" ]
|
[ div [ class "ui form warning" ]
|
||||||
@ -687,13 +725,18 @@ item visible. This message will disappear then.
|
|||||||
"""
|
"""
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, optional [ Data.Fields.Direction ] <|
|
, optional [ Data.Fields.CustomFields ] <|
|
||||||
div [ class "field" ]
|
h4 [ class "ui dividing header" ]
|
||||||
[ label []
|
[ Icons.customFieldIcon ""
|
||||||
[ Icons.directionIcon "grey"
|
, text "Custom Fields"
|
||||||
, text "Direction"
|
]
|
||||||
]
|
, optional [ Data.Fields.CustomFields ] <|
|
||||||
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
|
Html.map CustomFieldMsg
|
||||||
|
(Comp.CustomFieldMultiInput.view customFieldSettings model.customFieldModel)
|
||||||
|
, optional [ Data.Fields.Date, Data.Fields.DueDate ] <|
|
||||||
|
h4 [ class "ui dividing header" ]
|
||||||
|
[ Icons.itemDatesIcon ""
|
||||||
|
, text "Item Dates"
|
||||||
]
|
]
|
||||||
, optional [ Data.Fields.Date ] <|
|
, optional [ Data.Fields.Date ] <|
|
||||||
div [ class "field" ]
|
div [ class "field" ]
|
||||||
@ -701,7 +744,7 @@ item visible. This message will disappear then.
|
|||||||
[ Icons.dateIcon "grey"
|
[ Icons.dateIcon "grey"
|
||||||
, text "Date"
|
, text "Date"
|
||||||
]
|
]
|
||||||
, div [ class "ui action input" ]
|
, div [ class "ui left icon action input" ]
|
||||||
[ Html.map ItemDatePickerMsg
|
[ Html.map ItemDatePickerMsg
|
||||||
(Comp.DatePicker.viewTime
|
(Comp.DatePicker.viewTime
|
||||||
model.itemDate
|
model.itemDate
|
||||||
@ -711,6 +754,7 @@ item visible. This message will disappear then.
|
|||||||
, a [ class "ui icon button", href "", onClick RemoveDate ]
|
, a [ class "ui icon button", href "", onClick RemoveDate ]
|
||||||
[ i [ class "trash alternate outline icon" ] []
|
[ i [ class "trash alternate outline icon" ] []
|
||||||
]
|
]
|
||||||
|
, Icons.dateIcon ""
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, optional [ Data.Fields.DueDate ] <|
|
, optional [ Data.Fields.DueDate ] <|
|
||||||
@ -719,7 +763,7 @@ item visible. This message will disappear then.
|
|||||||
[ Icons.dueDateIcon "grey"
|
[ Icons.dueDateIcon "grey"
|
||||||
, text "Due Date"
|
, text "Due Date"
|
||||||
]
|
]
|
||||||
, div [ class "ui action input" ]
|
, div [ class "ui left icon action input" ]
|
||||||
[ Html.map DueDatePickerMsg
|
[ Html.map DueDatePickerMsg
|
||||||
(Comp.DatePicker.viewTime
|
(Comp.DatePicker.viewTime
|
||||||
model.dueDate
|
model.dueDate
|
||||||
@ -728,6 +772,7 @@ item visible. This message will disappear then.
|
|||||||
)
|
)
|
||||||
, a [ class "ui icon button", href "", onClick RemoveDueDate ]
|
, a [ class "ui icon button", href "", onClick RemoveDueDate ]
|
||||||
[ i [ class "trash alternate outline icon" ] [] ]
|
[ i [ class "trash alternate outline icon" ] [] ]
|
||||||
|
, Icons.dueDateIcon ""
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, optional [ Data.Fields.CorrOrg, Data.Fields.CorrPerson ] <|
|
, optional [ Data.Fields.CorrOrg, Data.Fields.CorrPerson ] <|
|
||||||
@ -772,6 +817,14 @@ item visible. This message will disappear then.
|
|||||||
]
|
]
|
||||||
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
||||||
]
|
]
|
||||||
|
, optional [ Data.Fields.Direction ] <|
|
||||||
|
div [ class "field" ]
|
||||||
|
[ label []
|
||||||
|
[ Icons.directionIcon "grey"
|
||||||
|
, text "Direction"
|
||||||
|
]
|
||||||
|
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
|
||||||
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -5,9 +5,12 @@ module Comp.ItemDetail.FormChange exposing
|
|||||||
|
|
||||||
import Api
|
import Api
|
||||||
import Api.Model.BasicResult exposing (BasicResult)
|
import Api.Model.BasicResult exposing (BasicResult)
|
||||||
|
import Api.Model.CustomField exposing (CustomField)
|
||||||
|
import Api.Model.CustomFieldValue exposing (CustomFieldValue)
|
||||||
import Api.Model.IdName exposing (IdName)
|
import Api.Model.IdName exposing (IdName)
|
||||||
import Api.Model.ItemsAndDate exposing (ItemsAndDate)
|
import Api.Model.ItemsAndDate exposing (ItemsAndDate)
|
||||||
import Api.Model.ItemsAndDirection exposing (ItemsAndDirection)
|
import Api.Model.ItemsAndDirection exposing (ItemsAndDirection)
|
||||||
|
import Api.Model.ItemsAndFieldValue exposing (ItemsAndFieldValue)
|
||||||
import Api.Model.ItemsAndName exposing (ItemsAndName)
|
import Api.Model.ItemsAndName exposing (ItemsAndName)
|
||||||
import Api.Model.ItemsAndRef exposing (ItemsAndRef)
|
import Api.Model.ItemsAndRef exposing (ItemsAndRef)
|
||||||
import Api.Model.ItemsAndRefs exposing (ItemsAndRefs)
|
import Api.Model.ItemsAndRefs exposing (ItemsAndRefs)
|
||||||
@ -33,6 +36,8 @@ type FormChange
|
|||||||
| DueDateChange (Maybe Int)
|
| DueDateChange (Maybe Int)
|
||||||
| NameChange String
|
| NameChange String
|
||||||
| ConfirmChange Bool
|
| ConfirmChange Bool
|
||||||
|
| CustomValueChange CustomField String
|
||||||
|
| RemoveCustomValue CustomField
|
||||||
|
|
||||||
|
|
||||||
multiUpdate :
|
multiUpdate :
|
||||||
@ -47,6 +52,20 @@ multiUpdate flags ids change receive =
|
|||||||
Set.toList ids
|
Set.toList ids
|
||||||
in
|
in
|
||||||
case change of
|
case change of
|
||||||
|
CustomValueChange field value ->
|
||||||
|
let
|
||||||
|
data =
|
||||||
|
ItemsAndFieldValue items (CustomFieldValue field.id value)
|
||||||
|
in
|
||||||
|
Api.putCustomValueMultiple flags data receive
|
||||||
|
|
||||||
|
RemoveCustomValue field ->
|
||||||
|
let
|
||||||
|
data =
|
||||||
|
ItemsAndName items field.id
|
||||||
|
in
|
||||||
|
Api.deleteCustomValueMultiple flags data receive
|
||||||
|
|
||||||
ReplaceTagChange tags ->
|
ReplaceTagChange tags ->
|
||||||
let
|
let
|
||||||
data =
|
data =
|
||||||
|
@ -728,6 +728,9 @@ renderEditForm settings model =
|
|||||||
|
|
||||||
else
|
else
|
||||||
span [ class "invisible hidden" ] []
|
span [ class "invisible hidden" ] []
|
||||||
|
|
||||||
|
customFieldSettings =
|
||||||
|
Comp.CustomFieldMultiInput.ViewSettings True "field"
|
||||||
in
|
in
|
||||||
div [ class "ui attached segment" ]
|
div [ class "ui attached segment" ]
|
||||||
[ div [ class "ui form warning" ]
|
[ div [ class "ui form warning" ]
|
||||||
@ -781,11 +784,11 @@ item visible. This message will disappear then.
|
|||||||
]
|
]
|
||||||
, optional [ Data.Fields.CustomFields ] <|
|
, optional [ Data.Fields.CustomFields ] <|
|
||||||
Html.map CustomFieldMsg
|
Html.map CustomFieldMsg
|
||||||
(Comp.CustomFieldMultiInput.view "field" model.customFieldsModel)
|
(Comp.CustomFieldMultiInput.view customFieldSettings model.customFieldsModel)
|
||||||
, optional [ Data.Fields.DueDate, Data.Fields.Date ] <|
|
, optional [ Data.Fields.DueDate, Data.Fields.Date ] <|
|
||||||
h4 [ class "ui dividing header" ]
|
h4 [ class "ui dividing header" ]
|
||||||
[ Icons.dateIcon ""
|
[ Icons.itemDatesIcon ""
|
||||||
, text "Dates"
|
, text "Item Dates"
|
||||||
]
|
]
|
||||||
, optional [ Data.Fields.Date ] <|
|
, optional [ Data.Fields.Date ] <|
|
||||||
div [ class "field" ]
|
div [ class "field" ]
|
||||||
|
@ -19,6 +19,7 @@ module Data.Icons exposing
|
|||||||
, equipmentIcon
|
, equipmentIcon
|
||||||
, folder
|
, folder
|
||||||
, folderIcon
|
, folderIcon
|
||||||
|
, itemDatesIcon
|
||||||
, organization
|
, organization
|
||||||
, organizationIcon
|
, organizationIcon
|
||||||
, person
|
, person
|
||||||
@ -85,6 +86,20 @@ correspondentIcon classes =
|
|||||||
i [ class (correspondent ++ " " ++ classes) ] []
|
i [ class (correspondent ++ " " ++ classes) ] []
|
||||||
|
|
||||||
|
|
||||||
|
itemDates : String
|
||||||
|
itemDates =
|
||||||
|
"calendar alternate outline icon"
|
||||||
|
|
||||||
|
|
||||||
|
itemDatesIcon : String -> Html msg
|
||||||
|
itemDatesIcon classes =
|
||||||
|
i
|
||||||
|
[ class classes
|
||||||
|
, class itemDates
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
||||||
date : String
|
date : String
|
||||||
date =
|
date =
|
||||||
"calendar outline icon"
|
"calendar outline icon"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user