Allow simple search when listing meta data

This commit is contained in:
Eike Kettner
2020-01-02 19:59:46 +01:00
parent eb6c483ef0
commit 8814de3c38
14 changed files with 163 additions and 46 deletions

View File

@ -19,9 +19,10 @@ object EquipmentRoutes {
import dsl._
HttpRoutes.of {
case GET -> Root =>
case req @ GET -> Root =>
val q = req.params.get("q").map(_.trim).filter(_.nonEmpty)
for {
data <- backend.equipment.findAll(user.account)
data <- backend.equipment.findAll(user.account, q)
resp <- Ok(EquipmentList(data.map(mkEquipment).toList))
} yield resp

View File

@ -20,15 +20,16 @@ object OrganizationRoutes {
import dsl._
HttpRoutes.of {
case GET -> Root :? FullQueryParamMatcher(full) =>
case req @ GET -> Root :? FullQueryParamMatcher(full) =>
val q = req.params.get("q").map(_.trim).filter(_.nonEmpty)
if (full.getOrElse(false)) {
for {
data <- backend.organization.findAllOrg(user.account)
data <- backend.organization.findAllOrg(user.account, q)
resp <- Ok(OrganizationList(data.map(mkOrg).toList))
} yield resp
} else {
for {
data <- backend.organization.findAllOrgRefs(user.account)
data <- backend.organization.findAllOrgRefs(user.account, q)
resp <- Ok(ReferenceList(data.map(mkIdName).toList))
} yield resp
}

View File

@ -23,15 +23,16 @@ object PersonRoutes {
import dsl._
HttpRoutes.of {
case GET -> Root :? FullQueryParamMatcher(full) =>
case req @ GET -> Root :? FullQueryParamMatcher(full) =>
val q = req.params.get("q").map(_.trim).filter(_.nonEmpty)
if (full.getOrElse(false)) {
for {
data <- backend.organization.findAllPerson(user.account)
data <- backend.organization.findAllPerson(user.account, q)
resp <- Ok(PersonList(data.map(mkPerson).toList))
} yield resp
} else {
for {
data <- backend.organization.findAllPersonRefs(user.account)
data <- backend.organization.findAllPersonRefs(user.account, q)
resp <- Ok(ReferenceList(data.map(mkIdName).toList))
} yield resp
}

View File

@ -20,9 +20,10 @@ object TagRoutes {
import dsl._
HttpRoutes.of {
case GET -> Root =>
case req @ GET -> Root =>
val q = req.params.get("q").map(_.trim).filter(_.nonEmpty)
for {
all <- backend.tag.findAll(user.account)
all <- backend.tag.findAll(user.account, q)
resp <- Ok(TagList(all.size, all.map(mkTag).toList))
} yield resp