mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-04 10:29:34 +00:00
parent
48d182667d
commit
9bc2084499
@ -636,7 +636,10 @@ renderCustomValues : UiSettings -> Model -> List (Html Msg)
|
||||
renderCustomValues settings model =
|
||||
let
|
||||
fieldView cv =
|
||||
Util.CustomField.renderValue "ui secondary basic label" cv
|
||||
Comp.LinkTarget.makeCustomFieldLink
|
||||
cv
|
||||
[ ( "ui secondary basic label", True ) ]
|
||||
SetLinkTarget
|
||||
|
||||
labelThenName cv =
|
||||
Maybe.withDefault cv.name cv.label
|
||||
|
@ -2,14 +2,17 @@ module Comp.LinkTarget exposing
|
||||
( LinkTarget(..)
|
||||
, makeConcLink
|
||||
, makeCorrLink
|
||||
, makeCustomFieldLink
|
||||
, makeFolderLink
|
||||
, makeTagLink
|
||||
)
|
||||
|
||||
import Api.Model.IdName exposing (IdName)
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Util.CustomField
|
||||
|
||||
|
||||
type LinkTarget
|
||||
@ -19,6 +22,7 @@ type LinkTarget
|
||||
| LinkConcEquip IdName
|
||||
| LinkFolder IdName
|
||||
| LinkTag IdName
|
||||
| LinkCustomField ItemFieldValue
|
||||
| LinkNone
|
||||
|
||||
|
||||
@ -74,6 +78,18 @@ makeTagLink tagId classes tagger =
|
||||
makeLink classes (LinkTag >> tagger) tagId
|
||||
|
||||
|
||||
makeCustomFieldLink :
|
||||
ItemFieldValue
|
||||
-> List ( String, Bool )
|
||||
-> (LinkTarget -> msg)
|
||||
-> Html msg
|
||||
makeCustomFieldLink cv classes tagger =
|
||||
Util.CustomField.renderValue1
|
||||
classes
|
||||
(tagger (LinkCustomField cv) |> Just)
|
||||
cv
|
||||
|
||||
|
||||
|
||||
--- Helpers
|
||||
|
||||
|
@ -19,6 +19,7 @@ import Api.Model.Equipment exposing (Equipment)
|
||||
import Api.Model.EquipmentList exposing (EquipmentList)
|
||||
import Api.Model.FolderStats exposing (FolderStats)
|
||||
import Api.Model.IdName exposing (IdName)
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Api.Model.ItemSearch exposing (ItemSearch)
|
||||
import Api.Model.PersonList exposing (PersonList)
|
||||
import Api.Model.ReferenceList exposing (ReferenceList)
|
||||
@ -353,6 +354,7 @@ type Msg
|
||||
| SetConcEquip IdName
|
||||
| SetFolder IdName
|
||||
| SetTag String
|
||||
| SetCustomField ItemFieldValue
|
||||
| CustomFieldMsg Comp.CustomFieldMultiInput.Msg
|
||||
| SetSource String
|
||||
| GetStatsResp (Result Http.Error SearchStats)
|
||||
@ -829,6 +831,22 @@ updateDrop ddm flags settings msg model =
|
||||
, dragDrop = DD.DragDropData ddm Nothing
|
||||
}
|
||||
|
||||
SetCustomField cv ->
|
||||
let
|
||||
lm =
|
||||
Comp.CustomFieldMultiInput.setValues [ cv ]
|
||||
|
||||
values =
|
||||
Data.CustomFieldChange.fromItemValues [ cv ]
|
||||
|
||||
next =
|
||||
updateDrop ddm flags settings (CustomFieldMsg lm) model
|
||||
|
||||
m =
|
||||
next.model
|
||||
in
|
||||
{ next | model = { m | customValues = values } }
|
||||
|
||||
SetSource str ->
|
||||
let
|
||||
next =
|
||||
|
@ -3,12 +3,14 @@ module Data.CustomFieldChange exposing
|
||||
, CustomFieldValueCollect
|
||||
, collectValues
|
||||
, emptyCollect
|
||||
, fromItemValues
|
||||
, isValueChange
|
||||
, toFieldValues
|
||||
)
|
||||
|
||||
import Api.Model.CustomField exposing (CustomField)
|
||||
import Api.Model.CustomFieldValue exposing (CustomFieldValue)
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Dict exposing (Dict)
|
||||
|
||||
|
||||
@ -75,3 +77,10 @@ isValueChange change =
|
||||
|
||||
FieldCreateNew ->
|
||||
False
|
||||
|
||||
|
||||
fromItemValues : List { v | id : String, value : String } -> CustomFieldValueCollect
|
||||
fromItemValues values =
|
||||
List.map (\e -> ( e.id, e.value )) values
|
||||
|> Dict.fromList
|
||||
|> CustomFieldValueCollect
|
||||
|
@ -713,6 +713,9 @@ linkTargetMsg linkTarget =
|
||||
Comp.LinkTarget.LinkTag id ->
|
||||
Just <| SearchMenuMsg (Comp.SearchMenu.SetTag id.id)
|
||||
|
||||
Comp.LinkTarget.LinkCustomField id ->
|
||||
Just <| SearchMenuMsg (Comp.SearchMenu.SetCustomField id)
|
||||
|
||||
|
||||
doSearchMore : Flags -> UiSettings -> Model -> ( Model, Cmd Msg )
|
||||
doSearchMore flags settings model =
|
||||
|
@ -1,10 +1,11 @@
|
||||
module Util.CustomField exposing (nameOrLabel, renderValue)
|
||||
module Util.CustomField exposing (nameOrLabel, renderValue, renderValue1)
|
||||
|
||||
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
|
||||
import Data.CustomFieldType
|
||||
import Data.Icons as Icons
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
|
||||
|
||||
nameOrLabel : { r | name : String, label : Maybe String } -> String
|
||||
@ -14,6 +15,11 @@ nameOrLabel fv =
|
||||
|
||||
renderValue : String -> ItemFieldValue -> Html msg
|
||||
renderValue classes cv =
|
||||
renderValue1 [ ( classes, True ) ] Nothing cv
|
||||
|
||||
|
||||
renderValue1 : List ( String, Bool ) -> Maybe msg -> ItemFieldValue -> Html msg
|
||||
renderValue1 classes tagger cv =
|
||||
let
|
||||
renderBool =
|
||||
if cv.value == "true" then
|
||||
@ -21,8 +27,21 @@ renderValue classes cv =
|
||||
|
||||
else
|
||||
i [ class "minus icon" ] []
|
||||
|
||||
el : List (Html msg) -> Html msg
|
||||
el =
|
||||
case tagger of
|
||||
Just t ->
|
||||
a
|
||||
[ classList classes
|
||||
, onClick t
|
||||
, href "#"
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
div [ classList classes ]
|
||||
in
|
||||
div [ class classes ]
|
||||
el
|
||||
[ Icons.customFieldTypeIconString "" cv.ftype
|
||||
, nameOrLabel cv |> text
|
||||
, div [ class "detail" ]
|
||||
|
Loading…
x
Reference in New Issue
Block a user