Add search field to tag view

This commit is contained in:
Eike Kettner 2020-01-02 20:48:23 +01:00
parent 7ba413e49f
commit 4e7315c2a9
4 changed files with 38 additions and 10 deletions

View File

@ -279,10 +279,10 @@ setCollectiveSettings flags settings receive =
-- Tags -- Tags
getTags : Flags -> (Result Http.Error TagList -> msg) -> Cmd msg getTags : Flags -> String -> (Result Http.Error TagList -> msg) -> Cmd msg
getTags flags receive = getTags flags query receive =
Http2.authGet Http2.authGet
{ url = flags.config.baseUrl ++ "/api/v1/sec/tag" { url = flags.config.baseUrl ++ "/api/v1/sec/tag?q=" ++ Url.percentEncode query
, account = getAccount flags , account = getAccount flags
, expect = Http.expectJson receive Api.Model.TagList.decoder , expect = Http.expectJson receive Api.Model.TagList.decoder
} }

View File

@ -167,7 +167,7 @@ type Msg
getOptions : Flags -> Cmd Msg getOptions : Flags -> Cmd Msg
getOptions flags = getOptions flags =
Cmd.batch Cmd.batch
[ Api.getTags flags GetTagsResp [ Api.getTags flags "" GetTagsResp
, Api.getOrgLight flags GetOrgResp , Api.getOrgLight flags GetOrgResp
, Api.getPersonsLight flags GetPersonResp , Api.getPersonsLight flags GetPersonResp
, Api.getEquipments flags GetEquipResp , Api.getEquipments flags GetEquipResp

View File

@ -206,7 +206,7 @@ update flags msg model =
noChange noChange
( { model | untilDateModel = dp, fromDateModel = dp, untilDueDateModel = dp, fromDueDateModel = dp } ( { model | untilDateModel = dp, fromDateModel = dp, untilDueDateModel = dp, fromDueDateModel = dp }
, Cmd.batch , Cmd.batch
[ Api.getTags flags GetTagsResp [ Api.getTags flags "" GetTagsResp
, Api.getOrgLight flags GetOrgResp , Api.getOrgLight flags GetOrgResp
, Api.getEquipments flags GetEquipResp , Api.getEquipments flags GetEquipResp
, Api.getPersonsLight flags GetPersonResp , Api.getPersonsLight flags GetPersonResp

View File

@ -16,7 +16,7 @@ import Comp.YesNoDimmer
import Data.Flags exposing (Flags) import Data.Flags exposing (Flags)
import Html exposing (..) import Html exposing (..)
import Html.Attributes exposing (..) import Html.Attributes exposing (..)
import Html.Events exposing (onClick, onSubmit) import Html.Events exposing (onClick, onInput, onSubmit)
import Http import Http
import Util.Http import Util.Http
import Util.Maybe import Util.Maybe
@ -59,6 +59,7 @@ type Msg
| SubmitResp (Result Http.Error BasicResult) | SubmitResp (Result Http.Error BasicResult)
| YesNoMsg Comp.YesNoDimmer.Msg | YesNoMsg Comp.YesNoDimmer.Msg
| RequestDelete | RequestDelete
| SetQuery String
update : Flags -> Msg -> Model -> ( Model, Cmd Msg ) update : Flags -> Msg -> Model -> ( Model, Cmd Msg )
@ -101,7 +102,7 @@ update flags msg model =
( { model | tagFormModel = m2 }, Cmd.map FormMsg c2 ) ( { model | tagFormModel = m2 }, Cmd.map FormMsg c2 )
LoadTags -> LoadTags ->
( { model | loading = True }, Api.getTags flags TagResp ) ( { model | loading = True }, Api.getTags flags "" TagResp )
TagResp (Ok tags) -> TagResp (Ok tags) ->
let let
@ -186,6 +187,9 @@ update flags msg model =
in in
( { model | deleteConfirm = cm }, cmd ) ( { model | deleteConfirm = cm }, cmd )
SetQuery str ->
( model, Api.getTags flags str TagResp )
view : Model -> Html Msg view : Model -> Html Msg
view model = view model =
@ -199,9 +203,33 @@ view model =
viewTable : Model -> Html Msg viewTable : Model -> Html Msg
viewTable model = viewTable model =
div [] div []
[ button [ class "ui basic button", onClick InitNewTag ] [ 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 InitNewTag
]
[ i [ class "plus icon" ] [] [ i [ class "plus icon" ] []
, text "Create new" , text "New Tag"
]
]
]
]
] ]
, Html.map TableMsg (Comp.TagTable.view model.tagTableModel) , Html.map TableMsg (Comp.TagTable.view model.tagTableModel)
, div , div