Using elm-format for all files

This commit is contained in:
Eike Kettner
2019-12-29 21:55:12 +01:00
parent 546f1a6ee3
commit 2001cca88b
84 changed files with 7668 additions and 5079 deletions

View File

@ -1,85 +1,94 @@
module Comp.SourceTable exposing ( Model
, emptyModel
, Msg(..)
, view
, update)
module Comp.SourceTable exposing
( Model
, Msg(..)
, emptyModel
, update
, view
)
import Api.Model.Source exposing (Source)
import Data.Flags exposing (Flags)
import Data.Priority
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick)
import Data.Flags exposing (Flags)
import Data.Priority exposing (Priority)
import Api.Model.Source exposing (Source)
type alias Model =
{ sources: List Source
, selected: Maybe Source
{ sources : List Source
, selected : Maybe Source
}
emptyModel: Model
emptyModel : Model
emptyModel =
{ sources = []
, selected = Nothing
}
type Msg
= SetSources (List Source)
| Select Source
| Deselect
update: Flags -> Msg -> Model -> (Model, Cmd Msg)
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
update flags msg model =
case msg of
SetSources list ->
({model | sources = list, selected = Nothing }, Cmd.none)
( { model | sources = list, selected = Nothing }, Cmd.none )
Select source ->
({model | selected = Just source}, Cmd.none)
( { model | selected = Just source }, 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 "Abbrev"]
,th [class "collapsing"][text "Enabled"]
,th [class "collapsing"][text "Counter"]
,th [class "collapsing"][text "Priority"]
,th [][text "Id"]
]
]
,tbody []
table [ class "ui selectable table" ]
[ thead []
[ tr []
[ th [ class "collapsing" ] [ text "Abbrev" ]
, th [ class "collapsing" ] [ text "Enabled" ]
, th [ class "collapsing" ] [ text "Counter" ]
, th [ class "collapsing" ] [ text "Priority" ]
, th [] [ text "Id" ]
]
]
, tbody []
(List.map (renderSourceLine model) model.sources)
]
renderSourceLine: Model -> Source -> Html Msg
renderSourceLine : Model -> Source -> Html Msg
renderSourceLine model source =
tr [classList [("active", model.selected == Just source)]
,onClick (Select source)
]
[td [class "collapsing"]
[text source.abbrev
]
,td [class "collapsing"]
[if source.enabled then
i [class "check square outline icon"][]
else
i [class "minus square outline icon"][]
tr
[ classList [ ( "active", model.selected == Just source ) ]
, onClick (Select source)
]
[ td [ class "collapsing" ]
[ text source.abbrev
]
,td [class "collapsing"]
[source.counter |> String.fromInt |> text
, td [ class "collapsing" ]
[ if source.enabled then
i [ class "check square outline icon" ] []
else
i [ class "minus square outline icon" ] []
]
,td [class "collapsing"]
[Data.Priority.fromString source.priority
|> Maybe.map Data.Priority.toName
|> Maybe.withDefault source.priority
|> text
, td [ class "collapsing" ]
[ source.counter |> String.fromInt |> text
]
,td []
[text source.id
, td [ class "collapsing" ]
[ Data.Priority.fromString source.priority
|> Maybe.map Data.Priority.toName
|> Maybe.withDefault source.priority
|> text
]
, td []
[ text source.id
]
]