Move route to translate page
This commit is contained in:
@@ -91,7 +91,7 @@ module.exports = function (options) {
|
||||
]
|
||||
})
|
||||
if (forkedTranslationArtifactVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
|
||||
return response.redirect(`/translate/${forkedTranslationArtifactVersion.id}`)
|
||||
}
|
||||
} else {
|
||||
next()
|
||||
@@ -168,7 +168,7 @@ module.exports = function (options) {
|
||||
request.user.individualEntityUser.entityUser.entityId
|
||||
)
|
||||
if (forkedTranslationArtifactVersion) {
|
||||
return response.redirect(`/v/${forkedTranslationArtifactVersion.artifactVersionId}/translations/${forkedTranslationArtifactVersion.id}`)
|
||||
return response.redirect(`/translate/${forkedTranslationArtifactVersion.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,31 +9,93 @@ module.exports = function (options) {
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.id, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Artifact.Owner,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
// required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user.id
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.ArtifactVersion.Chapters
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ForkedFrom
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||
limit: 1,
|
||||
required: true
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.Chapter
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
// required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user.id
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
// {
|
||||
// association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
// required: true,
|
||||
// include: [
|
||||
// {
|
||||
// association: db.ArtifactVersion.Chapters,
|
||||
// required: true,
|
||||
// limit: 1,
|
||||
// // TODO: Order by chapter index
|
||||
// }
|
||||
// ]
|
||||
// }
|
||||
]
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
// Show translation without artifactVersion
|
||||
response.redirect(`/translate/${translationArtifactVersion.id}/chapter/${translationArtifactVersion.translationChapters[0].id}`)
|
||||
response.display("translation-artifact-version", {
|
||||
user: request.user,
|
||||
pageTitle: "Translation Artifact - Mantra",
|
||||
translationArtifactVersion: translationArtifactVersion,
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -248,100 +248,6 @@ module.exports = function (options) {
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/:id/translations/:translationArtifactVersionId')
|
||||
.get(function(request, response, next) {
|
||||
db.TranslationArtifactVersion.findByPk(request.params.translationArtifactVersionId, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ArtifactVersion,
|
||||
include: [
|
||||
{
|
||||
association: db.ArtifactVersion.Artifact,
|
||||
include: [
|
||||
{
|
||||
association: db.Artifact.Owner,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
// required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user.id
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.ArtifactVersion.Chapters
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ForkedFrom
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.Chapter
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.Owner,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Owner.OwnerEntities,
|
||||
// required: true,
|
||||
include: [
|
||||
{
|
||||
association: db.OwnerEntity.Entity,
|
||||
// required: false,
|
||||
include: [
|
||||
{
|
||||
association: db.Entity.EntityUsers,
|
||||
required: false,
|
||||
where: {
|
||||
userId: request.user.id
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationArtifactVersion => {
|
||||
if (translationArtifactVersion) {
|
||||
response.display("translation-artifact-version", {
|
||||
user: request.user,
|
||||
pageTitle: "Translation Artifact - Mantra",
|
||||
translationArtifactVersion: translationArtifactVersion,
|
||||
})
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
}).catch(error => {
|
||||
next(error)
|
||||
})
|
||||
})
|
||||
|
||||
router.route('/:id/translations/add')
|
||||
.get(function(request, response, next) {
|
||||
db.ArtifactVersion.findByPk(request.params.id, {
|
||||
@@ -459,7 +365,7 @@ module.exports = function (options) {
|
||||
})
|
||||
|
||||
if (translationArtifactVersion) {
|
||||
return response.redirect(`/v/${artifactVersion.id}/translations/${translationArtifactVersion.id}`)
|
||||
return response.redirect(`/translate/${translationArtifactVersion.id}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,6 @@ block content
|
||||
.row
|
||||
each translationArtifact in artifactVersion.translationArtifactVersions
|
||||
.col.s12
|
||||
a(href=`/v/${artifactVersion.id}/translations/${translationArtifact.id}`)
|
||||
a(href=`/translate/${translationArtifact.id}`)
|
||||
.card-panel
|
||||
p.flow-text= translationArtifact.name
|
||||
@@ -21,5 +21,5 @@ block content
|
||||
h2 forks
|
||||
each translationArtifactVersion in translationArtifactVersions
|
||||
p.flow-text
|
||||
a(href=`/v/${translationArtifactVersion.artifactVersionId}/translations/${translationArtifactVersion.id}`)= translationArtifactVersion.name
|
||||
a(href=`/translate/${translationArtifactVersion.id}`)= translationArtifactVersion.name
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ block content
|
||||
|
||||
if translationArtifactVersion.forkedFrom
|
||||
p.flow-text is a
|
||||
a(href=`/v/${translationArtifactVersion.forkedFrom.artifactVersionId}/translations/${translationArtifactVersion.forkedFrom.id}`) fork
|
||||
a(href=`/translate/${translationArtifactVersion.forkedFrom.id}`) fork
|
||||
|
||||
//- TODO: Condition to show translate button
|
||||
.row
|
||||
|
||||
Reference in New Issue
Block a user