Chunk page

This commit is contained in:
2021-12-22 22:34:58 +02:00
parent 072b35fd54
commit b21637f015
3 changed files with 64 additions and 3 deletions

View File

@@ -73,5 +73,52 @@ module.exports = function (options) {
next(error)
})
})
router.route('/:id/chapter/:chapterId/t/:chunkId')
.get(function(request, response, next) {
db.Chunk.findByPk(request.params.chunkId, {
include: [
{
association: db.Chunk.Translation
},
{
association: db.Chunk.Chapter,
where: {
id: request.params.chapterId
},
include: [
{
association: db.Chapter.Entry,
required: true,
include: [
{
association: db.Entry.TranslationEntries,
required: true,
where: {
id: request.params.id
}
},
{
association: db.Entry.Dialect
}
]
}
]
}
]
}).then(chunk => {
if (chunk) {
response.display("translate-chunk", {
user: request.user,
pageTitle: `Translate ${chunk.chapter.entry.name}`,
chunk: chunk
})
} else {
next()
}
}).catch(error => {
next(error)
})
})
return router;
};