Add a tracker

This commit is contained in:
2022-02-18 01:28:23 +02:00
parent b72fd3029f
commit 77997d7ca6
4 changed files with 137 additions and 0 deletions

View File

@@ -1120,6 +1120,93 @@ module.exports = function (options) {
})
router.route('/:id/tracker')
.get(function(request, response, next) {
db.Project.findByPk(request.params.id, {
include: [
{
association: db.Project.Owner,
include: [
{
association: db.Owner.OwnerEntities,
include: [
{
association: db.OwnerEntity.Entity,
include: [
{
association: db.Entity.EntityUsers,
required: false,
where: {
userId: request.user?.id ?? null
}
}
]
}
]
}
]
}
]
}).then(async (project) => {
if (project) {
db.TranslationChapter.findAll({
include: [
{
association: db.TranslationChapter.TranslationChunks,
include: [
{
association: db.TranslationChunk.Translation
}
]
},
{
association: db.TranslationChapter.TranslationArtifactVersion,
required: true,
include: [
{
association: db.TranslationArtifactVersion.ProjectTranslationArtifactVersions,
required: true,
where: {
projectId: request.params.id
},
},
{
association: db.TranslationArtifactVersion.ArtifactVersion,
include: [
{
association: db.ArtifactVersion.ProjectArtifactVersions
},
{
association: db.ArtifactVersion.Artifact,
include: [
{
association: db.Artifact.Dialect
}
]
}
]
},
{
association: db.TranslationArtifactVersion.Dialect
},
]
}
]
}).then(translationChapters => {
response.display("project-tracker", {
user: request.user,
project: project,
translationChapters: translationChapters
})
}).catch(error => {
next(error)
})
} else {
next()
}
})
})
const getProjectArtifactVersion = (userId, project, artifactVersion) => {
if (project.projectArtifactVersions.length == 0) {
return db.ProjectArtifactVersion.create({

View File

@@ -48,4 +48,10 @@ html {
.bitcoin-address {
word-wrap: break-word;
}
.tracker-title-cell {
width: 1rem;
text-overflow: ellipsis;
overflow: hidden;
}

View File

@@ -0,0 +1,41 @@
extend templates/layout.pug
block content
-
const isOwnedByUser = project.owner.ownerEntities.some(ownerEntity => {
return ownerEntity.entity.entityUsers.some(entityUser => {
return entityUser.userId == user?.id
})
})
.container
.center
h1= project.name
p.flow-text= project.description
if isOwnedByUser
.row
.col.s12
a.btn.black(href=`/projects/${project.id}/tracker/trail`) audit trail
.divider
table
thead
tr
th Title Text
th Artifact
th Chapter
th translator
th proof reader
tbody
each translationChapter in translationChapters.sort((a, b) => a.index - b.index)
tr
-
const title = translationChapter.translationChunks.length > 0 ? translationChapter.translationChunks.sort((a, b) => a.index - b.index)[0].text : "N/A"
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}
td= translationChapter.index
td
td

View File

@@ -17,6 +17,9 @@ block content
.row
.col.s12
a.btn.black(href=`/projects/${project.id}/campaign`) funding campaign
.row
.col.s12
a.btn.black(href=`/projects/${project.id}/tracker`) tracker
.row
.col.s12
form(action=`/projects/${project.id}/sheets`, method="post")