mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-06-22 10:28:27 +00:00
Amend source form with tags and file-filter
Allow to define tags and a file filter per source.
This commit is contained in:
@ -524,21 +524,36 @@ trait Conversions {
|
||||
|
||||
// sources
|
||||
|
||||
def mkSource(s: RSource): Source =
|
||||
Source(
|
||||
s.sid,
|
||||
s.abbrev,
|
||||
s.description,
|
||||
s.counter,
|
||||
s.enabled,
|
||||
s.priority,
|
||||
s.folderId,
|
||||
s.created
|
||||
def mkSource(s: SourceData): SourceAndTags =
|
||||
SourceAndTags(
|
||||
Source(
|
||||
s.source.sid,
|
||||
s.source.abbrev,
|
||||
s.source.description,
|
||||
s.source.counter,
|
||||
s.source.enabled,
|
||||
s.source.priority,
|
||||
s.source.folderId,
|
||||
s.source.fileFilter,
|
||||
s.source.created
|
||||
),
|
||||
TagList(s.tags.length, s.tags.map(mkTag).toList)
|
||||
)
|
||||
|
||||
def newSource[F[_]: Sync](s: Source, cid: Ident): F[RSource] =
|
||||
timeId.map({ case (id, now) =>
|
||||
RSource(id, cid, s.abbrev, s.description, 0, s.enabled, s.priority, now, s.folder)
|
||||
RSource(
|
||||
id,
|
||||
cid,
|
||||
s.abbrev,
|
||||
s.description,
|
||||
0,
|
||||
s.enabled,
|
||||
s.priority,
|
||||
now,
|
||||
s.folder,
|
||||
s.fileFilter
|
||||
)
|
||||
})
|
||||
|
||||
def changeSource[F[_]: Sync](s: Source, coll: Ident): RSource =
|
||||
@ -551,7 +566,8 @@ trait Conversions {
|
||||
s.enabled,
|
||||
s.priority,
|
||||
s.created,
|
||||
s.folder
|
||||
s.folder,
|
||||
s.fileFilter
|
||||
)
|
||||
|
||||
// equipment
|
||||
|
@ -30,17 +30,17 @@ object SourceRoutes {
|
||||
|
||||
case req @ POST -> Root =>
|
||||
for {
|
||||
data <- req.as[Source]
|
||||
src <- newSource(data, user.account.collective)
|
||||
added <- backend.source.add(src)
|
||||
data <- req.as[SourceTagIn]
|
||||
src <- newSource(data.source, user.account.collective)
|
||||
added <- backend.source.add(src, data.tags)
|
||||
resp <- Ok(basicResult(added, "Source added."))
|
||||
} yield resp
|
||||
|
||||
case req @ PUT -> Root =>
|
||||
for {
|
||||
data <- req.as[Source]
|
||||
src = changeSource(data, user.account.collective)
|
||||
updated <- backend.source.update(src)
|
||||
data <- req.as[SourceTagIn]
|
||||
src = changeSource(data.source, user.account.collective)
|
||||
updated <- backend.source.update(src, data.tags)
|
||||
resp <- Ok(basicResult(updated, "Source updated."))
|
||||
} yield resp
|
||||
|
||||
|
Reference in New Issue
Block a user