Display list of tasks on the frontend.
This commit is contained in:
parent
f3ccc4f194
commit
c07df0b094
|
@ -2,7 +2,7 @@ module Dashboard exposing (Model, Msg, Task, init, update, view)
|
||||||
|
|
||||||
import Browser exposing (Document)
|
import Browser exposing (Document)
|
||||||
import Browser.Navigation as Nav
|
import Browser.Navigation as Nav
|
||||||
import Html exposing (Html, button, div, input, text, textarea)
|
import Html exposing (Html, button, div, input, li, text, textarea)
|
||||||
import Html.Attributes exposing (placeholder, value)
|
import Html.Attributes exposing (placeholder, value)
|
||||||
import Html.Events exposing (onClick, onInput)
|
import Html.Events exposing (onClick, onInput)
|
||||||
import Http
|
import Http
|
||||||
|
@ -152,11 +152,43 @@ viewBody model =
|
||||||
|
|
||||||
Success tasks ->
|
Success tasks ->
|
||||||
div []
|
div []
|
||||||
[ text ("Loaded " ++ String.fromInt (List.length tasks) ++ "tasks")
|
[ viewTaskList tasks
|
||||||
, viewCreate model
|
, viewCreate model
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
viewTaskList : List Task -> Html Msg
|
||||||
|
viewTaskList tasks =
|
||||||
|
div
|
||||||
|
[]
|
||||||
|
(text
|
||||||
|
("Loaded "
|
||||||
|
++ String.fromInt (List.length tasks)
|
||||||
|
++ "tasks"
|
||||||
|
)
|
||||||
|
:: List.map viewTaskListItem tasks
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
viewTaskListItem : Task -> Html Msg
|
||||||
|
viewTaskListItem task =
|
||||||
|
li []
|
||||||
|
[ text
|
||||||
|
(task.title
|
||||||
|
++ (case task.description of
|
||||||
|
Just "" ->
|
||||||
|
""
|
||||||
|
|
||||||
|
Just desc ->
|
||||||
|
": " ++ desc
|
||||||
|
|
||||||
|
_ ->
|
||||||
|
""
|
||||||
|
)
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
viewCreate : Model -> Html Msg
|
viewCreate : Model -> Html Msg
|
||||||
viewCreate model =
|
viewCreate model =
|
||||||
if model.createTaskCollapsed then
|
if model.createTaskCollapsed then
|
||||||
|
|
Loading…
Reference in New Issue