Externalize strings in usersettings page

This commit is contained in:
Eike Kettner
2021-04-04 21:57:34 +02:00
parent 594818499e
commit 9c1beb2240
38 changed files with 1145 additions and 446 deletions

View File

@ -3,7 +3,7 @@ module Comp.ItemDetail.EditForm exposing (formTabs, view2)
import Comp.CustomFieldMultiInput
import Comp.DatePicker
import Comp.Dropdown
import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..))
import Comp.ItemDetail.Model
exposing
( Model
@ -143,7 +143,8 @@ formTabs flags settings model =
, style = dds
}
in
[ { title = "Name"
[ { name = FTabState.tabName TabName
, title = "Name"
, titleRight = []
, info = Nothing
, body =
@ -169,7 +170,8 @@ formTabs flags settings model =
]
]
}
, { title = "Date"
, { name = FTabState.tabName TabDate
, title = "Date"
, titleRight = []
, info = Nothing
, body =
@ -194,7 +196,8 @@ formTabs flags settings model =
]
]
}
, { title = "Tags"
, { name = FTabState.tabName TabTags
, title = "Tags"
, titleRight = []
, info = Nothing
, body =
@ -217,7 +220,8 @@ formTabs flags settings model =
]
]
}
, { title = "Folder"
, { name = FTabState.tabName TabFolder
, title = "Folder"
, titleRight = []
, info = Nothing
, body =
@ -243,7 +247,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Custom Fields"
, { name = FTabState.tabName TabCustomFields
, title = "Custom Fields"
, titleRight = []
, info = Nothing
, body =
@ -257,7 +262,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Due Date"
, { name = FTabState.tabName TabDueDate
, title = "Due Date"
, titleRight = []
, info = Nothing
, body =
@ -282,7 +288,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Correspondent"
, { name = FTabState.tabName TabCorrespondent
, title = "Correspondent"
, titleRight = []
, info = Nothing
, body =
@ -331,7 +338,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Concerning"
, { name = FTabState.tabName TabConcerning
, title = "Concerning"
, titleRight = []
, info = Nothing
, body =
@ -373,7 +381,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Direction"
, { name = FTabState.tabName TabDirection
, title = "Direction"
, titleRight = []
, info = Nothing
, body =
@ -494,4 +503,4 @@ tabState settings allNames model =
FTabState.tabState settings
openTabs
Nothing
(.title >> ToggleAkkordionTab)
(.name >> ToggleAkkordionTab)

View File

@ -1,4 +1,4 @@
module Comp.ItemDetail.FieldTabState exposing (tabState)
module Comp.ItemDetail.FieldTabState exposing (EditTab(..), findTab, tabName, tabState)
import Comp.CustomFieldMultiInput
import Comp.Tabs as TB
@ -7,6 +7,87 @@ import Data.UiSettings exposing (UiSettings)
import Set exposing (Set)
type EditTab
= TabName
| TabDate
| TabTags
| TabFolder
| TabCustomFields
| TabDueDate
| TabCorrespondent
| TabConcerning
| TabDirection
| TabConfirmUnconfirm
tabName : EditTab -> String
tabName tab =
case tab of
TabName ->
"name"
TabTags ->
"tags"
TabDate ->
"date"
TabFolder ->
"folder"
TabCustomFields ->
"custom-fields"
TabDueDate ->
"due-date"
TabCorrespondent ->
"correspondent"
TabConcerning ->
"concerning"
TabDirection ->
"direction"
TabConfirmUnconfirm ->
"confirm-unconfirm"
findTab : TB.Tab msg -> Maybe EditTab
findTab tab =
case tab.name of
"name" ->
Just TabName
"tags" ->
Just TabTags
"date" ->
Just TabDate
"folder" ->
Just TabFolder
"custom-fields" ->
Just TabCustomFields
"due-date" ->
Just TabDueDate
"correspondent" ->
Just TabCorrespondent
"concerning" ->
Just TabConcerning
"direction" ->
Just TabDirection
_ ->
Nothing
tabState :
UiSettings
-> Set String
@ -20,32 +101,32 @@ tabState settings openTabs cfmodel toggle tab =
Data.UiSettings.fieldHidden settings f
hidden =
case tab.title of
"Tags" ->
case findTab tab of
Just TabTags ->
isHidden Data.Fields.Tag
"Folder" ->
Just TabFolder ->
isHidden Data.Fields.Folder
"Correspondent" ->
Just TabCorrespondent ->
isHidden Data.Fields.CorrOrg && isHidden Data.Fields.CorrPerson
"Concerning" ->
Just TabConcerning ->
isHidden Data.Fields.ConcEquip && isHidden Data.Fields.ConcPerson
"Custom Fields" ->
Just TabCustomFields ->
isHidden Data.Fields.CustomFields
|| (Maybe.map Comp.CustomFieldMultiInput.isEmpty cfmodel
|> Maybe.withDefault False
)
"Date" ->
Just TabDate ->
isHidden Data.Fields.Date
"Due Date" ->
Just TabDueDate ->
isHidden Data.Fields.DueDate
"Direction" ->
Just TabDirection ->
isHidden Data.Fields.Direction
_ ->
@ -55,7 +136,7 @@ tabState settings openTabs cfmodel toggle tab =
if hidden then
TB.Hidden
else if Set.member tab.title openTabs then
else if Set.member tab.name openTabs then
TB.Open
else

View File

@ -22,7 +22,7 @@ import Comp.CustomFieldMultiInput
import Comp.DatePicker
import Comp.DetailEdit
import Comp.Dropdown exposing (isDropdownChangeMsg)
import Comp.ItemDetail.FieldTabState as FTabState
import Comp.ItemDetail.FieldTabState as FTabState exposing (EditTab(..), tabName)
import Comp.ItemDetail.FormChange exposing (FormChange(..))
import Comp.Tabs as TB
import Data.CustomFieldChange exposing (CustomFieldChange(..))
@ -48,7 +48,6 @@ import Time
import Util.Folder exposing (mkFolderOption)
import Util.List
import Util.Maybe
import Util.Person
import Util.Tag
@ -560,14 +559,14 @@ update flags msg model =
in
UpdateResult model_ cmd_ Sub.none change
ToggleAkkordionTab title ->
ToggleAkkordionTab name ->
let
tabs =
if Set.member title model.openTabs then
Set.remove title model.openTabs
if Set.member name model.openTabs then
Set.remove name model.openTabs
else
Set.insert title model.openTabs
Set.insert name model.openTabs
in
UpdateResult { model | openTabs = tabs } Cmd.none Sub.none NoFormChange
@ -697,7 +696,8 @@ renderEditForm2 flags cfg settings model =
[ TB.akkordion
tabStyle
(tabState settings model)
[ { title = "Confirm/Unconfirm item metadata"
[ { name = tabName TabConfirmUnconfirm
, title = "Confirm/Unconfirm item metadata"
, titleRight = []
, info = Nothing
, body =
@ -721,7 +721,8 @@ renderEditForm2 flags cfg settings model =
]
]
}
, { title = "Tags"
, { name = tabName TabTags
, title = "Tags"
, titleRight = []
, info = Nothing
, body =
@ -748,7 +749,8 @@ renderEditForm2 flags cfg settings model =
]
]
}
, { title = "Folder"
, { name = tabName TabFolder
, title = "Folder"
, titleRight = []
, info = Nothing
, body =
@ -767,7 +769,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Custom Fields"
, { name = tabName TabCustomFields
, title = "Custom Fields"
, titleRight = []
, info = Nothing
, body =
@ -775,7 +778,8 @@ item visible. This message will disappear then.
(Comp.CustomFieldMultiInput.view2 dds customFieldSettings model.customFieldModel)
]
}
, { title = "Date"
, { name = tabName TabDate
, title = "Date"
, titleRight = []
, info = Nothing
, body =
@ -797,7 +801,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Due Date"
, { name = tabName TabDueDate
, title = "Due Date"
, titleRight = []
, info = Nothing
, body =
@ -819,7 +824,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Correspondent"
, { name = tabName TabCorrespondent
, title = "Correspondent"
, titleRight = []
, info = Nothing
, body =
@ -845,7 +851,8 @@ item visible. This message will disappear then.
]
]
}
, { title = "Concerning"
, { name = tabName TabConcerning
, title = "Concerning"
, titleRight = []
, info = Nothing
, body =
@ -873,14 +880,16 @@ item visible. This message will disappear then.
]
]
}
, { title = "Direction"
, { name = tabName TabDirection
, title = "Direction"
, titleRight = []
, info = Nothing
, body =
[ Html.map DirDropdownMsg (Comp.Dropdown.view2 directionCfg settings model.directionModel)
]
}
, { title = "Name"
, { name = tabName TabName
, title = "Name"
, titleRight = []
, info = Nothing
, body =

View File

@ -1469,14 +1469,14 @@ update key flags inav settings msg model =
ToggleAttachmentDropdown ->
resultModel { model | attachmentDropdownOpen = not model.attachmentDropdownOpen }
ToggleAkkordionTab title ->
ToggleAkkordionTab name ->
let
tabs =
if Set.member title model.editMenuTabsOpen then
Set.remove title model.editMenuTabsOpen
if Set.member name model.editMenuTabsOpen then
Set.remove name model.editMenuTabsOpen
else
Set.insert title model.editMenuTabsOpen
Set.insert name model.editMenuTabsOpen
in
resultModel { model | editMenuTabsOpen = tabs }