Project ownership handling
This commit is contained in:
@@ -82,19 +82,16 @@ module.exports = function (options) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.Project.Owner,
|
association: db.Project.Owner,
|
||||||
required: true,
|
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Owner.OwnerEntities,
|
association: db.Owner.OwnerEntities,
|
||||||
required: true,
|
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.OwnerEntity.Entity,
|
association: db.OwnerEntity.Entity,
|
||||||
required: true,
|
|
||||||
include: [
|
include: [
|
||||||
{
|
{
|
||||||
association: db.Entity.EntityUsers,
|
association: db.Entity.EntityUsers,
|
||||||
required: true,
|
required: false,
|
||||||
where: {
|
where: {
|
||||||
userId: request.user?.id ?? null
|
userId: request.user?.id ?? null
|
||||||
}
|
}
|
||||||
@@ -174,6 +171,31 @@ module.exports = function (options) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.Project.ProjectTranslationArtifactVersions
|
association: db.Project.ProjectTranslationArtifactVersions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(async (project) => {
|
}).then(async (project) => {
|
||||||
@@ -239,6 +261,31 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(async (project) => {
|
}).then(async (project) => {
|
||||||
@@ -292,6 +339,31 @@ module.exports = function (options) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.Project.ProjectTranslationArtifactVersions
|
association: db.Project.ProjectTranslationArtifactVersions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(async (project) => {
|
}).then(async (project) => {
|
||||||
@@ -332,6 +404,31 @@ module.exports = function (options) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
association: db.Project.ProjectTranslationArtifactVersions
|
association: db.Project.ProjectTranslationArtifactVersions
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(async (project) => {
|
}).then(async (project) => {
|
||||||
@@ -375,6 +472,31 @@ module.exports = function (options) {
|
|||||||
{
|
{
|
||||||
association: db.Project.Campaign,
|
association: db.Project.Campaign,
|
||||||
required: true
|
required: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(project => {
|
}).then(project => {
|
||||||
@@ -423,6 +545,31 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(project => {
|
}).then(project => {
|
||||||
@@ -483,6 +630,31 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
association: db.Project.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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}).then(async (project) => {
|
}).then(async (project) => {
|
||||||
@@ -559,7 +731,30 @@ module.exports = function (options) {
|
|||||||
router.route('/:id/spreadsheet')
|
router.route('/:id/spreadsheet')
|
||||||
.post(function(request, response, next) {
|
.post(function(request, response, next) {
|
||||||
db.Project.findByPk(request.params.id, {
|
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) => {
|
}).then(async (project) => {
|
||||||
if (project) {
|
if (project) {
|
||||||
db.TranslationArtifactVersion.findAll({
|
db.TranslationArtifactVersion.findAll({
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
extend templates/layout.pug
|
extend templates/layout.pug
|
||||||
|
|
||||||
block content
|
block content
|
||||||
|
-
|
||||||
|
const isOwnedByUser = project.owner.ownerEntities.some(ownerEntity => {
|
||||||
|
return ownerEntity.entity.entityUsers.some(entityUser => {
|
||||||
|
return entityUser.userId == user?.id
|
||||||
|
})
|
||||||
|
})
|
||||||
.container
|
.container
|
||||||
.center
|
.center
|
||||||
h1= project.name
|
h1= project.name
|
||||||
@@ -19,15 +25,17 @@ block content
|
|||||||
h2 Entries
|
h2 Entries
|
||||||
each projectArtifactVersion in project.projectArtifactVersions
|
each projectArtifactVersion in project.projectArtifactVersions
|
||||||
p.flow-text= projectArtifactVersion.artifactVersion.artifact.name
|
p.flow-text= projectArtifactVersion.artifactVersion.artifact.name
|
||||||
.row
|
if isOwnedByUser
|
||||||
.col.s12
|
.row
|
||||||
a.btn.black(href=`/projects/${project.id}/add-artifact`) add from library
|
.col.s12
|
||||||
|
a.btn.black(href=`/projects/${project.id}/add-artifact`) add from library
|
||||||
.divider
|
.divider
|
||||||
h2 Translation
|
h2 Translation
|
||||||
each projectTranslationArtifactVersion in project.projectTranslationArtifactVersions
|
each projectTranslationArtifactVersion in project.projectTranslationArtifactVersions
|
||||||
p.flow-text #{projectTranslationArtifactVersion.translationArtifactVersion.name} - #{projectTranslationArtifactVersion.translationArtifactVersion.artifactVersion.artifact.name}
|
p.flow-text #{projectTranslationArtifactVersion.translationArtifactVersion.name} - #{projectTranslationArtifactVersion.translationArtifactVersion.artifactVersion.artifact.name}
|
||||||
.row
|
if isOwnedByUser
|
||||||
.col.s12
|
.row
|
||||||
a.btn.black(href=`/projects/${project.id}/add-translation`) add translation
|
.col.s12
|
||||||
|
a.btn.black(href=`/projects/${project.id}/add-translation`) add translation
|
||||||
//- TODO: Show project translation artifact versions
|
//- TODO: Show project translation artifact versions
|
||||||
//- TODO: Show project artifact versions
|
//- TODO: Show project artifact versions
|
||||||
Reference in New Issue
Block a user