Translation chunks...
This commit is contained in:
@@ -88,7 +88,13 @@ module.exports = function (options) {
|
||||
}).then(artifactVersion => {
|
||||
const isString = typeof request.body.text === "string" || request.body.text instanceof String
|
||||
if (artifactVersion && isString) {
|
||||
const chunks = request.body.text.trim().split(/\r?\n\r?\n/)
|
||||
const chunks = request.body.text.trim().split(/\r?\n/).filter(text => {
|
||||
if (text) {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
db.Chapter.create({
|
||||
creatorId: request.user.id,
|
||||
name: chunks[0].trim(),
|
||||
@@ -176,6 +182,14 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.ForkedFrom
|
||||
},
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.Chapter
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(translationArtifactVersion => {
|
||||
@@ -237,6 +251,14 @@ module.exports = function (options) {
|
||||
},
|
||||
{
|
||||
association: db.ArtifactVersion.TranslationArtifactVersions
|
||||
},
|
||||
{
|
||||
association: db.ArtifactVersion.Chapters,
|
||||
include: [
|
||||
{
|
||||
association: db.Chapter.Chunks
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}).then(async (artifactVersion) => {
|
||||
@@ -259,7 +281,32 @@ module.exports = function (options) {
|
||||
name: dialect.name,
|
||||
artifactVersionId: artifactVersion.id,
|
||||
dialectId: dialect.id,
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId
|
||||
entityId: request.user.individualEntityUser.entityUser.entityId,
|
||||
translationChapters: artifactVersion.chapters.map(chapter => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
chapterId: chapter.id,
|
||||
translationChunks: chapter.chunks.map(chunk => {
|
||||
return {
|
||||
creatorId: request.user.id,
|
||||
chunkId: chunk.id,
|
||||
text: chunk.text,
|
||||
index: chunk.index
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}, {
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationArtifactVersion.TranslationChapters,
|
||||
include: [
|
||||
{
|
||||
association: db.TranslationChapter.TranslationChunks
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
|
||||
if (translationArtifactVersion) {
|
||||
|
||||
Reference in New Issue
Block a user