Add search field to person view

This commit is contained in:
Eike Kettner
2020-01-02 20:42:51 +01:00
parent 906ee9034e
commit 7ba413e49f
2 changed files with 38 additions and 9 deletions

View File

@ -16,7 +16,7 @@ import Comp.YesNoDimmer
import Data.Flags exposing (Flags)
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onSubmit)
import Html.Events exposing (onClick, onInput, onSubmit)
import Http
import Util.Http
import Util.Maybe
@ -59,6 +59,7 @@ type Msg
| SubmitResp (Result Http.Error BasicResult)
| YesNoMsg Comp.YesNoDimmer.Msg
| RequestDelete
| SetQuery String
update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -101,7 +102,7 @@ update flags msg model =
( { model | formModel = m2 }, Cmd.map FormMsg c2 )
LoadPersons ->
( { model | loading = True }, Api.getPersons flags PersonResp )
( { model | loading = True }, Api.getPersons flags "" PersonResp )
PersonResp (Ok orgs) ->
let
@ -186,6 +187,9 @@ update flags msg model =
in
( { model | deleteConfirm = cm }, cmd )
SetQuery str ->
( model, Api.getPersons flags str PersonResp )
view : Model -> Html Msg
view model =
@ -199,9 +203,33 @@ view model =
viewTable : Model -> Html Msg
viewTable model =
div []
[ button [ class "ui basic button", onClick InitNewPerson ]
[ i [ class "plus icon" ] []
, text "Create new"
[ div [ class "ui secondary menu" ]
[ div [ class "ui container" ]
[ div [ class "fitted-item" ]
[ div [ class "ui icon input" ]
[ input
[ type_ "text"
, onInput SetQuery
, placeholder "Search"
]
[]
, i [ class "ui search icon" ]
[]
]
]
, div [ class "right menu" ]
[ div [ class "fitted-item" ]
[ a
[ class "ui primary button"
, href "#"
, onClick InitNewPerson
]
[ i [ class "plus icon" ] []
, text "New Person"
]
]
]
]
]
, Html.map TableMsg (Comp.PersonTable.view model.tableModel)
, div