Display list of tasks on the frontend.

This commit is contained in:
Drew Galbraith 2024-07-05 23:37:43 -07:00
parent f3ccc4f194
commit c07df0b094
1 changed files with 34 additions and 2 deletions

View File

@ -2,7 +2,7 @@ module Dashboard exposing (Model, Msg, Task, init, update, view)
import Browser exposing (Document)
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.Events exposing (onClick, onInput)
import Http
@ -152,11 +152,43 @@ viewBody model =
Success tasks ->
div []
[ text ("Loaded " ++ String.fromInt (List.length tasks) ++ "tasks")
[ viewTaskList tasks
, 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 =
if model.createTaskCollapsed then