Collections: allow to drag and drop to change book position
This commit is contained in:
@@ -81,6 +81,7 @@ func fetchCollections(db *gorm.DB, userId uint) *gorm.DB {
|
||||
}
|
||||
|
||||
type CollectionItemQueryResult struct {
|
||||
ItemID uint
|
||||
Position uint
|
||||
ID uint
|
||||
Title string
|
||||
@@ -113,7 +114,7 @@ func FetchCollectionBooksCount(db *gorm.DB, userId uint, collectionId uint) (int
|
||||
|
||||
func fetchCollectionBooksQuery(db *gorm.DB, userId uint, collectionId uint) *gorm.DB {
|
||||
query := db.Model(&model.CollectionItem{})
|
||||
query = query.Select("collection_items.position, " + selectBookItem())
|
||||
query = query.Select("collection_items.position, collection_items.ID as item_id, " + selectBookItem())
|
||||
query = query.Joins("left join collections on (collection_items.collection_id = collections.id)")
|
||||
query = query.Joins("left join books on (books.id = collection_items.book_id)")
|
||||
query = joinAuthors(query)
|
||||
|
||||
Reference in New Issue
Block a user