mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-21 18:08:25 +00:00
@ -16,6 +16,7 @@ module Comp.CustomFieldMultiInput exposing
|
||||
, isEmpty
|
||||
, nonEmpty
|
||||
, reset
|
||||
, setOptions
|
||||
, setValues
|
||||
, update
|
||||
, updateSearch
|
||||
@ -125,6 +126,11 @@ setValues values =
|
||||
SetValues values
|
||||
|
||||
|
||||
setOptions : List CustomField -> Msg
|
||||
setOptions fields =
|
||||
CustomFieldResp (Ok (CustomFieldList fields))
|
||||
|
||||
|
||||
reset : Model -> Model
|
||||
reset model =
|
||||
let
|
||||
|
@ -60,6 +60,7 @@ import Http
|
||||
import Messages.Comp.SearchMenu exposing (Texts)
|
||||
import Set exposing (Set)
|
||||
import Styles as S
|
||||
import Util.CustomField
|
||||
import Util.Html exposing (KeyCode(..))
|
||||
import Util.ItemDragDrop as DD
|
||||
import Util.Maybe
|
||||
@ -564,6 +565,42 @@ updateDrop ddm flags settings msg model =
|
||||
selectModel =
|
||||
Comp.TagSelect.modifyCount model.tagSelectModel tagCount catCount
|
||||
|
||||
orgOpts =
|
||||
Comp.Dropdown.update (Comp.Dropdown.SetOptions (List.map .ref stats.corrOrgStats))
|
||||
model.orgModel
|
||||
|> Tuple.first
|
||||
|
||||
corrPersOpts =
|
||||
Comp.Dropdown.update (Comp.Dropdown.SetOptions (List.map .ref stats.corrPersStats))
|
||||
model.corrPersonModel
|
||||
|> Tuple.first
|
||||
|
||||
concPersOpts =
|
||||
Comp.Dropdown.update (Comp.Dropdown.SetOptions (List.map .ref stats.concPersStats))
|
||||
model.concPersonModel
|
||||
|> Tuple.first
|
||||
|
||||
concEquipOpts =
|
||||
let
|
||||
mkEquip ref =
|
||||
Equipment ref.id ref.name 0 Nothing ""
|
||||
in
|
||||
Comp.Dropdown.update
|
||||
(Comp.Dropdown.SetOptions
|
||||
(List.map (.ref >> mkEquip) stats.concEquipStats)
|
||||
)
|
||||
model.concEquipmentModel
|
||||
|> Tuple.first
|
||||
|
||||
fields =
|
||||
Util.CustomField.statsToFields stats
|
||||
|
||||
fieldOpts =
|
||||
Comp.CustomFieldMultiInput.update flags
|
||||
(Comp.CustomFieldMultiInput.setOptions fields)
|
||||
model.customFieldModel
|
||||
|> .model
|
||||
|
||||
model_ =
|
||||
{ model
|
||||
| tagSelectModel = selectModel
|
||||
@ -571,6 +608,11 @@ updateDrop ddm flags settings msg model =
|
||||
Comp.FolderSelect.modify model.selectedFolder
|
||||
model.folderList
|
||||
stats.folderStats
|
||||
, orgModel = orgOpts
|
||||
, corrPersonModel = corrPersOpts
|
||||
, concPersonModel = concPersOpts
|
||||
, concEquipmentModel = concEquipOpts
|
||||
, customFieldModel = fieldOpts
|
||||
}
|
||||
in
|
||||
{ model = model_
|
||||
|
@ -10,9 +10,12 @@ module Util.CustomField exposing
|
||||
, nameOrLabel
|
||||
, renderValue
|
||||
, renderValue2
|
||||
, statsToFields
|
||||
)
|
||||
|
||||
import Api.Model.CustomField exposing (CustomField)
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Api.Model.SearchStats exposing (SearchStats)
|
||||
import Data.CustomFieldType
|
||||
import Data.Icons as Icons
|
||||
import Html exposing (..)
|
||||
@ -20,6 +23,15 @@ import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
|
||||
|
||||
statsToFields : SearchStats -> List CustomField
|
||||
statsToFields stats =
|
||||
let
|
||||
mkField fs =
|
||||
CustomField fs.id fs.name fs.label fs.ftype fs.count 0
|
||||
in
|
||||
List.map mkField stats.fieldStats
|
||||
|
||||
|
||||
{-| This is how the server wants the value to a bool custom field
|
||||
-}
|
||||
boolValue : Bool -> String
|
||||
|
Reference in New Issue
Block a user