mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-23 10:58:26 +00:00
Manage custom fields in webui
This commit is contained in:
80
modules/webapp/src/main/elm/Data/CustomFieldType.elm
Normal file
80
modules/webapp/src/main/elm/Data/CustomFieldType.elm
Normal file
@ -0,0 +1,80 @@
|
||||
module Data.CustomFieldType exposing
|
||||
( CustomFieldType(..)
|
||||
, all
|
||||
, asString
|
||||
, fromString
|
||||
, label
|
||||
)
|
||||
|
||||
|
||||
type CustomFieldType
|
||||
= Text
|
||||
| Numeric
|
||||
| Date
|
||||
| Boolean
|
||||
| Money
|
||||
|
||||
|
||||
all : List CustomFieldType
|
||||
all =
|
||||
[ Text, Numeric, Date, Boolean, Money ]
|
||||
|
||||
|
||||
asString : CustomFieldType -> String
|
||||
asString ft =
|
||||
case ft of
|
||||
Text ->
|
||||
"text"
|
||||
|
||||
Numeric ->
|
||||
"numeric"
|
||||
|
||||
Date ->
|
||||
"date"
|
||||
|
||||
Boolean ->
|
||||
"bool"
|
||||
|
||||
Money ->
|
||||
"money"
|
||||
|
||||
|
||||
label : CustomFieldType -> String
|
||||
label ft =
|
||||
case ft of
|
||||
Text ->
|
||||
"Text"
|
||||
|
||||
Numeric ->
|
||||
"Numeric"
|
||||
|
||||
Date ->
|
||||
"Date"
|
||||
|
||||
Boolean ->
|
||||
"Boolean"
|
||||
|
||||
Money ->
|
||||
"Money"
|
||||
|
||||
|
||||
fromString : String -> Maybe CustomFieldType
|
||||
fromString str =
|
||||
case String.toLower str of
|
||||
"text" ->
|
||||
Just Text
|
||||
|
||||
"numeric" ->
|
||||
Just Numeric
|
||||
|
||||
"date" ->
|
||||
Just Date
|
||||
|
||||
"bool" ->
|
||||
Just Boolean
|
||||
|
||||
"money" ->
|
||||
Just Money
|
||||
|
||||
_ ->
|
||||
Nothing
|
@ -20,6 +20,7 @@ type Field
|
||||
| DueDate
|
||||
| Direction
|
||||
| PreviewImage
|
||||
| CustomFields
|
||||
|
||||
|
||||
all : List Field
|
||||
@ -35,6 +36,7 @@ all =
|
||||
, DueDate
|
||||
, Direction
|
||||
, PreviewImage
|
||||
, CustomFields
|
||||
]
|
||||
|
||||
|
||||
@ -76,6 +78,9 @@ fromString str =
|
||||
"preview" ->
|
||||
Just PreviewImage
|
||||
|
||||
"customfields" ->
|
||||
Just CustomFields
|
||||
|
||||
_ ->
|
||||
Nothing
|
||||
|
||||
@ -113,6 +118,9 @@ toString field =
|
||||
PreviewImage ->
|
||||
"preview"
|
||||
|
||||
CustomFields ->
|
||||
"customfields"
|
||||
|
||||
|
||||
label : Field -> String
|
||||
label field =
|
||||
@ -147,6 +155,9 @@ label field =
|
||||
PreviewImage ->
|
||||
"Preview Image"
|
||||
|
||||
CustomFields ->
|
||||
"Custom Fields"
|
||||
|
||||
|
||||
fromList : List String -> List Field
|
||||
fromList strings =
|
||||
|
@ -5,6 +5,8 @@ module Data.Icons exposing
|
||||
, concernedIcon
|
||||
, correspondent
|
||||
, correspondentIcon
|
||||
, customField
|
||||
, customFieldIcon
|
||||
, date
|
||||
, dateIcon
|
||||
, direction
|
||||
@ -33,6 +35,16 @@ import Html exposing (Html, i)
|
||||
import Html.Attributes exposing (class)
|
||||
|
||||
|
||||
customField : String
|
||||
customField =
|
||||
"highlighter icon"
|
||||
|
||||
|
||||
customFieldIcon : String -> Html msg
|
||||
customFieldIcon classes =
|
||||
i [ class (customField ++ " " ++ classes) ] []
|
||||
|
||||
|
||||
search : String
|
||||
search =
|
||||
"search icon"
|
||||
|
Reference in New Issue
Block a user