From b21637f0157697024dcfae6c913a45549456dc9b Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Wed, 22 Dec 2021 22:34:58 +0200 Subject: [PATCH] Chunk page --- server/router/translate/index.js | 47 ++++++++++++++++++++++++++++++ server/views/translate-chapter.pug | 6 ++-- server/views/translate-chunk.pug | 14 +++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 server/views/translate-chunk.pug diff --git a/server/router/translate/index.js b/server/router/translate/index.js index 9e81ff3..5f314ad 100644 --- a/server/router/translate/index.js +++ b/server/router/translate/index.js @@ -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; }; \ No newline at end of file diff --git a/server/views/translate-chapter.pug b/server/views/translate-chapter.pug index a3da1d3..813c1b0 100644 --- a/server/views/translate-chapter.pug +++ b/server/views/translate-chapter.pug @@ -21,16 +21,16 @@ block content tr td= chunk.text td - if chunk.ossified + if chunk.translated span= chunk.text else if chunk.translation span= chunk.translation.text else span= chunk.text.replaceAll(/./g, "  ") td - if chunk.ossified + if chunk.translated span nothing else if chunk.translation a.btn.blue review else - a.btn.black translate \ No newline at end of file + a.btn.black(href=`/translate/${chapter.entry.translationEntries[0].id}/chapter/${chapter.id}/t/${chunk.id}`) translate \ No newline at end of file diff --git a/server/views/translate-chunk.pug b/server/views/translate-chunk.pug new file mode 100644 index 0000000..4fca0c7 --- /dev/null +++ b/server/views/translate-chunk.pug @@ -0,0 +1,14 @@ +extend templates/layout.pug + +block content + .container + .center + h1 Translate into #{chunk.chapter.entry.translationEntries[0].name} + + form.row(action=`/translate/${chunk.chapter.entry.translationEntries[0].id}/chapter/${chunk.chapter.id}/t/${chunk.id}`) + .col.s12.m6.input-field + textarea#original-text.materialize-textarea(name="originalText")= 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 \ No newline at end of file