Update:Rename UserCollections to Collections

This commit is contained in:
advplyr 2022-11-11 17:13:10 -06:00
parent fdf67e17a0
commit 4cbc8676c6
11 changed files with 30 additions and 37 deletions

View File

@ -208,7 +208,7 @@ export default {
this.$router.push('/batch')
},
batchAddToCollectionClick() {
this.$store.commit('globals/setShowBatchUserCollectionsModal', true)
this.$store.commit('globals/setShowBatchCollectionsModal', true)
},
setBookshelfTotalEntities(totalEntities) {
this.totalEntities = totalEntities

View File

@ -668,7 +668,7 @@ export default {
},
openCollections() {
this.store.commit('setSelectedLibraryItem', this.libraryItem)
this.store.commit('globals/setShowUserCollectionsModal', true)
this.store.commit('globals/setShowCollectionsModal', true)
},
createMoreMenu() {
if (!this.$refs.moreIcon) return

View File

@ -9,7 +9,7 @@
<div ref="container" class="w-full rounded-lg bg-primary box-shadow-md overflow-y-auto overflow-x-hidden" style="max-height: 80vh">
<div v-if="show" class="w-full h-full">
<div class="py-4 px-4">
<h1 v-if="!showBatchUserCollectionModal" class="text-2xl">{{ $strings.LabelAddToCollection }}</h1>
<h1 v-if="!showBatchCollectionModal" class="text-2xl">{{ $strings.LabelAddToCollection }}</h1>
<h1 v-else class="text-2xl">{{ $getString('LabelAddToCollectionBatch', [selectedBookIds.length]) }}</h1>
</div>
<div class="w-full overflow-y-auto overflow-x-hidden max-h-96">
@ -57,14 +57,14 @@ export default {
computed: {
show: {
get() {
return this.$store.state.globals.showUserCollectionsModal
return this.$store.state.globals.showCollectionsModal
},
set(val) {
this.$store.commit('globals/setShowUserCollectionsModal', val)
this.$store.commit('globals/setShowCollectionsModal', val)
}
},
title() {
if (this.showBatchUserCollectionModal) {
if (this.showBatchCollectionModal) {
return this.$getString('MessageItemsSelected', [this.selectedBookIds.length])
}
return this.selectedLibraryItem ? this.selectedLibraryItem.media.metadata.title : ''
@ -85,7 +85,7 @@ export default {
return this.collections
.map((c) => {
var includesBook = false
if (this.showBatchUserCollectionModal) {
if (this.showBatchCollectionModal) {
// Only show collection added if all books are in the collection
var collectionBookIds = c.books.map((b) => b.id)
includesBook = !this.selectedBookIds.find((id) => !collectionBookIds.includes(id))
@ -100,8 +100,8 @@ export default {
})
.sort((a, b) => (a.isBookIncluded ? -1 : 1))
},
showBatchUserCollectionModal() {
return this.$store.state.globals.showBatchUserCollectionModal
showBatchCollectionModal() {
return this.$store.state.globals.showBatchCollectionModal
},
selectedBookIds() {
return this.$store.state.selectedLibraryItems || []
@ -112,13 +112,13 @@ export default {
},
methods: {
loadCollections() {
this.$store.dispatch('user/loadUserCollections')
this.$store.dispatch('user/loadCollections')
},
removeFromCollection(collection) {
if (!this.selectedLibraryItemId && !this.selectedBookIds.length) return
this.processing = true
if (this.showBatchUserCollectionModal) {
if (this.showBatchCollectionModal) {
// BATCH Remove books
this.$axios
.$post(`/api/collections/${collection.id}/batch/remove`, { books: this.selectedBookIds })
@ -152,7 +152,7 @@ export default {
if (!this.selectedLibraryItemId && !this.selectedBookIds.length) return
this.processing = true
if (this.showBatchUserCollectionModal) {
if (this.showBatchCollectionModal) {
// BATCH Remove books
this.$axios
.$post(`/api/collections/${collection.id}/batch/add`, { books: this.selectedBookIds })
@ -189,7 +189,7 @@ export default {
}
this.processing = true
var books = this.showBatchUserCollectionModal ? this.selectedBookIds : [this.selectedLibraryItemId]
var books = this.showBatchCollectionModal ? this.selectedBookIds : [this.selectedLibraryItemId]
var newCollection = {
books: books,
libraryId: this.currentLibraryId,

View File

@ -10,7 +10,7 @@
<app-stream-container ref="streamContainer" />
<modals-item-edit-modal />
<modals-user-collections-modal />
<modals-collections-add-create-modal />
<modals-edit-collection-modal />
<modals-podcast-edit-episode />
<modals-podcast-view-episode />

View File

@ -582,7 +582,7 @@ export default {
},
collectionsClick() {
this.$store.commit('setSelectedLibraryItem', this.libraryItem)
this.$store.commit('globals/setShowUserCollectionsModal', true)
this.$store.commit('globals/setShowCollectionsModal', true)
},
clickRSSFeed() {
this.showRssFeedModal = true

View File

@ -1,8 +1,8 @@
export const state = () => ({
isMobile: false,
isMobileLandscape: false,
showBatchUserCollectionModal: false,
showUserCollectionsModal: false,
showBatchCollectionModal: false,
showCollectionsModal: false,
showEditCollectionModal: false,
showEditPodcastEpisode: false,
showViewPodcastEpisodeModal: false,
@ -68,13 +68,13 @@ export const mutations = {
state.isMobile = width < 640 || height < 640
state.isMobileLandscape = state.isMobile && height > width
},
setShowUserCollectionsModal(state, val) {
state.showBatchUserCollectionModal = false
state.showUserCollectionsModal = val
setShowCollectionsModal(state, val) {
state.showBatchCollectionModal = false
state.showCollectionsModal = val
},
setShowBatchUserCollectionsModal(state, val) {
state.showBatchUserCollectionModal = true
state.showUserCollectionsModal = val
setShowBatchCollectionsModal(state, val) {
state.showBatchCollectionModal = true
state.showCollectionsModal = val
},
setShowEditCollectionModal(state, val) {
state.showEditCollectionModal = val

View File

@ -114,7 +114,7 @@ export const actions = {
return false
})
},
loadUserCollections({ state, commit }) {
loadCollections({ state, commit }) {
if (state.collectionsLoaded) {
console.log('Collections already loaded')
return state.collections

View File

@ -4,7 +4,7 @@ const Logger = require('./Logger')
const { version } = require('../package.json')
const LibraryItem = require('./objects/LibraryItem')
const User = require('./objects/user/User')
const UserCollection = require('./objects/UserCollection')
const Collection = require('./objects/Collection')
const Library = require('./objects/Library')
const Author = require('./objects/entities/Author')
const Series = require('./objects/entities/Series')
@ -180,7 +180,7 @@ class Db {
}
})
var p5 = this.collectionsDb.select(() => true).then((results) => {
this.collections = results.data.map(l => new UserCollection(l))
this.collections = results.data.map(l => new Collection(l))
Logger.info(`[DB] ${this.collections.length} Collections Loaded`)
})
var p6 = this.authorsDb.select(() => true).then((results) => {

View File

@ -1,11 +1,11 @@
const Logger = require('../Logger')
const UserCollection = require('../objects/UserCollection')
const Collection = require('../objects/Collection')
class CollectionController {
constructor() { }
async create(req, res) {
var newCollection = new UserCollection()
var newCollection = new Collection()
req.body.userId = req.user.id
var success = newCollection.setData(req.body)
if (!success) {

View File

@ -105,13 +105,6 @@ class UserController {
}
var user = req.reqUser
// delete user collections
var userCollections = this.db.collections.filter(c => c.userId === user.id)
var collectionsToRemove = userCollections.map(uc => uc.id)
for (let i = 0; i < collectionsToRemove.length; i++) {
await this.db.removeEntity('collection', collectionsToRemove[i])
}
// Todo: check if user is logged in and cancel streams
var userJson = user.toJSONForBrowser()

View File

@ -1,7 +1,7 @@
const Logger = require('../Logger')
const { getId } = require('../utils/index')
class UserCollection {
class Collection {
constructor(collection) {
this.id = null
this.libraryId = null
@ -105,4 +105,4 @@ class UserCollection {
return hasUpdates
}
}
module.exports = UserCollection
module.exports = Collection