mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-25 16:45:05 +00:00
Add search field to equipment view
This commit is contained in:
parent
4e7315c2a9
commit
d90afa30aa
@ -318,10 +318,10 @@ deleteTag flags tag receive =
|
||||
-- Equipments
|
||||
|
||||
|
||||
getEquipments : Flags -> (Result Http.Error EquipmentList -> msg) -> Cmd msg
|
||||
getEquipments flags receive =
|
||||
getEquipments : Flags -> String -> (Result Http.Error EquipmentList -> msg) -> Cmd msg
|
||||
getEquipments flags query receive =
|
||||
Http2.authGet
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/equipment"
|
||||
{ url = flags.config.baseUrl ++ "/api/v1/sec/equipment?q=" ++ Url.percentEncode query
|
||||
, account = getAccount flags
|
||||
, expect = Http.expectJson receive Api.Model.EquipmentList.decoder
|
||||
}
|
||||
|
@ -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 )
|
||||
|
||||
LoadEquipments ->
|
||||
( { model | loading = True }, Api.getEquipments flags EquipmentResp )
|
||||
( { model | loading = True }, Api.getEquipments flags "" EquipmentResp )
|
||||
|
||||
EquipmentResp (Ok equipments) ->
|
||||
let
|
||||
@ -186,6 +187,9 @@ update flags msg model =
|
||||
in
|
||||
( { model | deleteConfirm = cm }, cmd )
|
||||
|
||||
SetQuery str ->
|
||||
( model, Api.getEquipments flags str EquipmentResp )
|
||||
|
||||
|
||||
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 InitNewEquipment ]
|
||||
[ 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 InitNewEquipment
|
||||
]
|
||||
[ i [ class "plus icon" ] []
|
||||
, text "New Equipment"
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
, Html.map TableMsg (Comp.EquipmentTable.view model.tableModel)
|
||||
, div
|
||||
|
@ -170,7 +170,7 @@ getOptions flags =
|
||||
[ Api.getTags flags "" GetTagsResp
|
||||
, Api.getOrgLight flags GetOrgResp
|
||||
, Api.getPersonsLight flags GetPersonResp
|
||||
, Api.getEquipments flags GetEquipResp
|
||||
, Api.getEquipments flags "" GetEquipResp
|
||||
]
|
||||
|
||||
|
||||
|
@ -208,7 +208,7 @@ update flags msg model =
|
||||
, Cmd.batch
|
||||
[ Api.getTags flags "" GetTagsResp
|
||||
, Api.getOrgLight flags GetOrgResp
|
||||
, Api.getEquipments flags GetEquipResp
|
||||
, Api.getEquipments flags "" GetEquipResp
|
||||
, Api.getPersonsLight flags GetPersonResp
|
||||
, Cmd.map UntilDateMsg dpc
|
||||
, Cmd.map FromDateMsg dpc
|
||||
|
Loading…
x
Reference in New Issue
Block a user