Fork with translations...
This commit is contained in:
@@ -32,6 +32,7 @@ module.exports = function (options) {
|
||||
]
|
||||
}).then(async (translationArtifactVersion) => {
|
||||
if (translationArtifactVersion) {
|
||||
const existingTranslation = {}
|
||||
// fork check if forkable...
|
||||
const forkedTranslationArtifactVersion = await db.TranslationArtifactVersion.create({
|
||||
creatorId: request.user.id,
|
||||
@@ -52,21 +53,18 @@ module.exports = function (options) {
|
||||
creatorId: request.user.id,
|
||||
chapterId: translationChapter.chapterId,
|
||||
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,
|
||||
chunkId: translationChunk.chunkId,
|
||||
text: translationChunk.text,
|
||||
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) {
|
||||
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}`)
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user