Update counter on movie add / delete

fix #1383
This commit is contained in:
Ruud
2013-05-19 00:22:44 +02:00
parent 510c0d5f56
commit 1258f34c78
@@ -63,7 +63,8 @@ var MovieList = new Class({
self.movies.each(function(movie){ self.movies.each(function(movie){
if(movie.get('id') == notification.data.id){ if(movie.get('id') == notification.data.id){
movie.destroy(); movie.destroy();
delete self.movies_added[notification.data.id] delete self.movies_added[notification.data.id];
self.setCounter(self.counter_count-1);
} }
}) })
} }
@@ -77,6 +78,7 @@ var MovieList = new Class({
if(self.options.add_new && !self.movies_added[notification.data.id] && notification.data.status.identifier == self.options.status){ if(self.options.add_new && !self.movies_added[notification.data.id] && notification.data.status.identifier == self.options.status){
window.scroll(0,0); window.scroll(0,0);
self.createMovie(notification.data, 'top'); self.createMovie(notification.data, 'top');
self.setCounter(self.counter_count+1);
self.checkIfEmpty(); self.checkIfEmpty();
} }
@@ -126,6 +128,7 @@ var MovieList = new Class({
if(!self.navigation_counter) return; if(!self.navigation_counter) return;
self.counter_count = count;
self.navigation_counter.set('text', (count || 0) + ' movies'); self.navigation_counter.set('text', (count || 0) + ' movies');
if (self.empty_message) { if (self.empty_message) {
@@ -377,14 +380,14 @@ var MovieList = new Class({
self.movies.each(function(movie){ self.movies.each(function(movie){
if (movie.isSelected()){ if (movie.isSelected()){
$(movie).destroy() $(movie).destroy()
erase_movies.include(movie) erase_movies.include(movie);
} }
}); });
erase_movies.each(function(movie){ erase_movies.each(function(movie){
self.movies.erase(movie); self.movies.erase(movie);
movie.destroy();
movie.destroy() self.setCounter(self.counter_count-1);
}); });
self.calculateSelected(); self.calculateSelected();