mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-04 14:15:59 +00:00
Merge pull request #219 from eikek/hide-fields
Allow to hide fields in menus based on ui settings
This commit is contained in:
commit
4ddd930c9a
69
modules/webapp/src/main/elm/Comp/FieldListSelect.elm
Normal file
69
modules/webapp/src/main/elm/Comp/FieldListSelect.elm
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
module Comp.FieldListSelect exposing (..)
|
||||||
|
|
||||||
|
import Data.Fields exposing (Field)
|
||||||
|
import Html exposing (..)
|
||||||
|
import Html.Attributes exposing (..)
|
||||||
|
import Html.Events exposing (onCheck)
|
||||||
|
|
||||||
|
|
||||||
|
type alias Model =
|
||||||
|
List Field
|
||||||
|
|
||||||
|
|
||||||
|
type Msg
|
||||||
|
= Toggle Field
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Update
|
||||||
|
|
||||||
|
|
||||||
|
update : Msg -> Model -> Model
|
||||||
|
update msg model =
|
||||||
|
case msg of
|
||||||
|
Toggle field ->
|
||||||
|
if List.member field model then
|
||||||
|
removeField model field
|
||||||
|
|
||||||
|
else
|
||||||
|
addField model field
|
||||||
|
|
||||||
|
|
||||||
|
removeField : Model -> Field -> Model
|
||||||
|
removeField selected field =
|
||||||
|
List.filter (\f -> f /= field) selected
|
||||||
|
|> Data.Fields.sort
|
||||||
|
|
||||||
|
|
||||||
|
addField : Model -> Field -> Model
|
||||||
|
addField selected field =
|
||||||
|
Data.Fields.sort (field :: selected)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- View
|
||||||
|
|
||||||
|
|
||||||
|
view : Model -> Html Msg
|
||||||
|
view selected =
|
||||||
|
div [ class "grouped fields" ]
|
||||||
|
(List.map (fieldCheckbox selected) Data.Fields.all)
|
||||||
|
|
||||||
|
|
||||||
|
fieldCheckbox : Model -> Field -> Html Msg
|
||||||
|
fieldCheckbox selected field =
|
||||||
|
let
|
||||||
|
isChecked =
|
||||||
|
List.member field selected
|
||||||
|
in
|
||||||
|
div [ class "field" ]
|
||||||
|
[ div [ class "ui checkbox" ]
|
||||||
|
[ input
|
||||||
|
[ type_ "checkbox"
|
||||||
|
, checked isChecked
|
||||||
|
, onCheck (\_ -> Toggle field)
|
||||||
|
]
|
||||||
|
[]
|
||||||
|
, label [] [ text (Data.Fields.label field) ]
|
||||||
|
]
|
||||||
|
]
|
@ -13,6 +13,7 @@ import Comp.MarkdownInput
|
|||||||
import Comp.SentMails
|
import Comp.SentMails
|
||||||
import Comp.YesNoDimmer
|
import Comp.YesNoDimmer
|
||||||
import Data.Direction
|
import Data.Direction
|
||||||
|
import Data.Fields exposing (Field)
|
||||||
import Data.Icons as Icons
|
import Data.Icons as Icons
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
import DatePicker
|
import DatePicker
|
||||||
@ -754,17 +755,34 @@ renderEditForm settings model =
|
|||||||
]
|
]
|
||||||
[ i [ class "grey pencil alternate link icon" ] []
|
[ i [ class "grey pencil alternate link icon" ] []
|
||||||
]
|
]
|
||||||
|
|
||||||
|
fieldVisible field =
|
||||||
|
Data.UiSettings.fieldVisible settings field
|
||||||
|
|
||||||
|
fieldHidden field =
|
||||||
|
Data.UiSettings.fieldHidden settings field
|
||||||
|
|
||||||
|
optional fields html =
|
||||||
|
if
|
||||||
|
List.map fieldVisible fields
|
||||||
|
|> List.foldl (||) False
|
||||||
|
then
|
||||||
|
html
|
||||||
|
|
||||||
|
else
|
||||||
|
span [ class "invisible hidden" ] []
|
||||||
in
|
in
|
||||||
div [ class "ui attached segment" ]
|
div [ class "ui attached segment" ]
|
||||||
[ div [ class "ui form warning" ]
|
[ div [ class "ui form warning" ]
|
||||||
[ div [ class "field" ]
|
[ optional [ Data.Fields.Tag ] <|
|
||||||
[ label []
|
div [ class "field" ]
|
||||||
[ Icons.tagsIcon "grey"
|
[ label []
|
||||||
, text "Tags"
|
[ Icons.tagsIcon "grey"
|
||||||
, addIconLink "Add new tag" StartTagModal
|
, text "Tags"
|
||||||
|
, addIconLink "Add new tag" StartTagModal
|
||||||
|
]
|
||||||
|
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
|
||||||
]
|
]
|
||||||
, Html.map TagDropdownMsg (Comp.Dropdown.view settings model.tagModel)
|
|
||||||
]
|
|
||||||
, div [ class " field" ]
|
, div [ class " field" ]
|
||||||
[ label [] [ text "Name" ]
|
[ label [] [ text "Name" ]
|
||||||
, div [ class "ui action input" ]
|
, div [ class "ui action input" ]
|
||||||
@ -777,121 +795,131 @@ renderEditForm settings model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class "field" ]
|
, optional [ Data.Fields.Folder ] <|
|
||||||
[ label []
|
div [ class "field" ]
|
||||||
[ Icons.folderIcon "grey"
|
[ label []
|
||||||
, text "Folder"
|
[ Icons.folderIcon "grey"
|
||||||
]
|
, text "Folder"
|
||||||
, Html.map FolderDropdownMsg (Comp.Dropdown.view settings model.folderModel)
|
|
||||||
, div
|
|
||||||
[ classList
|
|
||||||
[ ( "ui warning message", True )
|
|
||||||
, ( "hidden", isFolderMember model )
|
|
||||||
]
|
]
|
||||||
]
|
, Html.map FolderDropdownMsg (Comp.Dropdown.view settings model.folderModel)
|
||||||
[ Markdown.toHtml [] """
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( "ui warning message", True )
|
||||||
|
, ( "hidden", isFolderMember model )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ Markdown.toHtml [] """
|
||||||
You are **not a member** of this folder. This item will be **hidden**
|
You are **not a member** of this folder. This item will be **hidden**
|
||||||
from any search now. Use a folder where you are a member of to make this
|
from any search now. Use a folder where you are a member of to make this
|
||||||
item visible. This message will disappear then.
|
item visible. This message will disappear then.
|
||||||
"""
|
"""
|
||||||
]
|
|
||||||
]
|
|
||||||
, div [ class "field" ]
|
|
||||||
[ label []
|
|
||||||
[ Icons.directionIcon "grey"
|
|
||||||
, text "Direction"
|
|
||||||
]
|
|
||||||
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
|
|
||||||
]
|
|
||||||
, div [ class "field" ]
|
|
||||||
[ label []
|
|
||||||
[ Icons.dateIcon "grey"
|
|
||||||
, text "Date"
|
|
||||||
]
|
|
||||||
, div [ class "ui action input" ]
|
|
||||||
[ Html.map ItemDatePickerMsg
|
|
||||||
(Comp.DatePicker.viewTime
|
|
||||||
model.itemDate
|
|
||||||
actionInputDatePicker
|
|
||||||
model.itemDatePicker
|
|
||||||
)
|
|
||||||
, a [ class "ui icon button", href "", onClick RemoveDate ]
|
|
||||||
[ i [ class "trash alternate outline icon" ] []
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, renderItemDateSuggestions model
|
, optional [ Data.Fields.Direction ] <|
|
||||||
]
|
div [ class "field" ]
|
||||||
, div [ class " field" ]
|
[ label []
|
||||||
[ label []
|
[ Icons.directionIcon "grey"
|
||||||
[ Icons.dueDateIcon "grey"
|
, text "Direction"
|
||||||
, text "Due Date"
|
]
|
||||||
|
, Html.map DirDropdownMsg (Comp.Dropdown.view settings model.directionModel)
|
||||||
]
|
]
|
||||||
, div [ class "ui action input" ]
|
, optional [ Data.Fields.Date ] <|
|
||||||
[ Html.map DueDatePickerMsg
|
div [ class "field" ]
|
||||||
(Comp.DatePicker.viewTime
|
[ label []
|
||||||
model.dueDate
|
[ Icons.dateIcon "grey"
|
||||||
actionInputDatePicker
|
, text "Date"
|
||||||
model.dueDatePicker
|
]
|
||||||
)
|
, div [ class "ui action input" ]
|
||||||
, a [ class "ui icon button", href "", onClick RemoveDueDate ]
|
[ Html.map ItemDatePickerMsg
|
||||||
[ i [ class "trash alternate outline icon" ] [] ]
|
(Comp.DatePicker.viewTime
|
||||||
|
model.itemDate
|
||||||
|
actionInputDatePicker
|
||||||
|
model.itemDatePicker
|
||||||
|
)
|
||||||
|
, a [ class "ui icon button", href "", onClick RemoveDate ]
|
||||||
|
[ i [ class "trash alternate outline icon" ] []
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, renderItemDateSuggestions model
|
||||||
]
|
]
|
||||||
, renderDueDateSuggestions model
|
, optional [ Data.Fields.DueDate ] <|
|
||||||
]
|
div [ class " field" ]
|
||||||
, h4 [ class "ui dividing header" ]
|
[ label []
|
||||||
[ Icons.correspondentIcon ""
|
[ Icons.dueDateIcon "grey"
|
||||||
, text "Correspondent"
|
, text "Due Date"
|
||||||
]
|
]
|
||||||
, div [ class "field" ]
|
, div [ class "ui action input" ]
|
||||||
[ label []
|
[ Html.map DueDatePickerMsg
|
||||||
[ Icons.organizationIcon "grey"
|
(Comp.DatePicker.viewTime
|
||||||
, text "Organization"
|
model.dueDate
|
||||||
, addIconLink "Add new organization" StartCorrOrgModal
|
actionInputDatePicker
|
||||||
, editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal
|
model.dueDatePicker
|
||||||
|
)
|
||||||
|
, a [ class "ui icon button", href "", onClick RemoveDueDate ]
|
||||||
|
[ i [ class "trash alternate outline icon" ] [] ]
|
||||||
|
]
|
||||||
|
, renderDueDateSuggestions model
|
||||||
]
|
]
|
||||||
, Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel)
|
, optional [ Data.Fields.CorrOrg, Data.Fields.CorrPerson ] <|
|
||||||
, renderOrgSuggestions model
|
h4 [ class "ui dividing header" ]
|
||||||
]
|
[ Icons.correspondentIcon ""
|
||||||
, div [ class "field" ]
|
, text "Correspondent"
|
||||||
[ label []
|
|
||||||
[ Icons.personIcon "grey"
|
|
||||||
, text "Person"
|
|
||||||
, addIconLink "Add new correspondent person" StartCorrPersonModal
|
|
||||||
, editIconLink "Edit person"
|
|
||||||
model.corrPersonModel
|
|
||||||
(StartEditPersonModal model.corrPersonModel)
|
|
||||||
]
|
]
|
||||||
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
, optional [ Data.Fields.CorrOrg ] <|
|
||||||
, renderCorrPersonSuggestions model
|
div [ class "field" ]
|
||||||
]
|
[ label []
|
||||||
, h4 [ class "ui dividing header" ]
|
[ Icons.organizationIcon "grey"
|
||||||
[ Icons.concernedIcon
|
, text "Organization"
|
||||||
, text "Concerning"
|
, addIconLink "Add new organization" StartCorrOrgModal
|
||||||
]
|
, editIconLink "Edit organization" model.corrOrgModel StartEditCorrOrgModal
|
||||||
, div [ class "field" ]
|
]
|
||||||
[ label []
|
, Html.map OrgDropdownMsg (Comp.Dropdown.view settings model.corrOrgModel)
|
||||||
[ Icons.personIcon "grey"
|
, renderOrgSuggestions model
|
||||||
, text "Person"
|
|
||||||
, addIconLink "Add new concerning person" StartConcPersonModal
|
|
||||||
, editIconLink "Edit person"
|
|
||||||
model.concPersonModel
|
|
||||||
(StartEditPersonModal model.concPersonModel)
|
|
||||||
]
|
]
|
||||||
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
, optional [ Data.Fields.CorrPerson ] <|
|
||||||
, renderConcPersonSuggestions model
|
div [ class "field" ]
|
||||||
]
|
[ label []
|
||||||
, div [ class "field" ]
|
[ Icons.personIcon "grey"
|
||||||
[ label []
|
, text "Person"
|
||||||
[ Icons.equipmentIcon "grey"
|
, addIconLink "Add new correspondent person" StartCorrPersonModal
|
||||||
, text "Equipment"
|
, editIconLink "Edit person"
|
||||||
, addIconLink "Add new equipment" StartEquipModal
|
model.corrPersonModel
|
||||||
, editIconLink "Edit equipment"
|
(StartEditPersonModal model.corrPersonModel)
|
||||||
model.concEquipModel
|
]
|
||||||
StartEditEquipModal
|
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
||||||
|
, renderCorrPersonSuggestions model
|
||||||
|
]
|
||||||
|
, optional [ Data.Fields.ConcPerson, Data.Fields.ConcEquip ] <|
|
||||||
|
h4 [ class "ui dividing header" ]
|
||||||
|
[ Icons.concernedIcon
|
||||||
|
, text "Concerning"
|
||||||
|
]
|
||||||
|
, optional [ Data.Fields.ConcPerson ] <|
|
||||||
|
div [ class "field" ]
|
||||||
|
[ label []
|
||||||
|
[ Icons.personIcon "grey"
|
||||||
|
, text "Person"
|
||||||
|
, addIconLink "Add new concerning person" StartConcPersonModal
|
||||||
|
, editIconLink "Edit person"
|
||||||
|
model.concPersonModel
|
||||||
|
(StartEditPersonModal model.concPersonModel)
|
||||||
|
]
|
||||||
|
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
||||||
|
, renderConcPersonSuggestions model
|
||||||
|
]
|
||||||
|
, optional [ Data.Fields.ConcEquip ] <|
|
||||||
|
div [ class "field" ]
|
||||||
|
[ label []
|
||||||
|
[ Icons.equipmentIcon "grey"
|
||||||
|
, text "Equipment"
|
||||||
|
, addIconLink "Add new equipment" StartEquipModal
|
||||||
|
, editIconLink "Edit equipment"
|
||||||
|
model.concEquipModel
|
||||||
|
StartEditEquipModal
|
||||||
|
]
|
||||||
|
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
||||||
|
, renderConcEquipSuggestions model
|
||||||
]
|
]
|
||||||
, Html.map ConcEquipMsg (Comp.Dropdown.view settings model.concEquipModel)
|
|
||||||
, renderConcEquipSuggestions model
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import Comp.Dropdown exposing (isDropdownChangeMsg)
|
|||||||
import Comp.FolderSelect
|
import Comp.FolderSelect
|
||||||
import Comp.TagSelect
|
import Comp.TagSelect
|
||||||
import Data.Direction exposing (Direction)
|
import Data.Direction exposing (Direction)
|
||||||
|
import Data.Fields
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.Icons as Icons
|
import Data.Icons as Icons
|
||||||
import Data.UiSettings exposing (UiSettings)
|
import Data.UiSettings exposing (UiSettings)
|
||||||
@ -625,6 +626,22 @@ viewDrop ddd flags settings model =
|
|||||||
|
|
||||||
segmentClass =
|
segmentClass =
|
||||||
"ui vertical segment"
|
"ui vertical segment"
|
||||||
|
|
||||||
|
fieldVisible field =
|
||||||
|
Data.UiSettings.fieldVisible settings field
|
||||||
|
|
||||||
|
fieldHidden field =
|
||||||
|
Data.UiSettings.fieldHidden settings field
|
||||||
|
|
||||||
|
optional fields html =
|
||||||
|
if
|
||||||
|
List.map fieldVisible fields
|
||||||
|
|> List.foldl (||) False
|
||||||
|
then
|
||||||
|
html
|
||||||
|
|
||||||
|
else
|
||||||
|
span [ class "invisible hidden" ] []
|
||||||
in
|
in
|
||||||
div [ class "ui form" ]
|
div [ class "ui form" ]
|
||||||
[ div [ class segmentClass ]
|
[ div [ class segmentClass ]
|
||||||
@ -642,41 +659,68 @@ viewDrop ddd flags settings model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
, div
|
||||||
[ Html.map TagSelectMsg (Comp.TagSelect.viewTagsDrop ddd.model settings model.tagSelectModel)
|
[ classList
|
||||||
, Html.map TagSelectMsg (Comp.TagSelect.viewCats settings model.tagSelectModel)
|
[ ( segmentClass, True )
|
||||||
, Html.map FolderSelectMsg
|
, ( "invisible hidden", fieldHidden Data.Fields.Tag && fieldHidden Data.Fields.Folder )
|
||||||
(Comp.FolderSelect.viewDrop ddd.model settings.searchMenuFolderCount model.folderList)
|
]
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
[ optional [ Data.Fields.Tag ] <|
|
||||||
[ formHeader (Icons.correspondentIcon "")
|
Html.map TagSelectMsg (Comp.TagSelect.viewTagsDrop ddd.model settings model.tagSelectModel)
|
||||||
(case getDirection model of
|
, optional [ Data.Fields.Tag ] <|
|
||||||
Just Data.Direction.Incoming ->
|
Html.map TagSelectMsg (Comp.TagSelect.viewCats settings model.tagSelectModel)
|
||||||
"Sender"
|
, optional [ Data.Fields.Folder ] <|
|
||||||
|
Html.map FolderSelectMsg
|
||||||
|
(Comp.FolderSelect.viewDrop ddd.model settings.searchMenuFolderCount model.folderList)
|
||||||
|
]
|
||||||
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( segmentClass, True )
|
||||||
|
, ( "hidden invisible", fieldHidden Data.Fields.CorrOrg && fieldHidden Data.Fields.CorrPerson )
|
||||||
|
]
|
||||||
|
]
|
||||||
|
[ optional
|
||||||
|
[ Data.Fields.CorrOrg
|
||||||
|
, Data.Fields.CorrPerson
|
||||||
|
]
|
||||||
|
<|
|
||||||
|
formHeader (Icons.correspondentIcon "")
|
||||||
|
(case getDirection model of
|
||||||
|
Just Data.Direction.Incoming ->
|
||||||
|
"Sender"
|
||||||
|
|
||||||
Just Data.Direction.Outgoing ->
|
Just Data.Direction.Outgoing ->
|
||||||
"Recipient"
|
"Recipient"
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
"Correspondent"
|
"Correspondent"
|
||||||
)
|
)
|
||||||
, div [ class "field" ]
|
, optional [ Data.Fields.CorrOrg ] <|
|
||||||
[ label [] [ text "Organization" ]
|
div [ class "field" ]
|
||||||
, Html.map OrgMsg (Comp.Dropdown.view settings model.orgModel)
|
[ label [] [ text "Organization" ]
|
||||||
]
|
, Html.map OrgMsg (Comp.Dropdown.view settings model.orgModel)
|
||||||
, div [ class "field" ]
|
]
|
||||||
[ label [] [ text "Person" ]
|
, optional [ Data.Fields.CorrPerson ] <|
|
||||||
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
div [ class "field" ]
|
||||||
]
|
[ label [] [ text "Person" ]
|
||||||
, formHeader Icons.concernedIcon "Concerned"
|
, Html.map CorrPersonMsg (Comp.Dropdown.view settings model.corrPersonModel)
|
||||||
, div [ class "field" ]
|
]
|
||||||
[ label [] [ text "Person" ]
|
, optional
|
||||||
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
[ Data.Fields.ConcPerson
|
||||||
]
|
, Data.Fields.ConcEquip
|
||||||
, div [ class "field" ]
|
|
||||||
[ label [] [ text "Equipment" ]
|
|
||||||
, Html.map ConcEquipmentMsg (Comp.Dropdown.view settings model.concEquipmentModel)
|
|
||||||
]
|
]
|
||||||
|
<|
|
||||||
|
formHeader Icons.concernedIcon "Concerned"
|
||||||
|
, optional [ Data.Fields.ConcPerson ] <|
|
||||||
|
div [ class "field" ]
|
||||||
|
[ label [] [ text "Person" ]
|
||||||
|
, Html.map ConcPersonMsg (Comp.Dropdown.view settings model.concPersonModel)
|
||||||
|
]
|
||||||
|
, optional [ Data.Fields.ConcEquip ] <|
|
||||||
|
div [ class "field" ]
|
||||||
|
[ label [] [ text "Equipment" ]
|
||||||
|
, Html.map ConcEquipmentMsg (Comp.Dropdown.view settings model.concEquipmentModel)
|
||||||
|
]
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
, div [ class segmentClass ]
|
||||||
[ formHeader (Icons.searchIcon "") "Text Search"
|
[ formHeader (Icons.searchIcon "") "Text Search"
|
||||||
@ -740,55 +784,69 @@ viewDrop ddd flags settings model =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
, div
|
||||||
[ formHeader (Icons.dateIcon "") "Date"
|
[ classList
|
||||||
, div [ class "fields" ]
|
[ ( segmentClass, True )
|
||||||
[ div [ class "field" ]
|
, ( "invisible hidden", fieldHidden Data.Fields.Date && fieldHidden Data.Fields.DueDate )
|
||||||
[ label []
|
]
|
||||||
[ text "From"
|
]
|
||||||
]
|
[ optional [ Data.Fields.Date ] <|
|
||||||
, Html.map FromDateMsg
|
formHeader (Icons.dateIcon "") "Date"
|
||||||
(Comp.DatePicker.viewTimeDefault
|
, optional [ Data.Fields.Date ] <|
|
||||||
model.fromDate
|
div [ class "fields" ]
|
||||||
model.fromDateModel
|
[ div [ class "field" ]
|
||||||
)
|
[ label []
|
||||||
]
|
[ text "From"
|
||||||
, div [ class "field" ]
|
]
|
||||||
[ label []
|
, Html.map FromDateMsg
|
||||||
[ text "To"
|
(Comp.DatePicker.viewTimeDefault
|
||||||
]
|
model.fromDate
|
||||||
, Html.map UntilDateMsg
|
model.fromDateModel
|
||||||
(Comp.DatePicker.viewTimeDefault
|
)
|
||||||
model.untilDate
|
]
|
||||||
model.untilDateModel
|
, div [ class "field" ]
|
||||||
)
|
[ label []
|
||||||
]
|
[ text "To"
|
||||||
]
|
]
|
||||||
, formHeader (Icons.dueDateIcon "") "Due Date"
|
, Html.map UntilDateMsg
|
||||||
, div [ class "fields" ]
|
(Comp.DatePicker.viewTimeDefault
|
||||||
[ div [ class "field" ]
|
model.untilDate
|
||||||
[ label []
|
model.untilDateModel
|
||||||
[ text "Due From"
|
)
|
||||||
]
|
]
|
||||||
, Html.map FromDueDateMsg
|
]
|
||||||
(Comp.DatePicker.viewTimeDefault
|
, optional [ Data.Fields.DueDate ] <|
|
||||||
model.fromDueDate
|
formHeader (Icons.dueDateIcon "") "Due Date"
|
||||||
model.fromDueDateModel
|
, optional [ Data.Fields.DueDate ] <|
|
||||||
)
|
div [ class "fields" ]
|
||||||
]
|
[ div [ class "field" ]
|
||||||
, div [ class "field" ]
|
[ label []
|
||||||
[ label []
|
[ text "Due From"
|
||||||
[ text "Due To"
|
]
|
||||||
]
|
, Html.map FromDueDateMsg
|
||||||
, Html.map UntilDueDateMsg
|
(Comp.DatePicker.viewTimeDefault
|
||||||
(Comp.DatePicker.viewTimeDefault
|
model.fromDueDate
|
||||||
model.untilDueDate
|
model.fromDueDateModel
|
||||||
model.untilDueDateModel
|
)
|
||||||
)
|
]
|
||||||
]
|
, div [ class "field" ]
|
||||||
|
[ label []
|
||||||
|
[ text "Due To"
|
||||||
|
]
|
||||||
|
, Html.map UntilDueDateMsg
|
||||||
|
(Comp.DatePicker.viewTimeDefault
|
||||||
|
model.untilDueDate
|
||||||
|
model.untilDueDateModel
|
||||||
|
)
|
||||||
|
]
|
||||||
|
]
|
||||||
|
]
|
||||||
|
, div
|
||||||
|
[ classList
|
||||||
|
[ ( segmentClass, True )
|
||||||
|
, ( "invisible hidden", fieldHidden Data.Fields.Direction )
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class segmentClass ]
|
|
||||||
[ formHeader (Icons.directionIcon "") "Direction"
|
[ formHeader (Icons.directionIcon "") "Direction"
|
||||||
, div [ class "field" ]
|
, div [ class "field" ]
|
||||||
[ Html.map DirectionMsg (Comp.Dropdown.view settings model.directionModel)
|
[ Html.map DirectionMsg (Comp.Dropdown.view settings model.directionModel)
|
||||||
|
@ -9,8 +9,10 @@ module Comp.UiSettingsForm exposing
|
|||||||
import Api
|
import Api
|
||||||
import Api.Model.TagList exposing (TagList)
|
import Api.Model.TagList exposing (TagList)
|
||||||
import Comp.ColorTagger
|
import Comp.ColorTagger
|
||||||
|
import Comp.FieldListSelect
|
||||||
import Comp.IntField
|
import Comp.IntField
|
||||||
import Data.Color exposing (Color)
|
import Data.Color exposing (Color)
|
||||||
|
import Data.Fields exposing (Field)
|
||||||
import Data.Flags exposing (Flags)
|
import Data.Flags exposing (Flags)
|
||||||
import Data.UiSettings exposing (Pos(..), UiSettings)
|
import Data.UiSettings exposing (Pos(..), UiSettings)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
@ -36,6 +38,7 @@ type alias Model =
|
|||||||
, searchMenuTagCountModel : Comp.IntField.Model
|
, searchMenuTagCountModel : Comp.IntField.Model
|
||||||
, searchMenuTagCatCount : Maybe Int
|
, searchMenuTagCatCount : Maybe Int
|
||||||
, searchMenuTagCatCountModel : Comp.IntField.Model
|
, searchMenuTagCatCountModel : Comp.IntField.Model
|
||||||
|
, formFields : List Field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,6 +86,7 @@ init flags settings =
|
|||||||
(Just 2000)
|
(Just 2000)
|
||||||
False
|
False
|
||||||
"Number of categories in search menu"
|
"Number of categories in search menu"
|
||||||
|
, formFields = settings.formFields
|
||||||
}
|
}
|
||||||
, Api.getTags flags "" GetTagsResp
|
, Api.getTags flags "" GetTagsResp
|
||||||
)
|
)
|
||||||
@ -98,6 +102,7 @@ type Msg
|
|||||||
| SearchMenuFolderMsg Comp.IntField.Msg
|
| SearchMenuFolderMsg Comp.IntField.Msg
|
||||||
| SearchMenuTagMsg Comp.IntField.Msg
|
| SearchMenuTagMsg Comp.IntField.Msg
|
||||||
| SearchMenuTagCatMsg Comp.IntField.Msg
|
| SearchMenuTagCatMsg Comp.IntField.Msg
|
||||||
|
| FieldListMsg Comp.FieldListSelect.Msg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -240,6 +245,22 @@ update sett msg model =
|
|||||||
GetTagsResp (Err _) ->
|
GetTagsResp (Err _) ->
|
||||||
( model, Nothing )
|
( model, Nothing )
|
||||||
|
|
||||||
|
FieldListMsg lm ->
|
||||||
|
let
|
||||||
|
selected =
|
||||||
|
Comp.FieldListSelect.update lm model.formFields
|
||||||
|
|
||||||
|
newSettings =
|
||||||
|
{ sett | formFields = selected }
|
||||||
|
in
|
||||||
|
( { model | formFields = selected }
|
||||||
|
, if selected /= model.formFields then
|
||||||
|
Just newSettings
|
||||||
|
|
||||||
|
else
|
||||||
|
Nothing
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- View
|
--- View
|
||||||
@ -355,4 +376,11 @@ view flags _ model =
|
|||||||
tagColorViewOpts
|
tagColorViewOpts
|
||||||
model.tagColorModel
|
model.tagColorModel
|
||||||
)
|
)
|
||||||
|
, div [ class "ui dividing header" ]
|
||||||
|
[ text "Fields"
|
||||||
|
]
|
||||||
|
, span [ class "small-info" ]
|
||||||
|
[ text "Choose which fields to display in search and edit menus."
|
||||||
|
]
|
||||||
|
, Html.map FieldListMsg (Comp.FieldListSelect.view model.formFields)
|
||||||
]
|
]
|
||||||
|
142
modules/webapp/src/main/elm/Data/Fields.elm
Normal file
142
modules/webapp/src/main/elm/Data/Fields.elm
Normal file
@ -0,0 +1,142 @@
|
|||||||
|
module Data.Fields exposing
|
||||||
|
( Field(..)
|
||||||
|
, all
|
||||||
|
, fromList
|
||||||
|
, fromString
|
||||||
|
, label
|
||||||
|
, sort
|
||||||
|
, toString
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type Field
|
||||||
|
= Tag
|
||||||
|
| Folder
|
||||||
|
| CorrOrg
|
||||||
|
| CorrPerson
|
||||||
|
| ConcPerson
|
||||||
|
| ConcEquip
|
||||||
|
| Date
|
||||||
|
| DueDate
|
||||||
|
| Direction
|
||||||
|
|
||||||
|
|
||||||
|
all : List Field
|
||||||
|
all =
|
||||||
|
sort
|
||||||
|
[ Tag
|
||||||
|
, Folder
|
||||||
|
, CorrOrg
|
||||||
|
, CorrPerson
|
||||||
|
, ConcPerson
|
||||||
|
, ConcEquip
|
||||||
|
, Date
|
||||||
|
, DueDate
|
||||||
|
, Direction
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
sort : List Field -> List Field
|
||||||
|
sort fields =
|
||||||
|
List.sortBy toString fields
|
||||||
|
|
||||||
|
|
||||||
|
fromString : String -> Maybe Field
|
||||||
|
fromString str =
|
||||||
|
case String.toLower str of
|
||||||
|
"tag" ->
|
||||||
|
Just Tag
|
||||||
|
|
||||||
|
"folder" ->
|
||||||
|
Just Folder
|
||||||
|
|
||||||
|
"corrorg" ->
|
||||||
|
Just CorrOrg
|
||||||
|
|
||||||
|
"corrperson" ->
|
||||||
|
Just CorrPerson
|
||||||
|
|
||||||
|
"concperson" ->
|
||||||
|
Just ConcPerson
|
||||||
|
|
||||||
|
"concequip" ->
|
||||||
|
Just ConcEquip
|
||||||
|
|
||||||
|
"date" ->
|
||||||
|
Just Date
|
||||||
|
|
||||||
|
"duedate" ->
|
||||||
|
Just DueDate
|
||||||
|
|
||||||
|
"direction" ->
|
||||||
|
Just Direction
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
Nothing
|
||||||
|
|
||||||
|
|
||||||
|
toString : Field -> String
|
||||||
|
toString field =
|
||||||
|
case field of
|
||||||
|
Tag ->
|
||||||
|
"tag"
|
||||||
|
|
||||||
|
Folder ->
|
||||||
|
"folder"
|
||||||
|
|
||||||
|
CorrOrg ->
|
||||||
|
"corrorg"
|
||||||
|
|
||||||
|
CorrPerson ->
|
||||||
|
"corrperson"
|
||||||
|
|
||||||
|
ConcPerson ->
|
||||||
|
"concperson"
|
||||||
|
|
||||||
|
ConcEquip ->
|
||||||
|
"concequip"
|
||||||
|
|
||||||
|
Date ->
|
||||||
|
"date"
|
||||||
|
|
||||||
|
DueDate ->
|
||||||
|
"duedate"
|
||||||
|
|
||||||
|
Direction ->
|
||||||
|
"direction"
|
||||||
|
|
||||||
|
|
||||||
|
label : Field -> String
|
||||||
|
label field =
|
||||||
|
case field of
|
||||||
|
Tag ->
|
||||||
|
"Tag"
|
||||||
|
|
||||||
|
Folder ->
|
||||||
|
"Folder"
|
||||||
|
|
||||||
|
CorrOrg ->
|
||||||
|
"Correspondent Organization"
|
||||||
|
|
||||||
|
CorrPerson ->
|
||||||
|
"Correspondent Person"
|
||||||
|
|
||||||
|
ConcPerson ->
|
||||||
|
"Concerning Person"
|
||||||
|
|
||||||
|
ConcEquip ->
|
||||||
|
"Concerned Equipment"
|
||||||
|
|
||||||
|
Date ->
|
||||||
|
"Date"
|
||||||
|
|
||||||
|
DueDate ->
|
||||||
|
"Due Date"
|
||||||
|
|
||||||
|
Direction ->
|
||||||
|
"Direction"
|
||||||
|
|
||||||
|
|
||||||
|
fromList : List String -> List Field
|
||||||
|
fromList strings =
|
||||||
|
List.filterMap fromString strings
|
@ -5,6 +5,8 @@ module Data.UiSettings exposing
|
|||||||
, catColor
|
, catColor
|
||||||
, catColorString
|
, catColorString
|
||||||
, defaults
|
, defaults
|
||||||
|
, fieldHidden
|
||||||
|
, fieldVisible
|
||||||
, merge
|
, merge
|
||||||
, mergeDefaults
|
, mergeDefaults
|
||||||
, posFromString
|
, posFromString
|
||||||
@ -16,6 +18,7 @@ module Data.UiSettings exposing
|
|||||||
|
|
||||||
import Api.Model.Tag exposing (Tag)
|
import Api.Model.Tag exposing (Tag)
|
||||||
import Data.Color exposing (Color)
|
import Data.Color exposing (Color)
|
||||||
|
import Data.Fields exposing (Field)
|
||||||
import Dict exposing (Dict)
|
import Dict exposing (Dict)
|
||||||
|
|
||||||
|
|
||||||
@ -36,6 +39,7 @@ type alias StoredUiSettings =
|
|||||||
, searchMenuFolderCount : Maybe Int
|
, searchMenuFolderCount : Maybe Int
|
||||||
, searchMenuTagCount : Maybe Int
|
, searchMenuTagCount : Maybe Int
|
||||||
, searchMenuTagCatCount : Maybe Int
|
, searchMenuTagCatCount : Maybe Int
|
||||||
|
, formFields : Maybe (List String)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -55,6 +59,7 @@ type alias UiSettings =
|
|||||||
, searchMenuFolderCount : Int
|
, searchMenuFolderCount : Int
|
||||||
, searchMenuTagCount : Int
|
, searchMenuTagCount : Int
|
||||||
, searchMenuTagCatCount : Int
|
, searchMenuTagCatCount : Int
|
||||||
|
, formFields : List Field
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -96,6 +101,7 @@ defaults =
|
|||||||
, searchMenuFolderCount = 3
|
, searchMenuFolderCount = 3
|
||||||
, searchMenuTagCount = 6
|
, searchMenuTagCount = 6
|
||||||
, searchMenuTagCatCount = 3
|
, searchMenuTagCatCount = 3
|
||||||
|
, formFields = Data.Fields.all
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,6 +130,10 @@ merge given fallback =
|
|||||||
choose given.searchMenuTagCount fallback.searchMenuTagCount
|
choose given.searchMenuTagCount fallback.searchMenuTagCount
|
||||||
, searchMenuTagCatCount =
|
, searchMenuTagCatCount =
|
||||||
choose given.searchMenuTagCatCount fallback.searchMenuTagCatCount
|
choose given.searchMenuTagCatCount fallback.searchMenuTagCatCount
|
||||||
|
, formFields =
|
||||||
|
choose
|
||||||
|
(Maybe.map Data.Fields.fromList given.formFields)
|
||||||
|
fallback.formFields
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,6 +154,9 @@ toStoredUiSettings settings =
|
|||||||
, searchMenuFolderCount = Just settings.searchMenuFolderCount
|
, searchMenuFolderCount = Just settings.searchMenuFolderCount
|
||||||
, searchMenuTagCount = Just settings.searchMenuTagCount
|
, searchMenuTagCount = Just settings.searchMenuTagCount
|
||||||
, searchMenuTagCatCount = Just settings.searchMenuTagCatCount
|
, searchMenuTagCatCount = Just settings.searchMenuTagCatCount
|
||||||
|
, formFields =
|
||||||
|
List.map Data.Fields.toString settings.formFields
|
||||||
|
|> Just
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -171,6 +184,16 @@ tagColorString tag settings =
|
|||||||
|> Maybe.withDefault ""
|
|> Maybe.withDefault ""
|
||||||
|
|
||||||
|
|
||||||
|
fieldVisible : UiSettings -> Field -> Bool
|
||||||
|
fieldVisible settings field =
|
||||||
|
List.member field settings.formFields
|
||||||
|
|
||||||
|
|
||||||
|
fieldHidden : UiSettings -> Field -> Bool
|
||||||
|
fieldHidden settings field =
|
||||||
|
fieldVisible settings field |> not
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Helpers
|
--- Helpers
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user