mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-28 09:45:07 +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
|
-- Equipments
|
||||||
|
|
||||||
|
|
||||||
getEquipments : Flags -> (Result Http.Error EquipmentList -> msg) -> Cmd msg
|
getEquipments : Flags -> String -> (Result Http.Error EquipmentList -> msg) -> Cmd msg
|
||||||
getEquipments flags receive =
|
getEquipments flags query receive =
|
||||||
Http2.authGet
|
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
|
, account = getAccount flags
|
||||||
, expect = Http.expectJson receive Api.Model.EquipmentList.decoder
|
, expect = Http.expectJson receive Api.Model.EquipmentList.decoder
|
||||||
}
|
}
|
||||||
|
@ -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 | formModel = m2 }, Cmd.map FormMsg c2 )
|
( { model | formModel = m2 }, Cmd.map FormMsg c2 )
|
||||||
|
|
||||||
LoadEquipments ->
|
LoadEquipments ->
|
||||||
( { model | loading = True }, Api.getEquipments flags EquipmentResp )
|
( { model | loading = True }, Api.getEquipments flags "" EquipmentResp )
|
||||||
|
|
||||||
EquipmentResp (Ok equipments) ->
|
EquipmentResp (Ok equipments) ->
|
||||||
let
|
let
|
||||||
@ -186,6 +187,9 @@ update flags msg model =
|
|||||||
in
|
in
|
||||||
( { model | deleteConfirm = cm }, cmd )
|
( { model | deleteConfirm = cm }, cmd )
|
||||||
|
|
||||||
|
SetQuery str ->
|
||||||
|
( model, Api.getEquipments flags str EquipmentResp )
|
||||||
|
|
||||||
|
|
||||||
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 InitNewEquipment ]
|
[ div [ class "ui secondary menu" ]
|
||||||
[ i [ class "plus icon" ] []
|
[ div [ class "ui container" ]
|
||||||
, text "Create new"
|
[ 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)
|
, Html.map TableMsg (Comp.EquipmentTable.view model.tableModel)
|
||||||
, div
|
, div
|
||||||
|
@ -170,7 +170,7 @@ getOptions flags =
|
|||||||
[ 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
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ update flags msg model =
|
|||||||
, 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
|
||||||
, Cmd.map UntilDateMsg dpc
|
, Cmd.map UntilDateMsg dpc
|
||||||
, Cmd.map FromDateMsg dpc
|
, Cmd.map FromDateMsg dpc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user