From 3141d8ed4867c394b0b1978151c1600a98d6ccbe Mon Sep 17 00:00:00 2001 From: Kgothatso Ngako Date: Mon, 27 Dec 2021 00:14:48 +0200 Subject: [PATCH] Some UX rework... --- server/router/translate/index.js | 21 +++++++++++++-------- server/views/translate-chunk.pug | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/server/router/translate/index.js b/server/router/translate/index.js index ad01b76..10ba8ac 100644 --- a/server/router/translate/index.js +++ b/server/router/translate/index.js @@ -130,13 +130,18 @@ module.exports = function (options) { }).then(chunks => { if (chunks.length > 0) { const chunk = chunks.find(chunk => chunk.index == Number(request.params.chunkIndex)) - response.display("translate-chunk", { - user: request.user, - pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`, - chunk: chunk, - previousChunk: chunks.find(chunk => chunk.index == previousIndex), - nextChunk: chunks.find(chunk => chunk.index == nextIndex) - }) + if (chunk) { + response.display("translate-chunk", { + user: request.user, + pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`, + chunk: chunk, + previousChunk: chunks.find(chunk => chunk.index == previousIndex), + nextChunk: chunks.find(chunk => chunk.index == nextIndex) + }) + } else { + response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}`) + } + } else { next() } @@ -194,7 +199,7 @@ module.exports = function (options) { translationEntryVersionId: request.params.id }) } - response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}/t/${request.params.chunkIndex}`) + response.redirect(`/translate/${request.params.id}/chapter/${request.params.chapterId}/t/${Number(request.params.chunkIndex)+1}`) } else { next() } diff --git a/server/views/translate-chunk.pug b/server/views/translate-chunk.pug index 8f4d26f..45d92a2 100644 --- a/server/views/translate-chunk.pug +++ b/server/views/translate-chunk.pug @@ -3,7 +3,8 @@ extend templates/layout.pug block content .container .center - h1 Translate into #{chunk.chapter.entryVersion.translationEntryVersions[0].name} + h1 Translate into + a(href=`/translate/${chunk.chapter.entryVersion.translationEntryVersions[0].id}/chapter/${chunk.chapter.id}`) #{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.index}`, method="post")