Fork with translations...
This commit is contained in:
@@ -32,6 +32,7 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
}).then(async (translationArtifactVersion) => {
|
}).then(async (translationArtifactVersion) => {
|
||||||
if (translationArtifactVersion) {
|
if (translationArtifactVersion) {
|
||||||
|
const existingTranslation = {}
|
||||||
// fork check if forkable...
|
// fork check if forkable...
|
||||||
const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({
|
const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
@@ -52,21 +53,18 @@ module.exports = function (options) {
|
|||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
chapterId: translationChapter.chapterId,
|
chapterId: translationChapter.chapterId,
|
||||||
translationChunks: translationChapter.translationChunks.map(translationChunk => {
|
translationChunks: translationChapter.translationChunks.map(translationChunk => {
|
||||||
const tc = {
|
if (translationChunk.translation) {
|
||||||
|
existingTranslation[translationChunk.chunkId] = {
|
||||||
|
creatorId: translationChunk.translation.creatorId,
|
||||||
|
text: translationChunk.translation.text,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return {
|
||||||
creatorId: request.user.id,
|
creatorId: request.user.id,
|
||||||
chunkId: translationChunk.chunkId,
|
chunkId: translationChunk.chunkId,
|
||||||
text: translationChunk.text,
|
text: translationChunk.text,
|
||||||
index: translationChunk.index,
|
index: translationChunk.index,
|
||||||
}
|
}
|
||||||
// if (translationChunk.translation) {
|
|
||||||
// tc.translation = {
|
|
||||||
// creatorId: translationChunk.translation.creatorId,
|
|
||||||
// text: translationChunk.translation.text,
|
|
||||||
// // TODO: Might want to create translations separately...
|
|
||||||
// translationArtifactVersionId: translationChunk.translation.translationArtifactVersionId,
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return tc
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -91,6 +89,20 @@ module.exports = function (options) {
|
|||||||
]
|
]
|
||||||
})
|
})
|
||||||
if (forkedTranslationArtifactVersion) {
|
if (forkedTranslationArtifactVersion) {
|
||||||
|
const t = []
|
||||||
|
forkedTranslationArtifactVersion.translationChapters.forEach(translationChapter => {
|
||||||
|
translationChapter.translationChunks.forEach(translationChunk => {
|
||||||
|
if (existingTranslation[translationChunk.chunkId]) {
|
||||||
|
t.push({
|
||||||
|
translationChunkId: translationChunk.id,
|
||||||
|
creatorId: existingTranslation[translationChunk.chunkId].creatorId,
|
||||||
|
text: existingTranslation[translationChunk.chunkId].text,
|
||||||
|
translationArtifactVersionId: forkedTranslationArtifactVersion.id
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
await db.Translation.bulkCreate(t)
|
||||||
return response.redirect(`/translate/${forkedTranslationArtifactVersion.id}`)
|
return response.redirect(`/translate/${forkedTranslationArtifactVersion.id}`)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ block content
|
|||||||
.container
|
.container
|
||||||
.center
|
.center
|
||||||
h1 Translate into
|
h1 Translate into
|
||||||
a(href=`/translate/${translationChunk.translationChapter.translationArtifactVersion.id}/chapter/${translationChunk.translationChapter.id}`) #{translationChunk.translationChapter.translationArtifactVersion.name}
|
a(href=`/translate/${translationChunk.translationChapter.translationArtifactVersion.id}`) #{translationChunk.translationChapter.translationArtifactVersion.name}
|
||||||
|
|
||||||
//- TODO: Show previous...
|
//- TODO: Show previous...
|
||||||
form.row(action=`/translate/${translationChunk.translationChapter.translationArtifactVersion.id}/chapter/${translationChunk.translationChapter.id}/t/${translationChunk.index}`, method="post")
|
form.row(action=`/translate/${translationChunk.translationChapter.translationArtifactVersion.id}/chapter/${translationChunk.translationChapter.id}/t/${translationChunk.index}`, method="post")
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ block content
|
|||||||
a(href=`/translate/${translationArtifactVersion.forkedFrom.id}`) fork
|
a(href=`/translate/${translationArtifactVersion.forkedFrom.id}`) fork
|
||||||
|
|
||||||
//- TODO: Condition to show translate button
|
//- TODO: Condition to show translate button
|
||||||
.row
|
//- .row
|
||||||
.col.s12
|
.col.s12
|
||||||
a.btn.black(href=`/translate/${translationArtifactVersion.id}`) Translate
|
a.btn.black(href=`/translate/${translationArtifactVersion.id}`) Translate
|
||||||
//- TODO: Condition to show fork button
|
//- TODO: Condition to show fork button
|
||||||
@@ -60,4 +60,6 @@ block content
|
|||||||
h2 Chapters
|
h2 Chapters
|
||||||
each translationChapter in translationArtifactVersion.translationChapters
|
each translationChapter in translationArtifactVersion.translationChapters
|
||||||
p.flow-text
|
p.flow-text
|
||||||
|
small translate
|
||||||
|
br
|
||||||
a(href=`/translate/${translationArtifactVersion.id}/chapter/${translationChapter.id}`)= translationChapter.chapter.name
|
a(href=`/translate/${translationArtifactVersion.id}/chapter/${translationChapter.id}`)= translationChapter.chapter.name
|
||||||
Reference in New Issue
Block a user