diff --git a/couchpotato/core/plugins/movie/main.py b/couchpotato/core/plugins/movie/main.py index a1016066..d86b97c9 100644 --- a/couchpotato/core/plugins/movie/main.py +++ b/couchpotato/core/plugins/movie/main.py @@ -431,9 +431,11 @@ class MoviePlugin(Plugin): movie = db.query(Movie).filter_by(id = movie_id).first() if movie: + deleted = False if delete_from == 'all': db.delete(movie) db.commit() + deleted = True else: done_status = fireEvent('status.get', 'done', single = True) @@ -456,6 +458,7 @@ class MoviePlugin(Plugin): if total_releases == total_deleted: db.delete(movie) db.commit() + deleted = True elif new_movie_status: new_status = fireEvent('status.get', new_movie_status, single = True) movie.profile_id = None @@ -464,6 +467,9 @@ class MoviePlugin(Plugin): else: fireEvent('movie.restatus', movie.id, single = True) + if deleted: + fireEvent('notify.frontend', type = 'movie.deleted', data = movie.to_dict()) + #db.close() return True diff --git a/couchpotato/core/plugins/movie/static/list.js b/couchpotato/core/plugins/movie/static/list.js index 0aff0bde..51b0f4c5 100644 --- a/couchpotato/core/plugins/movie/static/list.js +++ b/couchpotato/core/plugins/movie/static/list.js @@ -35,6 +35,17 @@ var MovieList = new Class({ if(options.add_new) App.addEvent('movie.added', self.movieAdded.bind(self)) + + App.addEvent('movie.deleted', self.movieDeleted.bind(self)) + }, + + movieDeleted: function(notification){ + var self = this; + + if(!self.movies_added[notification.data.id]) + self.movies_added[notification.data.id].destroy(); + + self.checkIfEmpty(); }, movieAdded: function(notification){ @@ -43,6 +54,8 @@ var MovieList = new Class({ if(!self.movies_added[notification.data.id]) self.createMovie(notification.data, 'top'); + + self.checkIfEmpty(); }, create: function(){ @@ -460,6 +473,8 @@ var MovieList = new Class({ self.addMovies(json.movies, json.total); self.load_more.set('text', 'load more movies'); if(self.scrollspy) self.scrollspy.start(); + + self.checkIfEmpty() } }); }, @@ -477,6 +492,28 @@ var MovieList = new Class({ }, + checkIfEmpty: function(){ + var self = this; + + var is_empty = self.movies.length == 0; + + if(is_empty && self.options.on_empty_element){ + self.el.grab(self.options.on_empty_element); + + if(self.navigation) + self.navigation.hide(); + + self.empty_element = self.options.on_empty_element; + } + else if(self.empty_element){ + self.empty_element.destroy(); + + if(self.navigation) + self.navigation.show(); + } + + }, + toElement: function(){ return this.el; } diff --git a/couchpotato/core/plugins/movie/static/movie.js b/couchpotato/core/plugins/movie/static/movie.js index b406e4e3..b10b5b1b 100644 --- a/couchpotato/core/plugins/movie/static/movie.js +++ b/couchpotato/core/plugins/movie/static/movie.js @@ -42,6 +42,9 @@ var Movie = new Class({ self.el.destroy(); delete self.list.movies_added[self.get('id')]; + self.list.movies.erase(self) + + self.list.checkIfEmpty(); // Remove events App.removeEvents('movie.update.'+self.data.id); @@ -467,11 +470,11 @@ var ReleaseAction = new Class({ self.next_release = release; } }); - + if(self.last_release){ self.release_container.getElement('#release_'+self.last_release.id).addClass('last_release'); } - + if(self.next_release){ self.release_container.getElement('#release_'+self.next_release.id).addClass('next_release'); } diff --git a/couchpotato/static/images/emptylist.png b/couchpotato/static/images/emptylist.png new file mode 100644 index 00000000..08db6537 Binary files /dev/null and b/couchpotato/static/images/emptylist.png differ diff --git a/couchpotato/static/scripts/page/wanted.js b/couchpotato/static/scripts/page/wanted.js index 69743247..599e7814 100644 --- a/couchpotato/static/scripts/page/wanted.js +++ b/couchpotato/static/scripts/page/wanted.js @@ -18,13 +18,23 @@ Page.Wanted = new Class({ } }); + // See if userscript can be installed + + // Wanted movies self.wanted = new MovieList({ 'identifier': 'wanted', 'status': 'active', 'actions': MovieActions, 'add_new': true, - 'menu': [self.manual_search] + 'menu': [self.manual_search], + 'on_empty_element': App.createUserscriptButtons().setStyles({ + 'background-image': "url('"+Api.createUrl('static/images/emptylist.png')+"')", + 'height': 750, + 'width': 800, + 'padding-top': 260, + 'margin-top': -50 + }) }); $(self.wanted).inject(self.el);