mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-10-22 13:20:12 +00:00
Allow to specify ordering when retrieving meta data
The query now searches in more fields. For example, when getting a list of tags, the query is applied to the tag name *and* category. When listing persons, the query now also looks in the associated organization name. This has been used to make some headers in the meta data tables clickable to sort the list accordingly. Refs: #965, #538
This commit is contained in:
@@ -23,6 +23,7 @@ import Comp.OrgForm
|
||||
import Comp.OrgTable
|
||||
import Comp.YesNoDimmer
|
||||
import Data.Flags exposing (Flags)
|
||||
import Data.OrganizationOrder exposing (OrganizationOrder)
|
||||
import Data.UiSettings exposing (UiSettings)
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
@@ -41,6 +42,7 @@ type alias Model =
|
||||
, loading : Bool
|
||||
, deleteConfirm : Comp.YesNoDimmer.Model
|
||||
, query : String
|
||||
, order : OrganizationOrder
|
||||
}
|
||||
|
||||
|
||||
@@ -65,6 +67,7 @@ emptyModel =
|
||||
, loading = False
|
||||
, deleteConfirm = Comp.YesNoDimmer.emptyModel
|
||||
, query = ""
|
||||
, order = Data.OrganizationOrder.NameAsc
|
||||
}
|
||||
|
||||
|
||||
@@ -87,7 +90,7 @@ update flags msg model =
|
||||
case msg of
|
||||
TableMsg m ->
|
||||
let
|
||||
( tm, tc ) =
|
||||
( tm, tc, maybeOrder ) =
|
||||
Comp.OrgTable.update flags m model.tableModel
|
||||
|
||||
( m2, c2 ) =
|
||||
@@ -100,6 +103,7 @@ update flags msg model =
|
||||
|
||||
else
|
||||
model.formError
|
||||
, order = Maybe.withDefault model.order maybeOrder
|
||||
}
|
||||
, Cmd.map TableMsg tc
|
||||
)
|
||||
@@ -111,8 +115,15 @@ update flags msg model =
|
||||
|
||||
Nothing ->
|
||||
( m2, Cmd.none )
|
||||
|
||||
( m4, c4 ) =
|
||||
if maybeOrder /= Nothing && maybeOrder /= Just model.order then
|
||||
update flags LoadOrgs m3
|
||||
|
||||
else
|
||||
( m3, Cmd.none )
|
||||
in
|
||||
( m3, Cmd.batch [ c2, c3 ] )
|
||||
( m4, Cmd.batch [ c2, c3, c4 ] )
|
||||
|
||||
FormMsg m ->
|
||||
let
|
||||
@@ -122,7 +133,13 @@ update flags msg model =
|
||||
( { model | formModel = m2 }, Cmd.map FormMsg c2 )
|
||||
|
||||
LoadOrgs ->
|
||||
( { model | loading = True }, Api.getOrganizations flags model.query OrgResp )
|
||||
( { model | loading = True }
|
||||
, Api.getOrganizations
|
||||
flags
|
||||
model.query
|
||||
model.order
|
||||
OrgResp
|
||||
)
|
||||
|
||||
OrgResp (Ok orgs) ->
|
||||
let
|
||||
@@ -212,7 +229,7 @@ update flags msg model =
|
||||
m =
|
||||
{ model | query = str }
|
||||
in
|
||||
( m, Api.getOrganizations flags str OrgResp )
|
||||
( m, Api.getOrganizations flags str model.order OrgResp )
|
||||
|
||||
|
||||
|
||||
@@ -250,7 +267,7 @@ viewTable2 texts model =
|
||||
]
|
||||
, rootClasses = "mb-4"
|
||||
}
|
||||
, Html.map TableMsg (Comp.OrgTable.view2 texts.orgTable model.tableModel)
|
||||
, Html.map TableMsg (Comp.OrgTable.view2 texts.orgTable model.order model.tableModel)
|
||||
, B.loadingDimmer
|
||||
{ active = model.loading
|
||||
, label = texts.basics.loading
|
||||
|
Reference in New Issue
Block a user