From f89bbf957321f91bd4b857d3275c28371679ce20 Mon Sep 17 00:00:00 2001 From: kngako Date: Sun, 19 Jun 2022 03:38:27 +0200 Subject: [PATCH] Tracker with filter ability --- server/router/projects/index.js | 16 +++++++++++++--- server/views/project-tracker.pug | 19 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/server/router/projects/index.js b/server/router/projects/index.js index af41882..c0b9685 100644 --- a/server/router/projects/index.js +++ b/server/router/projects/index.js @@ -1151,6 +1151,9 @@ module.exports = function (options) { if (project) { db.TranslationChapter.findAll({ include: [ + { + association: db.TranslationChapter.Chapter, + }, { association: db.TranslationChapter.TranslationChunks, include: [ @@ -1186,9 +1189,16 @@ module.exports = function (options) { } ] }, - { - association: db.TranslationArtifactVersion.Dialect - }, + request.query.dialectId ? { + association: db.TranslationArtifactVersion.Dialect, + required: true, + where: { + id: request.query.dialectId + } + } : { + association: db.TranslationArtifactVersion.Dialect, + } + , ] } ] diff --git a/server/views/project-tracker.pug b/server/views/project-tracker.pug index d3986de..28df7b1 100644 --- a/server/views/project-tracker.pug +++ b/server/views/project-tracker.pug @@ -13,6 +13,10 @@ block content p.flow-text= project.description + p.flow-text + - + const wordCount = translationChapters.reduce((totalWordCount, translationChapter) => totalWordCount+translationChapter.chapter.wordCount, 0) + span.chip #{wordCount.toLocaleString()} words if isOwnedByUser .row .col.s12 @@ -20,22 +24,27 @@ block content .divider - table + table.highlight thead tr th Title Text + th language th Artifact th Chapter th translator th proof reader + th editor tbody each translationChapter in translationChapters.sort((a, b) => a.index - b.index) - tr + tr(onclick=`window.location='/projects/${project.id}/tracker/${translationChapter.id}'`) + //- TODO: link to the translationChapter... - - const title = translationChapter.translationChunks.length > 0 ? translationChapter.translationChunks.sort((a, b) => a.index - b.index)[0].text : "N/A" + const title = translationChapter.chapter.name + td(title=title)= title td - a.tracker-title-cell(href=`/projects/${project.id}/tracker/${translationChapter.id}`, title=title)= title - td #{translationChapter.translationArtifactVersion.artifactVersion.artifact.name} - #{translationChapter.translationArtifactVersion.name} - #{translationChapter.translationArtifactVersion.artifactVersion.tag} + a(href=`/projects/${project.id}/tracker?dialectId=${translationChapter.translationArtifactVersion.dialect.id}`)= translationChapter.translationArtifactVersion.dialect.name + td #{translationChapter.translationArtifactVersion.artifactVersion.artifact.name} - #{translationChapter.translationArtifactVersion.artifactVersion.tag} td= translationChapter.index td + td td \ No newline at end of file