Disallow to select a mixture of albums and photos.

This commit uses a different approach than before. Now we prevent the
selection and display an error to the user to explain him whats going
on. Thus, we do no longer need to check in contextMenu whether a mixture
of photos and albums has been selected.

This fixes the open bug in #603.
pull/611/head
Nils Asmussen 8 years ago
parent a765b5ee06
commit 3f7f2ffcd1

@ -69,26 +69,6 @@ const getSubIDs = function(albums, albumID) {
}
const countSubAlbums = function(photoIDs) {
let count = 0
if (album.subjson) {
for (i in photoIDs) {
for (j in album.subjson.albums) {
if (album.subjson.albums[j].id == photoIDs[i]) {
count++
break
}
}
}
}
return count
}
contextMenu = {}
contextMenu.add = function(albumID, e) {
@ -280,20 +260,6 @@ contextMenu.photo = function(photoID, e) {
contextMenu.photoMulti = function(photoIDs, e) {
let subcount = countSubAlbums(photoIDs)
let photocount = photoIDs.length - subcount
if (subcount && photocount) {
multiselect.deselect('.photo.active, .album.active')
multiselect.close()
lychee.error('Please select either albums or photos!')
return
}
if (subcount) {
contextMenu.albumMulti(photoIDs, e)
return
}
multiselect.stopResize()
// Notice for 'Move All':

@ -11,7 +11,9 @@ const isSelectKeyPressed = function(e) {
multiselect = {
ids: []
ids : [],
albumsSelected : 0,
photosSelected : 0
}
@ -57,9 +59,19 @@ multiselect.addItem = function(object, id) {
if (album.isSmartID(id)) return
if (multiselect.isSelected(id).selected===true) return
let isAlbum = object.hasClass('album')
if ((isAlbum && multiselect.photosSelected > 0) ||
(!isAlbum && multiselect.albumsSelected > 0)) {
lychee.error('Please select either albums or photos!')
return
}
multiselect.ids.push(id)
multiselect.select(object)
if (isAlbum) multiselect.albumsSelected++
else multiselect.photosSelected++
}
multiselect.removeItem = function(object, id) {
@ -71,6 +83,10 @@ multiselect.removeItem = function(object, id) {
multiselect.ids.splice(pos, 1)
multiselect.deselect(object)
let isAlbum = object.hasClass('album')
if (isAlbum) multiselect.albumsSelected--
else multiselect.photosSelected--
}
multiselect.albumClick = function(e, albumObj) {
@ -98,7 +114,7 @@ multiselect.albumContextMenu = function(e, albumObj) {
if (selected!==false) {
contextMenu.albumMulti(multiselect.ids, e)
multiselect.ids = []
multiselect.clearSelection(false)
} else {
multiselect.clearSelection()
contextMenu.album(album.getID(), e)
@ -113,7 +129,7 @@ multiselect.photoContextMenu = function(e, photoObj) {
if (selected!==false) {
contextMenu.photoMulti(multiselect.ids, e)
multiselect.ids = []
multiselect.clearSelection(false)
} else {
multiselect.clearSelection()
contextMenu.photo(photo.getID(), e)
@ -121,10 +137,13 @@ multiselect.photoContextMenu = function(e, photoObj) {
}
multiselect.clearSelection = function() {
multiselect.clearSelection = function(deselect = true) {
if (deselect) multiselect.deselect('.photo.active, .album.active')
multiselect.deselect('.photo.active, .album.active')
multiselect.ids = []
multiselect.albumsSelected = 0
multiselect.photosSelected = 0
}

Loading…
Cancel
Save