mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-10-22 13:20:12 +00:00
Using elm-format for all files
This commit is contained in:
@@ -1,83 +1,91 @@
|
||||
module Comp.UserTable exposing ( Model
|
||||
, emptyModel
|
||||
, Msg(..)
|
||||
, view
|
||||
, update)
|
||||
module Comp.UserTable exposing
|
||||
( Model
|
||||
, Msg(..)
|
||||
, emptyModel
|
||||
, update
|
||||
, view
|
||||
)
|
||||
|
||||
import Api.Model.User exposing (User)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onClick)
|
||||
import Data.Flags exposing (Flags)
|
||||
import Api.Model.User exposing (User)
|
||||
import Util.Time exposing (formatDateTime)
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ users: List User
|
||||
, selected: Maybe User
|
||||
{ users : List User
|
||||
, selected : Maybe User
|
||||
}
|
||||
|
||||
emptyModel: Model
|
||||
|
||||
emptyModel : Model
|
||||
emptyModel =
|
||||
{ users = []
|
||||
, selected = Nothing
|
||||
}
|
||||
|
||||
|
||||
type Msg
|
||||
= SetUsers (List User)
|
||||
| Select User
|
||||
| Deselect
|
||||
|
||||
update: Flags -> Msg -> Model -> (Model, Cmd Msg)
|
||||
|
||||
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
|
||||
update flags msg model =
|
||||
case msg of
|
||||
SetUsers list ->
|
||||
({model | users = list, selected = Nothing }, Cmd.none)
|
||||
( { model | users = list, selected = Nothing }, Cmd.none )
|
||||
|
||||
Select user ->
|
||||
({model | selected = Just user}, Cmd.none)
|
||||
( { model | selected = Just user }, Cmd.none )
|
||||
|
||||
Deselect ->
|
||||
({model | selected = Nothing}, Cmd.none)
|
||||
( { model | selected = Nothing }, Cmd.none )
|
||||
|
||||
|
||||
view: Model -> Html Msg
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
table [class "ui selectable table"]
|
||||
[thead []
|
||||
[tr []
|
||||
[th [class "collapsing"][text "Login"]
|
||||
,th [class "collapsing"][text "State"]
|
||||
,th [class "collapsing"][text "Email"]
|
||||
,th [class "collapsing"][text "Logins"]
|
||||
,th [class "collapsing"][text "Last Login"]
|
||||
,th [class "collapsing"][text "Created"]
|
||||
]
|
||||
]
|
||||
,tbody []
|
||||
table [ class "ui selectable table" ]
|
||||
[ thead []
|
||||
[ tr []
|
||||
[ th [ class "collapsing" ] [ text "Login" ]
|
||||
, th [ class "collapsing" ] [ text "State" ]
|
||||
, th [ class "collapsing" ] [ text "Email" ]
|
||||
, th [ class "collapsing" ] [ text "Logins" ]
|
||||
, th [ class "collapsing" ] [ text "Last Login" ]
|
||||
, th [ class "collapsing" ] [ text "Created" ]
|
||||
]
|
||||
]
|
||||
, tbody []
|
||||
(List.map (renderUserLine model) model.users)
|
||||
]
|
||||
|
||||
renderUserLine: Model -> User -> Html Msg
|
||||
|
||||
renderUserLine : Model -> User -> Html Msg
|
||||
renderUserLine model user =
|
||||
tr [classList [("active", model.selected == Just user)]
|
||||
,onClick (Select user)
|
||||
]
|
||||
[td [class "collapsing"]
|
||||
[text user.login
|
||||
]
|
||||
,td [class "collapsing"]
|
||||
[text user.state
|
||||
tr
|
||||
[ classList [ ( "active", model.selected == Just user ) ]
|
||||
, onClick (Select user)
|
||||
]
|
||||
[ td [ class "collapsing" ]
|
||||
[ text user.login
|
||||
]
|
||||
,td [class "collapsing"]
|
||||
[Maybe.withDefault "" user.email |> text
|
||||
, td [ class "collapsing" ]
|
||||
[ text user.state
|
||||
]
|
||||
,td [class "collapsing"]
|
||||
[String.fromInt user.loginCount |> text
|
||||
, td [ class "collapsing" ]
|
||||
[ Maybe.withDefault "" user.email |> text
|
||||
]
|
||||
,td [class "collapsing"]
|
||||
[Maybe.map formatDateTime user.lastLogin |> Maybe.withDefault "" |> text
|
||||
, td [ class "collapsing" ]
|
||||
[ String.fromInt user.loginCount |> text
|
||||
]
|
||||
,td [class "collapsing"]
|
||||
[formatDateTime user.created |> text
|
||||
, td [ class "collapsing" ]
|
||||
[ Maybe.map formatDateTime user.lastLogin |> Maybe.withDefault "" |> text
|
||||
]
|
||||
, td [ class "collapsing" ]
|
||||
[ formatDateTime user.created |> text
|
||||
]
|
||||
]
|
||||
|
Reference in New Issue
Block a user