mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-04-05 02:49:32 +00:00
Return custom field values with search results
This commit is contained in:
parent
44459aecd0
commit
7b7f1e4d6d
@ -5090,6 +5090,10 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/Tag"
|
||||
customfields:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/components/schemas/ItemFieldValue"
|
||||
notes:
|
||||
description: |
|
||||
Some prefix of the item notes.
|
||||
|
@ -213,10 +213,11 @@ trait Conversions {
|
||||
i.concEquip.map(mkIdName),
|
||||
i.folder.map(mkIdName),
|
||||
i.fileCount,
|
||||
Nil,
|
||||
Nil,
|
||||
Nil, //attachments
|
||||
Nil, //tags
|
||||
Nil, //customfields
|
||||
i.notes,
|
||||
Nil
|
||||
Nil // highlight
|
||||
)
|
||||
|
||||
def mkItemLight(i: OFulltext.FtsItem): ItemLight = {
|
||||
@ -227,7 +228,11 @@ trait Conversions {
|
||||
|
||||
def mkItemLightWithTags(i: OItemSearch.ListItemWithTags): ItemLight =
|
||||
mkItemLight(i.item)
|
||||
.copy(tags = i.tags.map(mkTag), attachments = i.attachments.map(mkAttachmentLight))
|
||||
.copy(
|
||||
tags = i.tags.map(mkTag),
|
||||
attachments = i.attachments.map(mkAttachmentLight),
|
||||
customfields = i.customfields.map(mkItemFieldValue)
|
||||
)
|
||||
|
||||
private def mkAttachmentLight(qa: QItem.AttachmentLight): AttachmentLight =
|
||||
AttachmentLight(qa.id, qa.position, qa.name, qa.pageCount)
|
||||
|
@ -524,7 +524,8 @@ object QItem {
|
||||
case class ListItemWithTags(
|
||||
item: ListItem,
|
||||
tags: List[RTag],
|
||||
attachments: List[AttachmentLight]
|
||||
attachments: List[AttachmentLight],
|
||||
customfields: List[ItemFieldValue]
|
||||
)
|
||||
|
||||
/** Same as `findItems` but resolves the tags for each item. Note that
|
||||
@ -560,10 +561,12 @@ object QItem {
|
||||
tags <- Stream.eval(tagItems.traverse(ti => findTag(resolvedTags, ti)))
|
||||
attachs <- Stream.eval(findAttachmentLight(item.id))
|
||||
ftags = tags.flatten.filter(t => t.collective == collective)
|
||||
cfields <- Stream.eval(findCustomFieldValuesForItem(item.id))
|
||||
} yield ListItemWithTags(
|
||||
item,
|
||||
ftags.toList.sortBy(_.name),
|
||||
attachs.sortBy(_.position)
|
||||
attachs.sortBy(_.position),
|
||||
cfields.toList
|
||||
)
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user