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;
|
||||
};
|
||||
@@ -6,13 +6,16 @@ block content
|
||||
h1 Translate into #{chunk.chapter.entryVersion.translationEntryVersions[0].name}
|
||||
|
||||
//- TODO: Show previous...
|
||||
form.row(action=`/translate/${chunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chunk.chapter.id}/t/${chunk.id}`)
|
||||
form.row(action=`/translate/${chunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chunk.chapter.id}/t/${chunk.index}`, method="post")
|
||||
.col.s12.m6.input-field
|
||||
textarea#original-text.materialize-textarea(name="originalText")= chunk.text
|
||||
textarea#original-text.materialize-textarea(name="originalText", readonly)= chunk.text
|
||||
label(for="original-text") Original Text
|
||||
.col.s12.m6.input-field
|
||||
textarea#translated-text.materialize-textarea(name="translatedText", placeholder=chunk.text)
|
||||
label(for="original-text") Translated Text
|
||||
.col.s12
|
||||
.center
|
||||
button.btn.black(type="submit") save
|
||||
|
||||
//- TODO: Show next...
|
||||
.row
|
||||
|
||||
Reference in New Issue
Block a user