SortBy Options: Started Date & Finished Date implemented. English-only strings

This commit is contained in:
tagmeh 2025-08-10 17:55:34 -05:00
parent 28d98b4dbc
commit c023f029d7
4 changed files with 46 additions and 5 deletions

View File

@ -353,6 +353,14 @@ export default {
if (!this.userProgressLastUpdated) return '\u00A0' if (!this.userProgressLastUpdated) return '\u00A0'
return this.$getString('LabelLastProgressDate', [this.$formatDatetime(this.userProgressLastUpdated, this.dateFormat, this.timeFormat)]) return this.$getString('LabelLastProgressDate', [this.$formatDatetime(this.userProgressLastUpdated, this.dateFormat, this.timeFormat)])
} }
if (this.orderBy === 'startedDate') {
if (!this.userProgressStartedDate) return '\u00A0'
return this.$getString('LabelFileStartedDate', [this.$formatDate(this.userProgressStartedDate, this.dateFormat, this.timeFormat)])
}
if (this.orderBy === 'finishedDate') {
if (!this.userProgressFinishedDate) return '\u00A0'
return this.$getString('LabelFileFinishedDate', [this.$formatDate(this.userProgressFinishedDate, this.dateFormat, this.timeFormat)])
}
return null return null
}, },
episodeProgress() { episodeProgress() {
@ -389,6 +397,15 @@ export default {
if (!this.userProgress) return null if (!this.userProgress) return null
return this.userProgress.lastUpdate return this.userProgress.lastUpdate
}, },
userProgressStartedDate() {
if (!this.userProgress) return null
return this.userProgress.startedAt
},
userProgressFinishedDate() {
if (!this.userProgress) return null
console.log(this.userProgress)
return this.userProgress.finishedAt
},
itemIsFinished() { itemIsFinished() {
if (this.booksInSeries) return this.seriesIsFinished if (this.booksInSeries) return this.seriesIsFinished
return this.userProgress ? !!this.userProgress.isFinished : false return this.userProgress ? !!this.userProgress.isFinished : false

View File

@ -134,6 +134,14 @@ export default {
text: this.$strings.LabelLibrarySortByProgress, text: this.$strings.LabelLibrarySortByProgress,
value: 'progress' value: 'progress'
}, },
{
text: this.$strings.LabelLibrarySortByStartDate,
value: 'startedDate'
},
{
text: this.$strings.LabelLibrarySortByFinishDate,
value: 'finishedDate'
},
{ {
text: this.$strings.LabelRandomly, text: this.$strings.LabelRandomly,
value: 'random' value: 'random'
@ -200,4 +208,4 @@ export default {
.librarySortMenu { .librarySortMenu {
max-height: calc(100vh - 125px); max-height: calc(100vh - 125px);
} }
</style> </style>

View File

@ -371,7 +371,9 @@
"LabelFileBirthtime": "File Birthtime", "LabelFileBirthtime": "File Birthtime",
"LabelFileBornDate": "Born {0}", "LabelFileBornDate": "Born {0}",
"LabelFileModified": "File Modified", "LabelFileModified": "File Modified",
"LabelFileFinishedDate": "Finished {0}",
"LabelFileModifiedDate": "Modified {0}", "LabelFileModifiedDate": "Modified {0}",
"LabelFileStartedDate": "Started {0}",
"LabelFilename": "Filename", "LabelFilename": "Filename",
"LabelFilterByUser": "Filter by User", "LabelFilterByUser": "Filter by User",
"LabelFindEpisodes": "Find Episodes", "LabelFindEpisodes": "Find Episodes",
@ -433,7 +435,9 @@
"LabelLibraryFilterSublistEmpty": "No {0}", "LabelLibraryFilterSublistEmpty": "No {0}",
"LabelLibraryItem": "Library Item", "LabelLibraryItem": "Library Item",
"LabelLibraryName": "Library Name", "LabelLibraryName": "Library Name",
"LabelLibrarySortByFinishDate": "Finish Date",
"LabelLibrarySortByProgress": "Progress Updated", "LabelLibrarySortByProgress": "Progress Updated",
"LabelLibrarySortByStartDate": "Start Date",
"LabelLimit": "Limit", "LabelLimit": "Limit",
"LabelLineSpacing": "Line spacing", "LabelLineSpacing": "Line spacing",
"LabelListenAgain": "Listen Again", "LabelListenAgain": "Listen Again",
@ -1137,4 +1141,4 @@
"ToastUserPasswordMismatch": "Passwords do not match", "ToastUserPasswordMismatch": "Passwords do not match",
"ToastUserPasswordMustChange": "New password cannot match old password", "ToastUserPasswordMustChange": "New password cannot match old password",
"ToastUserRootRequireName": "Must enter a root username" "ToastUserRootRequireName": "Must enter a root username"
} }

View File

@ -290,6 +290,18 @@ module.exports = {
return [[Sequelize.literal(`CAST(\`series.bookSeries.sequence\` AS FLOAT) ${nullDir}`)]] return [[Sequelize.literal(`CAST(\`series.bookSeries.sequence\` AS FLOAT) ${nullDir}`)]]
} else if (sortBy === 'progress') { } else if (sortBy === 'progress') {
return [[Sequelize.literal('mediaProgresses.updatedAt'), dir]] return [[Sequelize.literal('mediaProgresses.updatedAt'), dir]]
} else if (sortBy === 'startedDate') {
// Sort started books first (not null), then unstarted (nulls last), then by createdAt desc
return [
[Sequelize.literal('(CASE WHEN mediaProgresses.createdAt IS NULL THEN 1 ELSE 0 END)'), 'ASC'],
['mediaProgresses', 'createdAt', dir]
]
} else if (sortBy === 'finishedDate') {
// Sort finished books first (not null), then unfinished (nulls last), then by finishedAt desc
return [
[Sequelize.literal('(CASE WHEN mediaProgresses.finishedAt IS NULL THEN 1 ELSE 0 END)'), 'ASC'],
['mediaProgresses', 'finishedAt', dir]
]
} else if (sortBy === 'random') { } else if (sortBy === 'random') {
return [Database.sequelize.random()] return [Database.sequelize.random()]
} }
@ -519,7 +531,7 @@ module.exports = {
} }
bookIncludes.push({ bookIncludes.push({
model: Database.mediaProgressModel, model: Database.mediaProgressModel,
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'], attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt', 'createdAt', 'finishedAt'],
where: mediaProgressWhere, where: mediaProgressWhere,
required: false required: false
}) })
@ -530,10 +542,10 @@ module.exports = {
} }
// When sorting by progress but not filtering by progress, include media progresses // When sorting by progress but not filtering by progress, include media progresses
if (filterGroup !== 'progress' && sortBy === 'progress') { if (filterGroup !== 'progress' && ['startedDate', 'finishedDate', 'progress'].includes(sortBy)) {
bookIncludes.push({ bookIncludes.push({
model: Database.mediaProgressModel, model: Database.mediaProgressModel,
attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt'], attributes: ['id', 'isFinished', 'currentTime', 'ebookProgress', 'updatedAt', 'createdAt', 'finishedAt'],
where: { where: {
userId: user.id userId: user.id
}, },