Capture trnaslation
This commit is contained in:
@@ -144,5 +144,63 @@ module.exports = function (options) {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
.post(function(request, response, next) {
|
||||
db.Chunk.findOne({
|
||||
where: {
|
||||
chapterId: request.params.chapterId,
|
||||
index: request.params.chunkIndex
|
||||
},
|
||||
include: [
|
||||
{
|
||||
association: db.Chunk.Translation
|
||||
},
|
||||
{
|
||||
association: db.Chunk.Chapter,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.EntryVersion,
|
||||
required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.EntryVersion.TranslationEntryVersions,
|
||||
required: true,
|
||||
where: {
|
||||
id: request.params.id
|
||||
}
|
||||
},
|
||||
{
|
||||
association: db.EntryVersion.Entry,
|
||||
include: [
|
||||
{
|
||||
association: db.Entry.Dialect
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (chunk) => {
|
||||
if (chunk) {
|
||||
if (chunk.translation) {
|
||||
chunk.translation.text = request.body.translatedText
|
||||
await chunk.translation.save()
|
||||
} else {
|
||||
translation = await db.Translation.create({
|
||||
chunkId: chunk.id,
|
||||
text: request.body.translatedText,
|
||||
translationEntryVersionId: request.params.id
|
||||
})
|
||||
}
|
||||
response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}/t/${request.params.chunkIndex}`)
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
return router;
|
||||
};
|
||||
Reference in New Issue
Block a user