Display custom field values on item card

This commit is contained in:
Eike Kettner
2020-11-23 10:23:37 +01:00
parent 7b7f1e4d6d
commit 6d22bac720
4 changed files with 81 additions and 43 deletions

View File

@ -0,0 +1,30 @@
module Util.CustomField exposing (renderValue)
import Api.Model.ItemFieldValue exposing (ItemFieldValue)
import Data.CustomFieldType
import Data.Icons as Icons
import Html exposing (..)
import Html.Attributes exposing (..)
renderValue : String -> ItemFieldValue -> Html msg
renderValue classes cv =
let
renderBool =
if cv.value == "true" then
i [ class "check icon" ] []
else
i [ class "minus icon" ] []
in
div [ class classes ]
[ Icons.customFieldTypeIconString "" cv.ftype
, Maybe.withDefault cv.name cv.label |> text
, div [ class "detail" ]
[ if Data.CustomFieldType.fromString cv.ftype == Just Data.CustomFieldType.Boolean then
renderBool
else
text cv.value
]
]