mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-07 15:45:59 +00:00
Merge pull request #763 from eikek/date-format
Prepare translating dates
This commit is contained in:
commit
b781461b4a
@ -18,7 +18,6 @@ import Http
|
|||||||
import Messages.Comp.AttachmentMeta exposing (Texts)
|
import Messages.Comp.AttachmentMeta exposing (Texts)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Http
|
import Util.Http
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -129,7 +128,7 @@ viewProposals2 texts props =
|
|||||||
[ class S.basicLabel
|
[ class S.basicLabel
|
||||||
, class "text-sm"
|
, class "text-sm"
|
||||||
]
|
]
|
||||||
[ Util.Time.formatDateShort ms |> text
|
[ texts.formatDateShort ms |> text
|
||||||
]
|
]
|
||||||
in
|
in
|
||||||
div [ class "flex flex-col" ]
|
div [ class "flex flex-col" ]
|
||||||
|
@ -21,7 +21,6 @@ import Messages.Comp.CalEventInput exposing (Texts)
|
|||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Http
|
import Util.Http
|
||||||
import Util.Maybe
|
import Util.Maybe
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -284,7 +283,7 @@ view2 texts extraClasses ev model =
|
|||||||
, ul [ class "list-decimal list-inside text-sm" ]
|
, ul [ class "list-decimal list-inside text-sm" ]
|
||||||
(Maybe.map .next model.checkResult
|
(Maybe.map .next model.checkResult
|
||||||
|> Maybe.withDefault []
|
|> Maybe.withDefault []
|
||||||
|> List.map Util.Time.formatDateTime
|
|> List.map texts.formatDateTime
|
||||||
|> List.map (\s -> li [ class "" ] [ text s ])
|
|> List.map (\s -> li [ class "" ] [ text s ])
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,6 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Messages.Comp.CustomFieldTable exposing (Texts)
|
import Messages.Comp.CustomFieldTable exposing (Texts)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -59,13 +58,13 @@ view2 texts _ items =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
, tbody []
|
, tbody []
|
||||||
(List.map viewItem2 items)
|
(List.map (viewItem2 texts) items)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
viewItem2 : CustomField -> Html Msg
|
viewItem2 : Texts -> CustomField -> Html Msg
|
||||||
viewItem2 item =
|
viewItem2 texts item =
|
||||||
tr [ class S.tableRow ]
|
tr [ class S.tableRow ]
|
||||||
[ B.editLinkTableCell (EditItem item)
|
[ B.editLinkTableCell (EditItem item)
|
||||||
, td [ class "text-left py-4 md:py-2 pr-2" ]
|
, td [ class "text-left py-4 md:py-2 pr-2" ]
|
||||||
@ -79,7 +78,7 @@ viewItem2 item =
|
|||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
, td [ class "text-center py-4 md:py-2 hidden sm:table-cell" ]
|
, td [ class "text-center py-4 md:py-2 hidden sm:table-cell" ]
|
||||||
[ Util.Time.formatDateShort item.created
|
[ texts.formatDateShort item.created
|
||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,6 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Messages.Comp.FolderTable exposing (Texts)
|
import Messages.Comp.FolderTable exposing (Texts)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -69,12 +68,12 @@ view2 texts _ items =
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
, tbody []
|
, tbody []
|
||||||
(List.map viewItem2 items)
|
(List.map (viewItem2 texts) items)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
viewItem2 : FolderItem -> Html Msg
|
viewItem2 : Texts -> FolderItem -> Html Msg
|
||||||
viewItem2 item =
|
viewItem2 texts item =
|
||||||
tr
|
tr
|
||||||
[ class S.tableRow
|
[ class S.tableRow
|
||||||
]
|
]
|
||||||
@ -97,7 +96,7 @@ viewItem2 item =
|
|||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
, td [ class "text-center py-4 md:py-2" ]
|
, td [ class "text-center py-4 md:py-2" ]
|
||||||
[ Util.Time.formatDateShort item.created
|
[ texts.formatDateShort item.created
|
||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -221,6 +221,14 @@ fulltextResultsContent2 item =
|
|||||||
(List.map renderHighlightEntry2 item.highlighting)
|
(List.map renderHighlightEntry2 item.highlighting)
|
||||||
|
|
||||||
|
|
||||||
|
templateCtx : Texts -> IT.TemplateContext
|
||||||
|
templateCtx texts =
|
||||||
|
{ dateFormatLong = texts.formatDateLong
|
||||||
|
, dateFormatShort = texts.formatDateShort
|
||||||
|
, directionLabel = texts.directionLabel
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
metaDataContent2 : Texts -> UiSettings -> ItemLight -> Html Msg
|
metaDataContent2 : Texts -> UiSettings -> ItemLight -> Html Msg
|
||||||
metaDataContent2 texts settings item =
|
metaDataContent2 texts settings item =
|
||||||
let
|
let
|
||||||
@ -249,7 +257,7 @@ metaDataContent2 texts settings item =
|
|||||||
, Comp.LinkTarget.makeSourceLink
|
, Comp.LinkTarget.makeSourceLink
|
||||||
[ ( "hover:opacity-60", True ) ]
|
[ ( "hover:opacity-60", True ) ]
|
||||||
SetLinkTarget
|
SetLinkTarget
|
||||||
(IT.render IT.source item)
|
(IT.render IT.source (templateCtx texts) item)
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
@ -289,7 +297,7 @@ mainContent2 texts cardAction cardColor isConfirmed settings _ item =
|
|||||||
[ class (Data.Direction.iconFromMaybe2 item.direction)
|
[ class (Data.Direction.iconFromMaybe2 item.direction)
|
||||||
, class "mr-2 w-4 text-center"
|
, class "mr-2 w-4 text-center"
|
||||||
, classList [ ( "hidden", fieldHidden Data.Fields.Direction ) ]
|
, classList [ ( "hidden", fieldHidden Data.Fields.Direction ) ]
|
||||||
, IT.render IT.direction item |> title
|
, IT.render IT.direction (templateCtx texts) item |> title
|
||||||
]
|
]
|
||||||
[]
|
[]
|
||||||
|
|
||||||
@ -330,9 +338,9 @@ mainContent2 texts cardAction cardColor isConfirmed settings _ item =
|
|||||||
)
|
)
|
||||||
, div
|
, div
|
||||||
[ class "font-bold py-1 text-lg"
|
[ class "font-bold py-1 text-lg"
|
||||||
, classList [ ( "hidden", IT.render titlePattern item == "" ) ]
|
, classList [ ( "hidden", IT.render titlePattern (templateCtx texts) item == "" ) ]
|
||||||
]
|
]
|
||||||
[ IT.render titlePattern item |> text
|
[ IT.render titlePattern (templateCtx texts) item |> text
|
||||||
]
|
]
|
||||||
, div
|
, div
|
||||||
[ classList
|
[ classList
|
||||||
@ -347,11 +355,11 @@ mainContent2 texts cardAction cardColor isConfirmed settings _ item =
|
|||||||
, div
|
, div
|
||||||
[ classList
|
[ classList
|
||||||
[ ( "opacity-75", True )
|
[ ( "opacity-75", True )
|
||||||
, ( "hidden", IT.render subtitlePattern item == "" )
|
, ( "hidden", IT.render subtitlePattern (templateCtx texts) item == "" )
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
[ dirIcon
|
[ dirIcon
|
||||||
, IT.render subtitlePattern item |> text
|
, IT.render subtitlePattern (templateCtx texts) item |> text
|
||||||
]
|
]
|
||||||
, div [ class "" ]
|
, div [ class "" ]
|
||||||
[ mainTagsAndFields2 settings item
|
[ mainTagsAndFields2 settings item
|
||||||
@ -466,7 +474,7 @@ previewMenu2 texts settings model item mainAttach =
|
|||||||
|> Maybe.withDefault "/api/v1/sec/attachment/none"
|
|> Maybe.withDefault "/api/v1/sec/attachment/none"
|
||||||
|
|
||||||
dueDate =
|
dueDate =
|
||||||
IT.render IT.dueDateShort item
|
IT.render IT.dueDateShort (templateCtx texts) item
|
||||||
|
|
||||||
dueDateLabel =
|
dueDateLabel =
|
||||||
div
|
div
|
||||||
|
@ -32,7 +32,6 @@ import Styles as S
|
|||||||
import Util.Folder
|
import Util.Folder
|
||||||
import Util.Person
|
import Util.Person
|
||||||
import Util.Tag
|
import Util.Tag
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
view2 : Texts -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
@ -467,7 +466,7 @@ renderItemDateSuggestions : Texts -> Model -> Html Msg
|
|||||||
renderItemDateSuggestions texts model =
|
renderItemDateSuggestions texts model =
|
||||||
renderSuggestions texts
|
renderSuggestions texts
|
||||||
model
|
model
|
||||||
Util.Time.formatDate
|
texts.formatDate
|
||||||
(List.take 6 model.itemProposals.itemDate)
|
(List.take 6 model.itemProposals.itemDate)
|
||||||
SetItemDateSuggestion
|
SetItemDateSuggestion
|
||||||
|
|
||||||
@ -476,7 +475,7 @@ renderDueDateSuggestions : Texts -> Model -> Html Msg
|
|||||||
renderDueDateSuggestions texts model =
|
renderDueDateSuggestions texts model =
|
||||||
renderSuggestions texts
|
renderSuggestions texts
|
||||||
model
|
model
|
||||||
Util.Time.formatDate
|
texts.formatDate
|
||||||
(List.take 6 model.itemProposals.dueDate)
|
(List.take 6 model.itemProposals.dueDate)
|
||||||
SetDueDateSuggestion
|
SetDueDateSuggestion
|
||||||
|
|
||||||
|
@ -19,7 +19,6 @@ import Messages.Comp.ItemDetail.ItemInfoHeader exposing (Texts)
|
|||||||
import Page exposing (Page(..))
|
import Page exposing (Page(..))
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Maybe
|
import Util.Maybe
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
view : Texts -> UiSettings -> Model -> Html Msg
|
view : Texts -> UiSettings -> Model -> Html Msg
|
||||||
@ -32,7 +31,7 @@ view texts settings model =
|
|||||||
]
|
]
|
||||||
[ Icons.dateIcon2 "mr-2"
|
[ Icons.dateIcon2 "mr-2"
|
||||||
, Maybe.withDefault model.item.created model.item.itemDate
|
, Maybe.withDefault model.item.created model.item.itemDate
|
||||||
|> Util.Time.formatDate
|
|> texts.formatDate
|
||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
, Data.UiSettings.fieldVisible settings Data.Fields.Date
|
, Data.UiSettings.fieldVisible settings Data.Fields.Date
|
||||||
@ -51,7 +50,7 @@ view texts settings model =
|
|||||||
, title texts.dueDate
|
, title texts.dueDate
|
||||||
]
|
]
|
||||||
[ Icons.dueDateIcon2 "mr-2"
|
[ Icons.dueDateIcon2 "mr-2"
|
||||||
, Maybe.map Util.Time.formatDate model.item.dueDate
|
, Maybe.map texts.formatDate model.item.dueDate
|
||||||
|> Maybe.withDefault ""
|
|> Maybe.withDefault ""
|
||||||
|> text
|
|> text
|
||||||
]
|
]
|
||||||
|
@ -292,14 +292,14 @@ itemIdInfo texts model =
|
|||||||
, title texts.createdOn
|
, title texts.createdOn
|
||||||
]
|
]
|
||||||
[ i [ class "fa fa-sun font-thin mr-2" ] []
|
[ i [ class "fa fa-sun font-thin mr-2" ] []
|
||||||
, Util.Time.formatDateTime model.item.created |> text
|
, texts.formatDateTime model.item.created |> text
|
||||||
]
|
]
|
||||||
, div
|
, div
|
||||||
[ class "inline-flex items-center"
|
[ class "inline-flex items-center"
|
||||||
, title texts.lastUpdateOn
|
, title texts.lastUpdateOn
|
||||||
]
|
]
|
||||||
[ i [ class "fa fa-pencil-alt mr-2" ] []
|
[ i [ class "fa fa-pencil-alt mr-2" ] []
|
||||||
, Util.Time.formatDateTime model.item.updated |> text
|
, texts.formatDateTime model.item.updated |> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -15,7 +15,6 @@ import Html.Attributes exposing (..)
|
|||||||
import Html.Events exposing (onClick)
|
import Html.Events exposing (onClick)
|
||||||
import Messages.Comp.SentMails exposing (Texts)
|
import Messages.Comp.SentMails exposing (Texts)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -82,7 +81,7 @@ view2 texts model =
|
|||||||
[ text (texts.date ++ ":")
|
[ text (texts.date ++ ":")
|
||||||
]
|
]
|
||||||
, div [ class "ml-2" ]
|
, div [ class "ml-2" ]
|
||||||
[ Util.Time.formatDateTime mail.created |> text
|
[ texts.formatDateTime mail.created |> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class "flex flex-row" ]
|
, div [ class "flex flex-row" ]
|
||||||
@ -131,13 +130,13 @@ view2 texts model =
|
|||||||
]
|
]
|
||||||
, tbody [] <|
|
, tbody [] <|
|
||||||
List.map
|
List.map
|
||||||
renderLine2
|
(renderLine2 texts)
|
||||||
model.mails
|
model.mails
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
renderLine2 : SentMail -> Html Msg
|
renderLine2 : Texts -> SentMail -> Html Msg
|
||||||
renderLine2 mail =
|
renderLine2 texts mail =
|
||||||
tr [ class S.tableRow ]
|
tr [ class S.tableRow ]
|
||||||
[ td []
|
[ td []
|
||||||
[ B.linkLabel
|
[ B.linkLabel
|
||||||
@ -152,7 +151,7 @@ renderLine2 mail =
|
|||||||
]
|
]
|
||||||
, td [ class "hidden" ] [ text mail.subject ]
|
, td [ class "hidden" ] [ text mail.subject ]
|
||||||
, td [ class "hidden text-center xl:table-cell" ]
|
, td [ class "hidden text-center xl:table-cell" ]
|
||||||
[ Util.Time.formatDateTime mail.created |> text
|
[ texts.formatDateTime mail.created |> text
|
||||||
]
|
]
|
||||||
, td [ class "hidden" ] [ text mail.sender ]
|
, td [ class "hidden" ] [ text mail.sender ]
|
||||||
]
|
]
|
||||||
|
@ -13,7 +13,6 @@ import Html exposing (..)
|
|||||||
import Html.Attributes exposing (..)
|
import Html.Attributes exposing (..)
|
||||||
import Messages.Comp.UserTable exposing (Texts)
|
import Messages.Comp.UserTable exposing (Texts)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time exposing (formatDateTime)
|
|
||||||
|
|
||||||
|
|
||||||
type alias Model =
|
type alias Model =
|
||||||
@ -93,9 +92,9 @@ renderUserLine2 texts model user =
|
|||||||
[ String.fromInt user.loginCount |> text
|
[ String.fromInt user.loginCount |> text
|
||||||
]
|
]
|
||||||
, td [ class "hidden sm:table-cell text-center" ]
|
, td [ class "hidden sm:table-cell text-center" ]
|
||||||
[ Maybe.map formatDateTime user.lastLogin |> Maybe.withDefault "" |> text
|
[ Maybe.map texts.formatDateTime user.lastLogin |> Maybe.withDefault "" |> text
|
||||||
]
|
]
|
||||||
, td [ class "hidden md:table-cell text-center" ]
|
, td [ class "hidden md:table-cell text-center" ]
|
||||||
[ formatDateTime user.created |> text
|
[ texts.formatDateTime user.created |> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module Data.ItemTemplate exposing
|
module Data.ItemTemplate exposing
|
||||||
( ItemTemplate
|
( ItemTemplate
|
||||||
|
, TemplateContext
|
||||||
, concEquip
|
, concEquip
|
||||||
, concPerson
|
, concPerson
|
||||||
, concat
|
, concat
|
||||||
@ -30,15 +31,21 @@ module Data.ItemTemplate exposing
|
|||||||
|
|
||||||
import Api.Model.IdName exposing (IdName)
|
import Api.Model.IdName exposing (IdName)
|
||||||
import Api.Model.ItemLight exposing (ItemLight)
|
import Api.Model.ItemLight exposing (ItemLight)
|
||||||
import Data.Direction
|
import Data.Direction exposing (Direction)
|
||||||
import Set
|
import Set
|
||||||
import Util.List
|
import Util.List
|
||||||
import Util.String
|
import Util.String
|
||||||
import Util.Time
|
|
||||||
|
|
||||||
|
type alias TemplateContext =
|
||||||
|
{ dateFormatLong : Int -> String
|
||||||
|
, dateFormatShort : Int -> String
|
||||||
|
, directionLabel : Direction -> String
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
type ItemTemplate
|
type ItemTemplate
|
||||||
= ItemTemplate (ItemLight -> String)
|
= ItemTemplate (TemplateContext -> ItemLight -> String)
|
||||||
|
|
||||||
|
|
||||||
readTemplate : String -> Maybe ItemTemplate
|
readTemplate : String -> Maybe ItemTemplate
|
||||||
@ -55,16 +62,23 @@ readTemplate str =
|
|||||||
Maybe.map read (splitTokens str)
|
Maybe.map read (splitTokens str)
|
||||||
|
|
||||||
|
|
||||||
render : ItemTemplate -> ItemLight -> String
|
render : ItemTemplate -> TemplateContext -> ItemLight -> String
|
||||||
render pattern item =
|
render pattern ctx item =
|
||||||
case pattern of
|
case pattern of
|
||||||
ItemTemplate f ->
|
ItemTemplate f ->
|
||||||
f item
|
f ctx item
|
||||||
|
|
||||||
|
|
||||||
isEmpty : ItemTemplate -> ItemLight -> Bool
|
isEmpty : ItemTemplate -> ItemLight -> Bool
|
||||||
isEmpty pattern item =
|
isEmpty pattern item =
|
||||||
render pattern item |> String.isEmpty
|
let
|
||||||
|
ctx =
|
||||||
|
{ dateFormatLong = \_ -> "non-empty"
|
||||||
|
, dateFormatShort = \_ -> "non-empty"
|
||||||
|
, directionLabel = \_ -> "non-empty"
|
||||||
|
}
|
||||||
|
in
|
||||||
|
render pattern ctx item |> String.isEmpty
|
||||||
|
|
||||||
|
|
||||||
nonEmpty : ItemTemplate -> ItemLight -> Bool
|
nonEmpty : ItemTemplate -> ItemLight -> Bool
|
||||||
@ -80,14 +94,14 @@ map : (String -> String) -> ItemTemplate -> ItemTemplate
|
|||||||
map f pattern =
|
map f pattern =
|
||||||
case pattern of
|
case pattern of
|
||||||
ItemTemplate p ->
|
ItemTemplate p ->
|
||||||
from (p >> f)
|
ItemTemplate (\ctx -> p ctx >> f)
|
||||||
|
|
||||||
|
|
||||||
map2 : (String -> String -> String) -> ItemTemplate -> ItemTemplate -> ItemTemplate
|
map2 : (String -> String -> String) -> ItemTemplate -> ItemTemplate -> ItemTemplate
|
||||||
map2 f pattern1 pattern2 =
|
map2 f pattern1 pattern2 =
|
||||||
case ( pattern1, pattern2 ) of
|
case ( pattern1, pattern2 ) of
|
||||||
( ItemTemplate p1, ItemTemplate p2 ) ->
|
( ItemTemplate p1, ItemTemplate p2 ) ->
|
||||||
from (\i -> f (p1 i) (p2 i))
|
ItemTemplate (\ctx -> \i -> f (p1 ctx i) (p2 ctx i))
|
||||||
|
|
||||||
|
|
||||||
combine : String -> ItemTemplate -> ItemTemplate -> ItemTemplate
|
combine : String -> ItemTemplate -> ItemTemplate -> ItemTemplate
|
||||||
@ -104,18 +118,20 @@ combine sep p1 p2 =
|
|||||||
|
|
||||||
concat : List ItemTemplate -> ItemTemplate
|
concat : List ItemTemplate -> ItemTemplate
|
||||||
concat patterns =
|
concat patterns =
|
||||||
from
|
ItemTemplate
|
||||||
(\i ->
|
(\ctx ->
|
||||||
List.map (\p -> render p i) patterns
|
\i ->
|
||||||
|
List.map (\p -> render p ctx i) patterns
|
||||||
|> String.join ""
|
|> String.join ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
firstNonEmpty : List ItemTemplate -> ItemTemplate
|
firstNonEmpty : List ItemTemplate -> ItemTemplate
|
||||||
firstNonEmpty patterns =
|
firstNonEmpty patterns =
|
||||||
from
|
ItemTemplate
|
||||||
(\i ->
|
(\ctx ->
|
||||||
List.map (\p -> render p i) patterns
|
\i ->
|
||||||
|
List.map (\p -> render p ctx i) patterns
|
||||||
|> List.filter (String.isEmpty >> not)
|
|> List.filter (String.isEmpty >> not)
|
||||||
|> List.head
|
|> List.head
|
||||||
|> Maybe.withDefault ""
|
|> Maybe.withDefault ""
|
||||||
@ -128,17 +144,17 @@ firstNonEmpty patterns =
|
|||||||
|
|
||||||
from : (ItemLight -> String) -> ItemTemplate
|
from : (ItemLight -> String) -> ItemTemplate
|
||||||
from f =
|
from f =
|
||||||
ItemTemplate f
|
ItemTemplate (\_ -> f)
|
||||||
|
|
||||||
|
|
||||||
fromMaybe : (ItemLight -> Maybe String) -> ItemTemplate
|
fromMaybe : (TemplateContext -> ItemLight -> Maybe String) -> ItemTemplate
|
||||||
fromMaybe f =
|
fromMaybe f =
|
||||||
ItemTemplate (f >> Maybe.withDefault "")
|
ItemTemplate (\ctx -> f ctx >> Maybe.withDefault "")
|
||||||
|
|
||||||
|
|
||||||
literal : String -> ItemTemplate
|
literal : String -> ItemTemplate
|
||||||
literal str =
|
literal str =
|
||||||
ItemTemplate (\_ -> str)
|
ItemTemplate (\_ -> \_ -> str)
|
||||||
|
|
||||||
|
|
||||||
empty : ItemTemplate
|
empty : ItemTemplate
|
||||||
@ -148,57 +164,57 @@ empty =
|
|||||||
|
|
||||||
name : ItemTemplate
|
name : ItemTemplate
|
||||||
name =
|
name =
|
||||||
ItemTemplate (.name >> Util.String.underscoreToSpace)
|
from (.name >> Util.String.underscoreToSpace)
|
||||||
|
|
||||||
|
|
||||||
direction : ItemTemplate
|
direction : ItemTemplate
|
||||||
direction =
|
direction =
|
||||||
let
|
let
|
||||||
dirStr ms =
|
dirStr ctx ms =
|
||||||
Maybe.andThen Data.Direction.fromString ms
|
Maybe.andThen Data.Direction.fromString ms
|
||||||
|> Maybe.map Data.Direction.toString
|
|> Maybe.map ctx.directionLabel
|
||||||
in
|
in
|
||||||
fromMaybe (.direction >> dirStr)
|
fromMaybe (\ctx -> .direction >> dirStr ctx)
|
||||||
|
|
||||||
|
|
||||||
dateLong : ItemTemplate
|
dateLong : ItemTemplate
|
||||||
dateLong =
|
dateLong =
|
||||||
ItemTemplate (.date >> Util.Time.formatDate)
|
ItemTemplate (\ctx -> .date >> ctx.dateFormatLong)
|
||||||
|
|
||||||
|
|
||||||
dateShort : ItemTemplate
|
dateShort : ItemTemplate
|
||||||
dateShort =
|
dateShort =
|
||||||
ItemTemplate (.date >> Util.Time.formatDateShort)
|
ItemTemplate (\ctx -> .date >> ctx.dateFormatShort)
|
||||||
|
|
||||||
|
|
||||||
dueDateLong : ItemTemplate
|
dueDateLong : ItemTemplate
|
||||||
dueDateLong =
|
dueDateLong =
|
||||||
fromMaybe (.dueDate >> Maybe.map Util.Time.formatDate)
|
fromMaybe (\ctx -> .dueDate >> Maybe.map ctx.dateFormatLong)
|
||||||
|
|
||||||
|
|
||||||
dueDateShort : ItemTemplate
|
dueDateShort : ItemTemplate
|
||||||
dueDateShort =
|
dueDateShort =
|
||||||
fromMaybe (.dueDate >> Maybe.map Util.Time.formatDateShort)
|
fromMaybe (\ctx -> .dueDate >> Maybe.map ctx.dateFormatShort)
|
||||||
|
|
||||||
|
|
||||||
source : ItemTemplate
|
source : ItemTemplate
|
||||||
source =
|
source =
|
||||||
ItemTemplate .source
|
from .source
|
||||||
|
|
||||||
|
|
||||||
folder : ItemTemplate
|
folder : ItemTemplate
|
||||||
folder =
|
folder =
|
||||||
ItemTemplate (.folder >> getName)
|
from (.folder >> getName)
|
||||||
|
|
||||||
|
|
||||||
corrOrg : ItemTemplate
|
corrOrg : ItemTemplate
|
||||||
corrOrg =
|
corrOrg =
|
||||||
ItemTemplate (.corrOrg >> getName)
|
from (.corrOrg >> getName)
|
||||||
|
|
||||||
|
|
||||||
corrPerson : ItemTemplate
|
corrPerson : ItemTemplate
|
||||||
corrPerson =
|
corrPerson =
|
||||||
ItemTemplate (.corrPerson >> getName)
|
from (.corrPerson >> getName)
|
||||||
|
|
||||||
|
|
||||||
correspondent : ItemTemplate
|
correspondent : ItemTemplate
|
||||||
@ -208,12 +224,12 @@ correspondent =
|
|||||||
|
|
||||||
concPerson : ItemTemplate
|
concPerson : ItemTemplate
|
||||||
concPerson =
|
concPerson =
|
||||||
ItemTemplate (.concPerson >> getName)
|
from (.concPerson >> getName)
|
||||||
|
|
||||||
|
|
||||||
concEquip : ItemTemplate
|
concEquip : ItemTemplate
|
||||||
concEquip =
|
concEquip =
|
||||||
ItemTemplate (.concEquipment >> getName)
|
from (.concEquipment >> getName)
|
||||||
|
|
||||||
|
|
||||||
concerning : ItemTemplate
|
concerning : ItemTemplate
|
||||||
@ -223,7 +239,7 @@ concerning =
|
|||||||
|
|
||||||
fileCount : ItemTemplate
|
fileCount : ItemTemplate
|
||||||
fileCount =
|
fileCount =
|
||||||
ItemTemplate (.attachments >> List.length >> String.fromInt)
|
from (.attachments >> List.length >> String.fromInt)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module Messages.Comp.AttachmentMeta exposing (Texts, gb)
|
module Messages.Comp.AttachmentMeta exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -15,6 +17,7 @@ type alias Texts =
|
|||||||
, concerningEquipment : String
|
, concerningEquipment : String
|
||||||
, itemDate : String
|
, itemDate : String
|
||||||
, itemDueDate : String
|
, itemDueDate : String
|
||||||
|
, formatDateShort : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -31,4 +34,5 @@ gb =
|
|||||||
, concerningEquipment = "Concerning Equipment"
|
, concerningEquipment = "Concerning Equipment"
|
||||||
, itemDate = "Item Date"
|
, itemDate = "Item Date"
|
||||||
, itemDueDate = "Item Due Date"
|
, itemDueDate = "Item Due Date"
|
||||||
|
, formatDateShort = DF.formatDateShort Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
module Messages.Comp.CalEventInput exposing (Texts, gb)
|
module Messages.Comp.CalEventInput exposing (Texts, gb)
|
||||||
|
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
{ weekday : String
|
{ weekday : String
|
||||||
@ -11,6 +14,7 @@ type alias Texts =
|
|||||||
, error : String
|
, error : String
|
||||||
, schedule : String
|
, schedule : String
|
||||||
, next : String
|
, next : String
|
||||||
|
, formatDateTime : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -25,4 +29,5 @@ gb =
|
|||||||
, error = "Error"
|
, error = "Error"
|
||||||
, schedule = "Schedule"
|
, schedule = "Schedule"
|
||||||
, next = "Next"
|
, next = "Next"
|
||||||
|
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module Messages.Comp.CustomFieldTable exposing (Texts, gb)
|
module Messages.Comp.CustomFieldTable exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -8,6 +10,7 @@ type alias Texts =
|
|||||||
, nameLabel : String
|
, nameLabel : String
|
||||||
, format : String
|
, format : String
|
||||||
, usageCount : String
|
, usageCount : String
|
||||||
|
, formatDateShort : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -17,4 +20,5 @@ gb =
|
|||||||
, nameLabel = "Name/Label"
|
, nameLabel = "Name/Label"
|
||||||
, format = "Format"
|
, format = "Format"
|
||||||
, usageCount = "#Usage"
|
, usageCount = "#Usage"
|
||||||
|
, formatDateShort = DF.formatDateShort Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
module Messages.Comp.FolderTable exposing (Texts, gb)
|
module Messages.Comp.FolderTable exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
{ basics : Messages.Basics.Texts
|
{ basics : Messages.Basics.Texts
|
||||||
, memberCount : String
|
, memberCount : String
|
||||||
|
, formatDateShort : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -13,4 +16,5 @@ gb : Texts
|
|||||||
gb =
|
gb =
|
||||||
{ basics = Messages.Basics.gb
|
{ basics = Messages.Basics.gb
|
||||||
, memberCount = "#Member"
|
, memberCount = "#Member"
|
||||||
|
, formatDateShort = DF.formatDateShort Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
module Messages.Comp.ItemCard exposing (Texts, gb)
|
module Messages.Comp.ItemCard exposing (Texts, gb)
|
||||||
|
|
||||||
|
import Data.Direction exposing (Direction)
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.Data.Direction
|
||||||
|
import Messages.DateFormat
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -10,6 +14,9 @@ type alias Texts =
|
|||||||
, openAttachmentFile : String
|
, openAttachmentFile : String
|
||||||
, gotoDetail : String
|
, gotoDetail : String
|
||||||
, cycleAttachments : String
|
, cycleAttachments : String
|
||||||
|
, formatDateLong : Int -> String
|
||||||
|
, formatDateShort : Int -> String
|
||||||
|
, directionLabel : Direction -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -21,4 +28,7 @@ gb =
|
|||||||
, openAttachmentFile = "Open attachment file"
|
, openAttachmentFile = "Open attachment file"
|
||||||
, gotoDetail = "Go to detail view"
|
, gotoDetail = "Go to detail view"
|
||||||
, cycleAttachments = "Cycle attachments"
|
, cycleAttachments = "Cycle attachments"
|
||||||
|
, formatDateLong = Messages.DateFormat.formatDateLong Messages.UiLanguage.English
|
||||||
|
, formatDateShort = Messages.DateFormat.formatDateShort Messages.UiLanguage.English
|
||||||
|
, directionLabel = Messages.Data.Direction.gb
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,8 @@ import Messages.Comp.ItemDetail.Notes
|
|||||||
import Messages.Comp.ItemDetail.SingleAttachment
|
import Messages.Comp.ItemDetail.SingleAttachment
|
||||||
import Messages.Comp.ItemMail
|
import Messages.Comp.ItemMail
|
||||||
import Messages.Comp.SentMails
|
import Messages.Comp.SentMails
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -34,6 +36,7 @@ type alias Texts =
|
|||||||
, createdOn : String
|
, createdOn : String
|
||||||
, lastUpdateOn : String
|
, lastUpdateOn : String
|
||||||
, sendingMailNow : String
|
, sendingMailNow : String
|
||||||
|
, formatDateTime : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -63,4 +66,5 @@ gb =
|
|||||||
, createdOn = "Created on"
|
, createdOn = "Created on"
|
||||||
, lastUpdateOn = "Last update on"
|
, lastUpdateOn = "Last update on"
|
||||||
, sendingMailNow = "Sending e-mail…"
|
, sendingMailNow = "Sending e-mail…"
|
||||||
|
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ module Messages.Comp.ItemDetail.EditForm exposing (Texts, gb)
|
|||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
import Messages.Comp.CustomFieldMultiInput
|
import Messages.Comp.CustomFieldMultiInput
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -21,6 +23,7 @@ type alias Texts =
|
|||||||
, addNewEquipment : String
|
, addNewEquipment : String
|
||||||
, editEquipment : String
|
, editEquipment : String
|
||||||
, suggestions : String
|
, suggestions : String
|
||||||
|
, formatDate : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,4 +50,5 @@ item visible. This message will disappear then.
|
|||||||
, addNewEquipment = "Add new equipment"
|
, addNewEquipment = "Add new equipment"
|
||||||
, editEquipment = "Edit equipment"
|
, editEquipment = "Edit equipment"
|
||||||
, suggestions = "Suggestions"
|
, suggestions = "Suggestions"
|
||||||
|
, formatDate = DF.formatDateLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module Messages.Comp.ItemDetail.ItemInfoHeader exposing (Texts, gb)
|
module Messages.Comp.ItemDetail.ItemInfoHeader exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -9,6 +11,7 @@ type alias Texts =
|
|||||||
, dueDate : String
|
, dueDate : String
|
||||||
, source : String
|
, source : String
|
||||||
, new : String
|
, new : String
|
||||||
|
, formatDate : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -19,4 +22,5 @@ gb =
|
|||||||
, dueDate = "Due Date"
|
, dueDate = "Due Date"
|
||||||
, source = "Source"
|
, source = "Source"
|
||||||
, new = "New"
|
, new = "New"
|
||||||
|
, formatDate = DF.formatDateLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
module Messages.Comp.SentMails exposing (Texts, gb)
|
module Messages.Comp.SentMails exposing (Texts, gb)
|
||||||
|
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
{ from : String
|
{ from : String
|
||||||
@ -8,6 +11,7 @@ type alias Texts =
|
|||||||
, subject : String
|
, subject : String
|
||||||
, sent : String
|
, sent : String
|
||||||
, sender : String
|
, sender : String
|
||||||
|
, formatDateTime : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -19,4 +23,5 @@ gb =
|
|||||||
, subject = "Subject"
|
, subject = "Subject"
|
||||||
, sent = "Sent"
|
, sent = "Sent"
|
||||||
, sender = "Sender"
|
, sender = "Sender"
|
||||||
|
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
module Messages.Comp.UserTable exposing (Texts, gb)
|
module Messages.Comp.UserTable exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -10,6 +12,7 @@ type alias Texts =
|
|||||||
, email : String
|
, email : String
|
||||||
, logins : String
|
, logins : String
|
||||||
, lastLogin : String
|
, lastLogin : String
|
||||||
|
, formatDateTime : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -21,4 +24,5 @@ gb =
|
|||||||
, email = "E-Mail"
|
, email = "E-Mail"
|
||||||
, logins = "Logins"
|
, logins = "Logins"
|
||||||
, lastLogin = "Last Login"
|
, lastLogin = "Last Login"
|
||||||
|
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
13
modules/webapp/src/main/elm/Messages/Data/Direction.elm
Normal file
13
modules/webapp/src/main/elm/Messages/Data/Direction.elm
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
module Messages.Data.Direction exposing (gb)
|
||||||
|
|
||||||
|
import Data.Direction exposing (Direction(..))
|
||||||
|
|
||||||
|
|
||||||
|
gb : Direction -> String
|
||||||
|
gb dir =
|
||||||
|
case dir of
|
||||||
|
Incoming ->
|
||||||
|
"Incoming"
|
||||||
|
|
||||||
|
Outgoing ->
|
||||||
|
"Outgoing"
|
433
modules/webapp/src/main/elm/Messages/DateFormat.elm
Normal file
433
modules/webapp/src/main/elm/Messages/DateFormat.elm
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
module Messages.DateFormat exposing
|
||||||
|
( format
|
||||||
|
, formatDateLong
|
||||||
|
, formatDateShort
|
||||||
|
, formatDateTimeLong
|
||||||
|
)
|
||||||
|
|
||||||
|
import DateFormat exposing (Token)
|
||||||
|
import DateFormat.Language as DL
|
||||||
|
import Messages.UiLanguage exposing (UiLanguage(..))
|
||||||
|
import Time
|
||||||
|
exposing
|
||||||
|
( Month(..)
|
||||||
|
, Weekday(..)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
type alias DateTimeMsg =
|
||||||
|
{ dateLong : List Token
|
||||||
|
, dateShort : List Token
|
||||||
|
, dateTimeLong : List Token
|
||||||
|
, dateTimeShort : List Token
|
||||||
|
, lang : DL.Language
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get : UiLanguage -> DateTimeMsg
|
||||||
|
get lang =
|
||||||
|
case lang of
|
||||||
|
English ->
|
||||||
|
gb
|
||||||
|
|
||||||
|
|
||||||
|
format : UiLanguage -> (DateTimeMsg -> List Token) -> Int -> String
|
||||||
|
format lang pattern millis =
|
||||||
|
let
|
||||||
|
msg =
|
||||||
|
get lang
|
||||||
|
|
||||||
|
fmt =
|
||||||
|
DateFormat.formatWithLanguage msg.lang (pattern msg)
|
||||||
|
in
|
||||||
|
fmt Time.utc (Time.millisToPosix millis)
|
||||||
|
|
||||||
|
|
||||||
|
formatDateTimeLong : UiLanguage -> Int -> String
|
||||||
|
formatDateTimeLong lang millis =
|
||||||
|
format lang .dateTimeLong millis
|
||||||
|
|
||||||
|
|
||||||
|
formatDateLong : UiLanguage -> Int -> String
|
||||||
|
formatDateLong lang millis =
|
||||||
|
format lang .dateLong millis
|
||||||
|
|
||||||
|
|
||||||
|
formatDateShort : UiLanguage -> Int -> String
|
||||||
|
formatDateShort lang millis =
|
||||||
|
format lang .dateShort millis
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Language Definitions
|
||||||
|
|
||||||
|
|
||||||
|
gb : DateTimeMsg
|
||||||
|
gb =
|
||||||
|
{ dateLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
]
|
||||||
|
, dateShort =
|
||||||
|
[ DateFormat.yearNumber
|
||||||
|
, DateFormat.text "/"
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "/"
|
||||||
|
, DateFormat.dayOfMonthFixed
|
||||||
|
]
|
||||||
|
, dateTimeLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, dateTimeShort =
|
||||||
|
[ DateFormat.yearNumber
|
||||||
|
, DateFormat.text "/"
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "/"
|
||||||
|
, DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, lang = DL.english
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
de : DateTimeMsg
|
||||||
|
de =
|
||||||
|
{ dateLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
]
|
||||||
|
, dateShort =
|
||||||
|
[ DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
]
|
||||||
|
, dateTimeLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ". "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, dateTimeShort =
|
||||||
|
[ DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, lang = german
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{-| French date formats; must be reviewed!
|
||||||
|
-}
|
||||||
|
fr : DateTimeMsg
|
||||||
|
fr =
|
||||||
|
{ dateLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
]
|
||||||
|
, dateShort =
|
||||||
|
[ DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
]
|
||||||
|
, dateTimeLong =
|
||||||
|
[ DateFormat.dayOfWeekNameAbbreviated
|
||||||
|
, DateFormat.text ". "
|
||||||
|
, DateFormat.dayOfMonthSuffix
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.monthNameFull
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
, DateFormat.text ", "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, dateTimeShort =
|
||||||
|
[ DateFormat.dayOfMonthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.monthFixed
|
||||||
|
, DateFormat.text "."
|
||||||
|
, DateFormat.yearNumber
|
||||||
|
, DateFormat.text " "
|
||||||
|
, DateFormat.hourMilitaryNumber
|
||||||
|
, DateFormat.text ":"
|
||||||
|
, DateFormat.minuteFixed
|
||||||
|
]
|
||||||
|
, lang = french
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Languages for the DateFormat module
|
||||||
|
-- French
|
||||||
|
|
||||||
|
|
||||||
|
{-| The French language!
|
||||||
|
-}
|
||||||
|
french : DL.Language
|
||||||
|
french =
|
||||||
|
DL.Language
|
||||||
|
toFrenchMonthName
|
||||||
|
toFrenchMonthAbbreviation
|
||||||
|
toFrenchWeekdayName
|
||||||
|
(toFrenchWeekdayName >> String.left 3)
|
||||||
|
toEnglishAmPm
|
||||||
|
toFrenchOrdinalSuffix
|
||||||
|
|
||||||
|
|
||||||
|
toFrenchMonthName : Month -> String
|
||||||
|
toFrenchMonthName month =
|
||||||
|
case month of
|
||||||
|
Jan ->
|
||||||
|
"janvier"
|
||||||
|
|
||||||
|
Feb ->
|
||||||
|
"février"
|
||||||
|
|
||||||
|
Mar ->
|
||||||
|
"mars"
|
||||||
|
|
||||||
|
Apr ->
|
||||||
|
"avril"
|
||||||
|
|
||||||
|
May ->
|
||||||
|
"mai"
|
||||||
|
|
||||||
|
Jun ->
|
||||||
|
"juin"
|
||||||
|
|
||||||
|
Jul ->
|
||||||
|
"juillet"
|
||||||
|
|
||||||
|
Aug ->
|
||||||
|
"août"
|
||||||
|
|
||||||
|
Sep ->
|
||||||
|
"septembre"
|
||||||
|
|
||||||
|
Oct ->
|
||||||
|
"octobre"
|
||||||
|
|
||||||
|
Nov ->
|
||||||
|
"novembre"
|
||||||
|
|
||||||
|
Dec ->
|
||||||
|
"décembre"
|
||||||
|
|
||||||
|
|
||||||
|
toFrenchMonthAbbreviation : Month -> String
|
||||||
|
toFrenchMonthAbbreviation month =
|
||||||
|
case month of
|
||||||
|
Jan ->
|
||||||
|
"janv"
|
||||||
|
|
||||||
|
Feb ->
|
||||||
|
"févr"
|
||||||
|
|
||||||
|
Mar ->
|
||||||
|
"mars"
|
||||||
|
|
||||||
|
Apr ->
|
||||||
|
"avr"
|
||||||
|
|
||||||
|
May ->
|
||||||
|
"mai"
|
||||||
|
|
||||||
|
Jun ->
|
||||||
|
"juin"
|
||||||
|
|
||||||
|
Jul ->
|
||||||
|
"juil"
|
||||||
|
|
||||||
|
Aug ->
|
||||||
|
"août"
|
||||||
|
|
||||||
|
Sep ->
|
||||||
|
"sept"
|
||||||
|
|
||||||
|
Oct ->
|
||||||
|
"oct"
|
||||||
|
|
||||||
|
Nov ->
|
||||||
|
"nov"
|
||||||
|
|
||||||
|
Dec ->
|
||||||
|
"déc"
|
||||||
|
|
||||||
|
|
||||||
|
toFrenchWeekdayName : Weekday -> String
|
||||||
|
toFrenchWeekdayName weekday =
|
||||||
|
case weekday of
|
||||||
|
Mon ->
|
||||||
|
"lundi"
|
||||||
|
|
||||||
|
Tue ->
|
||||||
|
"mardi"
|
||||||
|
|
||||||
|
Wed ->
|
||||||
|
"mercredi"
|
||||||
|
|
||||||
|
Thu ->
|
||||||
|
"jeudi"
|
||||||
|
|
||||||
|
Fri ->
|
||||||
|
"vendredi"
|
||||||
|
|
||||||
|
Sat ->
|
||||||
|
"samedi"
|
||||||
|
|
||||||
|
Sun ->
|
||||||
|
"dimanche"
|
||||||
|
|
||||||
|
|
||||||
|
toFrenchOrdinalSuffix : Int -> String
|
||||||
|
toFrenchOrdinalSuffix n =
|
||||||
|
if n == 1 then
|
||||||
|
"er"
|
||||||
|
|
||||||
|
else
|
||||||
|
""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- German
|
||||||
|
|
||||||
|
|
||||||
|
{-| The German language!
|
||||||
|
-}
|
||||||
|
german : DL.Language
|
||||||
|
german =
|
||||||
|
let
|
||||||
|
withDot str =
|
||||||
|
str ++ "."
|
||||||
|
in
|
||||||
|
DL.Language
|
||||||
|
toGermanMonthName
|
||||||
|
(toGermanMonthName >> String.left 3 >> withDot)
|
||||||
|
toGermanWeekdayName
|
||||||
|
(toGermanWeekdayName >> String.left 2 >> withDot)
|
||||||
|
toEnglishAmPm
|
||||||
|
(\_ -> ".")
|
||||||
|
|
||||||
|
|
||||||
|
toGermanMonthName : Month -> String
|
||||||
|
toGermanMonthName month =
|
||||||
|
case month of
|
||||||
|
Jan ->
|
||||||
|
"Januar"
|
||||||
|
|
||||||
|
Feb ->
|
||||||
|
"Februar"
|
||||||
|
|
||||||
|
Mar ->
|
||||||
|
"März"
|
||||||
|
|
||||||
|
Apr ->
|
||||||
|
"April"
|
||||||
|
|
||||||
|
May ->
|
||||||
|
"Mai"
|
||||||
|
|
||||||
|
Jun ->
|
||||||
|
"Juni"
|
||||||
|
|
||||||
|
Jul ->
|
||||||
|
"Juli"
|
||||||
|
|
||||||
|
Aug ->
|
||||||
|
"August"
|
||||||
|
|
||||||
|
Sep ->
|
||||||
|
"September"
|
||||||
|
|
||||||
|
Oct ->
|
||||||
|
"Oktober"
|
||||||
|
|
||||||
|
Nov ->
|
||||||
|
"November"
|
||||||
|
|
||||||
|
Dec ->
|
||||||
|
"Dezember"
|
||||||
|
|
||||||
|
|
||||||
|
toGermanWeekdayName : Weekday -> String
|
||||||
|
toGermanWeekdayName weekday =
|
||||||
|
case weekday of
|
||||||
|
Mon ->
|
||||||
|
"Montag"
|
||||||
|
|
||||||
|
Tue ->
|
||||||
|
"Dienstag"
|
||||||
|
|
||||||
|
Wed ->
|
||||||
|
"Mittwoch"
|
||||||
|
|
||||||
|
Thu ->
|
||||||
|
"Donnerstag"
|
||||||
|
|
||||||
|
Fri ->
|
||||||
|
"Freitag"
|
||||||
|
|
||||||
|
Sat ->
|
||||||
|
"Samstag"
|
||||||
|
|
||||||
|
Sun ->
|
||||||
|
"Sonntag"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
--- Copy from DateFormat.Language
|
||||||
|
|
||||||
|
|
||||||
|
toEnglishAmPm : Int -> String
|
||||||
|
toEnglishAmPm hour =
|
||||||
|
if hour > 11 then
|
||||||
|
"pm"
|
||||||
|
|
||||||
|
else
|
||||||
|
"am"
|
@ -1,6 +1,8 @@
|
|||||||
module Messages.Page.Queue exposing (Texts, gb)
|
module Messages.Page.Queue exposing (Texts, gb)
|
||||||
|
|
||||||
import Messages.Basics
|
import Messages.Basics
|
||||||
|
import Messages.DateFormat as DF
|
||||||
|
import Messages.UiLanguage
|
||||||
|
|
||||||
|
|
||||||
type alias Texts =
|
type alias Texts =
|
||||||
@ -23,6 +25,7 @@ type alias Texts =
|
|||||||
, retries : String
|
, retries : String
|
||||||
, changePriority : String
|
, changePriority : String
|
||||||
, prio : String
|
, prio : String
|
||||||
|
, formatDateTime : Int -> String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -47,4 +50,5 @@ gb =
|
|||||||
, retries = "Retries"
|
, retries = "Retries"
|
||||||
, changePriority = "Change priority of this job"
|
, changePriority = "Change priority of this job"
|
||||||
, prio = "Prio"
|
, prio = "Prio"
|
||||||
|
, formatDateTime = DF.formatDateTimeLong Messages.UiLanguage.English
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import Html.Events exposing (onClick)
|
|||||||
import Messages.Page.Queue exposing (Texts)
|
import Messages.Page.Queue exposing (Texts)
|
||||||
import Page.Queue.Data exposing (..)
|
import Page.Queue.Data exposing (..)
|
||||||
import Styles as S
|
import Styles as S
|
||||||
import Util.Time exposing (formatDateTime, formatIsoDateTime)
|
import Util.Time exposing (formatIsoDateTime)
|
||||||
|
|
||||||
|
|
||||||
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
viewSidebar : Texts -> Bool -> Flags -> UiSettings -> Model -> Html Msg
|
||||||
@ -397,7 +397,7 @@ renderInfoCard texts model job =
|
|||||||
, div [ class "flex flex-row space-x-2 items-center flex-wrap" ]
|
, div [ class "flex flex-row space-x-2 items-center flex-wrap" ]
|
||||||
[ div [ class "flex flex-row justify-start " ]
|
[ div [ class "flex flex-row justify-start " ]
|
||||||
[ div [ class "text-xs font-semibold" ]
|
[ div [ class "text-xs font-semibold" ]
|
||||||
[ Util.Time.formatDateTime job.submitted |> text
|
[ texts.formatDateTime job.submitted |> text
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
, div [ class "flex-grow flex flex-row justify-end space-x-2 flex-wrap" ]
|
, div [ class "flex-grow flex flex-row justify-end space-x-2 flex-wrap" ]
|
||||||
|
@ -1,47 +1,9 @@
|
|||||||
module Util.Time exposing
|
module Util.Time exposing (formatIsoDateTime)
|
||||||
( formatDate
|
|
||||||
, formatDateShort
|
|
||||||
, formatDateTime
|
|
||||||
, formatIsoDateTime
|
|
||||||
)
|
|
||||||
|
|
||||||
import DateFormat
|
import DateFormat
|
||||||
import Time exposing (Posix, Zone, utc)
|
import Time exposing (Posix, Zone, utc)
|
||||||
|
|
||||||
|
|
||||||
dateFormatter : Zone -> Posix -> String
|
|
||||||
dateFormatter =
|
|
||||||
DateFormat.format
|
|
||||||
[ DateFormat.dayOfWeekNameAbbreviated
|
|
||||||
, DateFormat.text ", "
|
|
||||||
, DateFormat.monthNameFull
|
|
||||||
, DateFormat.text " "
|
|
||||||
, DateFormat.dayOfMonthSuffix
|
|
||||||
, DateFormat.text ", "
|
|
||||||
, DateFormat.yearNumber
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
dateFormatterShort : Zone -> Posix -> String
|
|
||||||
dateFormatterShort =
|
|
||||||
DateFormat.format
|
|
||||||
[ DateFormat.yearNumber
|
|
||||||
, DateFormat.text "/"
|
|
||||||
, DateFormat.monthFixed
|
|
||||||
, DateFormat.text "/"
|
|
||||||
, DateFormat.dayOfMonthFixed
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
timeFormatter : Zone -> Posix -> String
|
|
||||||
timeFormatter =
|
|
||||||
DateFormat.format
|
|
||||||
[ DateFormat.hourMilitaryNumber
|
|
||||||
, DateFormat.text ":"
|
|
||||||
, DateFormat.minuteFixed
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
isoDateTimeFormatter : Zone -> Posix -> String
|
isoDateTimeFormatter : Zone -> Posix -> String
|
||||||
isoDateTimeFormatter =
|
isoDateTimeFormatter =
|
||||||
DateFormat.format
|
DateFormat.format
|
||||||
@ -64,44 +26,7 @@ timeZone =
|
|||||||
utc
|
utc
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{- Format millis into "Wed, 10. Jan 2018, 18:57" -}
|
|
||||||
|
|
||||||
|
|
||||||
formatDateTime : Int -> String
|
|
||||||
formatDateTime millis =
|
|
||||||
formatDate millis ++ ", " ++ formatTime millis
|
|
||||||
|
|
||||||
|
|
||||||
formatIsoDateTime : Int -> String
|
formatIsoDateTime : Int -> String
|
||||||
formatIsoDateTime millis =
|
formatIsoDateTime millis =
|
||||||
Time.millisToPosix millis
|
Time.millisToPosix millis
|
||||||
|> isoDateTimeFormatter timeZone
|
|> isoDateTimeFormatter timeZone
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{- Format millis into "18:57". The current time (not the duration of
|
|
||||||
the millis).
|
|
||||||
-}
|
|
||||||
|
|
||||||
|
|
||||||
formatTime : Int -> String
|
|
||||||
formatTime millis =
|
|
||||||
Time.millisToPosix millis
|
|
||||||
|> timeFormatter timeZone
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{- Format millis into "Wed, 10. Jan 2018" -}
|
|
||||||
|
|
||||||
|
|
||||||
formatDate : Int -> String
|
|
||||||
formatDate millis =
|
|
||||||
Time.millisToPosix millis
|
|
||||||
|> dateFormatter timeZone
|
|
||||||
|
|
||||||
|
|
||||||
formatDateShort : Int -> String
|
|
||||||
formatDateShort millis =
|
|
||||||
Time.millisToPosix millis
|
|
||||||
|> dateFormatterShort timeZone
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user