Add versioning

This commit is contained in:
2021-12-25 01:35:32 +02:00
parent 1a539e673f
commit da9d91502c
14 changed files with 388 additions and 261 deletions

View File

@@ -7,14 +7,14 @@ module.exports = function (options) {
router.route('/:id')
.get(function(request, response, next) {
db.TranslationEntry.findByPk(request.params.id, {
db.TranslationEntryVersion.findByPk(request.params.id, {
include: [
{
association: db.TranslationEntry.Entry,
association: db.TranslationEntryVersion.EntryVersion,
required: true,
include: [
{
association: db.Entry.Chapters,
association: db.EntryVersion.Chapters,
required: true,
limit: 1,
// TODO: Order by chapter index
@@ -22,9 +22,9 @@ module.exports = function (options) {
]
}
]
}).then(translationEntry => {
if (translationEntry) {
response.redirect(`/translate/${translationEntry.id}/chapter/${translationEntry.entry.chapters[0].id}`)
}).then(translationEntryVersion => {
if (translationEntryVersion) {
response.redirect(`/translate/${translationEntryVersion.id}/chapter/${translationEntryVersion.entryVersion.chapters[0].id}`)
} else {
next()
}
@@ -44,18 +44,23 @@ module.exports = function (options) {
]
},
{
association: db.Chapter.Entry,
association: db.Chapter.EntryVersion,
required: true,
include: [
{
association: db.Entry.TranslationEntries,
association: db.EntryVersion.TranslationEntryVersions,
required: true,
where: {
id: request.params.id
}
},
{
association: db.Entry.Dialect
association: db.EntryVersion.Entry,
include: [
{
association: db.Entry.Dialect
}
]
}
]
}
@@ -99,18 +104,23 @@ module.exports = function (options) {
required: true,
include: [
{
association: db.Chapter.Entry,
association: db.Chapter.EntryVersion,
required: true,
include: [
{
association: db.Entry.TranslationEntries,
association: db.EntryVersion.TranslationEntryVersions,
required: true,
where: {
id: request.params.id
}
},
{
association: db.Entry.Dialect
association: db.EntryVersion.Entry,
include: [
{
association: db.Entry.Dialect
}
]
}
]
}
@@ -122,7 +132,7 @@ module.exports = function (options) {
const chunk = chunks.find(chunk => chunk.index == Number(request.params.chunkIndex))
response.display("translate-chunk", {
user: request.user,
pageTitle: `Translate ${chunk.chapter.entry.name}`,
pageTitle: `Translate ${chunk.chapter.entryVersion.entry.name}`,
chunk: chunk,
previousChunk: chunks.find(chunk => chunk.index == previousIndex),
nextChunk: chunks.find(chunk => chunk.index == nextIndex)