mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Change custom fields for multiple items
This commit is contained in:
@ -56,7 +56,7 @@ object CustomFieldRoutes {
|
||||
|
||||
case DELETE -> Root / Ident(id) =>
|
||||
for {
|
||||
res <- backend.customFields.delete(id, user.account.collective)
|
||||
res <- backend.customFields.delete(user.account.collective, id)
|
||||
resp <- Ok(convertResult(res))
|
||||
} yield resp
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import cats.implicits._
|
||||
|
||||
import docspell.backend.BackendApp
|
||||
import docspell.backend.auth.AuthToken
|
||||
import docspell.backend.ops.OCustomFields.{RemoveValue, SetValue}
|
||||
import docspell.common.{Ident, ItemState}
|
||||
import docspell.restapi.model._
|
||||
import docspell.restserver.conv.Conversions
|
||||
@ -180,6 +181,29 @@ object ItemMultiRoutes {
|
||||
)
|
||||
resp <- Ok(res)
|
||||
} yield resp
|
||||
|
||||
case req @ PUT -> Root / "customfield" =>
|
||||
for {
|
||||
json <- req.as[ItemsAndFieldValue]
|
||||
items <- readIds[F](json.items)
|
||||
res <- backend.customFields.setValueMultiple(
|
||||
items,
|
||||
SetValue(json.field.field, json.field.value, user.account.collective)
|
||||
)
|
||||
resp <- Ok(Conversions.basicResult(res))
|
||||
} yield resp
|
||||
|
||||
case req @ POST -> Root / "customfieldremove" =>
|
||||
for {
|
||||
json <- req.as[ItemsAndName]
|
||||
items <- readIds[F](json.items)
|
||||
field <- readId[F](json.name)
|
||||
res <- backend.customFields.deleteValue(
|
||||
RemoveValue(field, items, user.account.collective)
|
||||
)
|
||||
resp <- Ok(Conversions.basicResult(res, "Custom fields removed."))
|
||||
} yield resp
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -372,7 +372,7 @@ object ItemRoutes {
|
||||
case DELETE -> Root / Ident(id) / "customfield" / Ident(fieldId) =>
|
||||
for {
|
||||
res <- backend.customFields.deleteValue(
|
||||
RemoveValue(fieldId, id, user.account.collective)
|
||||
RemoveValue(fieldId, NonEmptyList.of(id), user.account.collective)
|
||||
)
|
||||
resp <- Ok(Conversions.basicResult(res, "Custom field value removed."))
|
||||
} yield resp
|
||||
|
Reference in New Issue
Block a user