Add ability to remove translator
This commit is contained in:
@@ -875,6 +875,21 @@ module.exports = function (options) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.TranslationChapter.TranslationChapterTranslators,
|
association: db.TranslationChapter.TranslationChapterTranslators,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationChapterTranslator.Translator,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entity.EntityEmail,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.EntityEmail.Email
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.TranslationChapter.TranslationChapterProofReaders,
|
association: db.TranslationChapter.TranslationChapterProofReaders,
|
||||||
@@ -1068,5 +1083,188 @@ module.exports = function (options) {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
router.route('/:id/chapter/:chapterId/translator/:translatorId')
|
||||||
|
.get(function(request, response, next) {
|
||||||
|
db.TranslationChapterTranslator.findByPk(request.params.translatorId, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationChapterTranslator.TranslationChapter,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationChapter.TranslationArtifactVersion,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.ArtifactVersion.Artifact,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Artifact.Dialect
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Artifact.Owner,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.OwnerEntity.Entity,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entity.EntityUsers,
|
||||||
|
required: true,
|
||||||
|
where: {
|
||||||
|
userId: request.user?.id ?? null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Dialect
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.BackTranslationFrom
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.TranslationArtifactVersionEditor,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationChapterTranslator.Translator,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entity.EntityEmail,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.EntityEmail.Email
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).then(translationChapterTranslator => {
|
||||||
|
if (translationChapterTranslator) {
|
||||||
|
response.display("translate-chapter-translator-remove", {
|
||||||
|
user: request.user,
|
||||||
|
pageTitle: `Translator ${translationChapterTranslator.name}`,
|
||||||
|
translationChapterTranslator: translationChapterTranslator
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
next(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.post(function(request, response, next) {
|
||||||
|
db.TranslationChapterTranslator.findByPk(request.params.translatorId, {
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationChapterTranslator.TranslationChapter,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationChapter.TranslationArtifactVersion,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.ArtifactVersion.Artifact,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Artifact.Dialect
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Artifact.Owner,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Owner.OwnerEntities,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.OwnerEntity.Entity,
|
||||||
|
required: true,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entity.EntityUsers,
|
||||||
|
required: true,
|
||||||
|
where: {
|
||||||
|
userId: request.user?.id ?? null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.Dialect
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.BackTranslationFrom
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationArtifactVersion.TranslationArtifactVersionEditor,
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.TranslationChapterTranslator.Translator,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.Entity.EntityEmail,
|
||||||
|
include: [
|
||||||
|
{
|
||||||
|
association: db.EntityEmail.Email
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}).then(async (translationChapterTranslator) => {
|
||||||
|
if (translationChapterTranslator) {
|
||||||
|
await translationChapterTranslator.destroy()
|
||||||
|
response.redirect(`/translate/${translationChapterTranslator.translationChapter.translationArtifactVersion.id}/chapter/${translationChapterTranslator.translationChapter.id}`)
|
||||||
|
} else {
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
next(error)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
return router;
|
return router;
|
||||||
};
|
};
|
||||||
@@ -73,4 +73,12 @@ html {
|
|||||||
vertical-align:middle;
|
vertical-align:middle;
|
||||||
margin-right:1em;
|
margin-right:1em;
|
||||||
color:white;
|
color:white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chip .remove {
|
||||||
|
cursor: pointer;
|
||||||
|
float: right;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 32px;
|
||||||
|
padding-left: 8px;
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,12 @@ block content
|
|||||||
p.flow-text
|
p.flow-text
|
||||||
span.chip #{translationChapter.chapter.wordCount.toLocaleString()} words
|
span.chip #{translationChapter.chapter.wordCount.toLocaleString()} words
|
||||||
|
|
||||||
|
if translationChapter.translationChapterTranslators.length > 0
|
||||||
|
p.flow-text Translators
|
||||||
|
each translationChapterTranslator in translationChapter.translationChapterTranslators
|
||||||
|
span.chip= translatorDisplayName(translationChapterTranslator)
|
||||||
|
a(href=`/translate/${translationChapter.translationArtifactVersion.id}/chapter/${translationChapter.id}/translator/${translationChapterTranslator.id}`)
|
||||||
|
i.remove.material-icons close
|
||||||
p.flow-text Add translator
|
p.flow-text Add translator
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
17
server/views/translate-chapter-translator-remove.pug
Normal file
17
server/views/translate-chapter-translator-remove.pug
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
extend templates/layout.pug
|
||||||
|
|
||||||
|
block content
|
||||||
|
.container
|
||||||
|
.center
|
||||||
|
h1 #{translationChapterTranslator.translationChapter.translationArtifactVersion.artifactVersion.artifact.name} - #{translationChapterTranslator.translationChapter.translationArtifactVersion.artifactVersion.tag}
|
||||||
|
p.flow-text Remove #{translatorDisplayName(translationChapterTranslator)}
|
||||||
|
|
||||||
|
.row
|
||||||
|
form.col.s12(action=`/translate/${translationChapterTranslator.translationChapter.translationArtifactVersion.id}/chapter/${translationChapterTranslator.translationChapter.id}/translator/${translationChapterTranslator.id}`, method="post")
|
||||||
|
.row
|
||||||
|
.input-field.col.s12
|
||||||
|
input#confirmation(type="text", name="confirmation", pattern=translatorDisplayName(translationChapterTranslator).replace(/.+$/g, '\\$&'), placeholder="Confirm translator removal", required=true, autocomplete="off")
|
||||||
|
label(for="confirmation")= `Please type '${translatorDisplayName(translationChapterTranslator)}' to confirm removal`
|
||||||
|
.input-field.col.s12
|
||||||
|
button.btn(type="submit") Remove Translator
|
||||||
|
|
||||||
@@ -13,13 +13,13 @@ block content
|
|||||||
.col.s12.m4
|
.col.s12.m4
|
||||||
|
|
||||||
p.flow-text
|
p.flow-text
|
||||||
a.btn-flat.waves-effect.dropdown-trigger(href=`/translate/${translationChapter.translationArtifactVersion.id}/chapter/${translationChapter.id}/translator`) Translator ▼
|
a.btn-flat.waves-effect.dropdown-trigger(href=`/translate/${translationChapter.translationArtifactVersion.id}/chapter/${translationChapter.id}/translator`) Translator ⚙
|
||||||
br
|
br
|
||||||
if translationChapter.translationChapterTranslators.length > 0
|
if translationChapter.translationChapterTranslators.length > 0
|
||||||
each translationChapterTranslator in translationChapter.translationChapterTranslators
|
each translationChapterTranslator in translationChapter.translationChapterTranslators
|
||||||
-
|
span.chip= translatorDisplayName(translationChapterTranslator)
|
||||||
const translatorDisplayName = translationChapterTranslator.translator.entityEmail == null ? translationChapterTranslator.translator.name : translationChapterTranslator.translator.entityEmail.email.address
|
a(href=`/translate/${translationChapter.translationArtifactVersion.id}/chapter/${translationChapter.id}/translator/${translationChapterTranslator.id}`)
|
||||||
span.chip= translatorDisplayName
|
i.remove.material-icons close
|
||||||
else
|
else
|
||||||
span No translators assigned yet
|
span No translators assigned yet
|
||||||
.col.s12.m4
|
.col.s12.m4
|
||||||
|
|||||||
Reference in New Issue
Block a user