Files
docspell/modules/webapp/src/main/elm/Comp/ScanMailboxList.elm
2021-09-21 22:35:38 +02:00

106 lines
2.7 KiB
Elm
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{-
Copyright 2020 Eike K. & Contributors
SPDX-License-Identifier: AGPL-3.0-or-later
-}
module Comp.ScanMailboxList exposing
( Action(..)
, Model
, Msg
, init
, update
, view2
)
import Api.Model.ScanMailboxSettings exposing (ScanMailboxSettings)
import Comp.Basic as B
import Html exposing (..)
import Html.Attributes exposing (..)
import Messages.Comp.ScanMailboxTable exposing (Texts)
import Styles as S
import Util.Html
type alias Model =
{}
type Msg
= EditSettings ScanMailboxSettings
type Action
= NoAction
| EditAction ScanMailboxSettings
init : Model
init =
{}
update : Msg -> Model -> ( Model, Action )
update msg model =
case msg of
EditSettings settings ->
( model, EditAction settings )
--- View2
view2 : Texts -> Model -> List ScanMailboxSettings -> Html Msg
view2 texts _ items =
div []
[ table [ class S.tableMain ]
[ thead []
[ tr []
[ th [ class "" ] []
, th [ class "" ]
[ i [ class "fa fa-check" ] []
]
, th [ class "text-left" ] [ text texts.summary ]
, th [ class "text-left mr-2" ] [ text "Schedule" ]
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text texts.connection ]
, th [ class "text-left mr-2 hidden md:table-cell" ] [ text texts.folders ]
, th [ class "text-left mr-2 hidden lg:table-cell" ] [ text texts.receivedSince ]
]
]
, tbody []
(List.map (viewItem2 texts) items)
]
]
viewItem2 : Texts -> ScanMailboxSettings -> Html Msg
viewItem2 texts item =
tr [ class S.tableRow ]
[ B.editLinkTableCell texts.basics.edit (EditSettings item)
, td [ class "w-px px-2" ]
[ Util.Html.checkbox2 item.enabled
]
, td [ class "text-left" ]
[ Maybe.withDefault "" item.summary |> text
]
, td [ class "mr-2" ]
[ code [ class "font-mono text-sm" ]
[ text item.schedule
]
]
, td [ class "text-left mr-2 hidden md:table-cell" ]
[ text item.imapConnection
]
, td [ class "text-left mr-2 hidden md:table-cell" ]
[ String.join ", " item.folders |> text
]
, td [ class "text-left mr-2 hidden lg:table-cell" ]
[ Maybe.map String.fromInt item.receivedSinceHours
|> Maybe.withDefault "-"
|> text
, text " h"
]
]