fix the footer to show correct information and refresh when FullCollection changes (#893)

pull/2/head
geogolem 8 years ago committed by Devin Buhl
parent 997dce288d
commit 55ac2dd1bb

@ -122,9 +122,13 @@ module.exports = Marionette.Layout.extend({
initialize : function() { initialize : function() {
this.seriesCollection = MoviesCollection.clone(); this.seriesCollection = MoviesCollection.clone();
this.seriesCollection.bindSignalR(); this.seriesCollection.bindSignalR();
this.fullCollection = FullMovieCollection; //this.fullCollection = FullMovieCollection;
//need to add this so the footer gets refreshed
this.listenTo(FullMovieCollection, 'sync', function(model, collection, options) {
//this._renderView();
this._showFooter();
});
this.listenTo(this.seriesCollection, 'sync', function(model, collection, options) { this.listenTo(this.seriesCollection, 'sync', function(model, collection, options) {
//this.seriesCollection.fullCollection.resetFiltered(); //this.seriesCollection.fullCollection.resetFiltered();
@ -310,7 +314,7 @@ module.exports = Marionette.Layout.extend({
//debugger; //debugger;
}); });
this._showToolbar(); this._showToolbar();
this._showFooter(); //this._showFooter();
} }
}, },
@ -362,75 +366,78 @@ module.exports = Marionette.Layout.extend({
_showFooter : function() { _showFooter : function() {
var footerModel = new FooterModel(); var footerModel = new FooterModel();
var movies = MoviesCollection.models.length; var movies = FullMovieCollection.models.length;
//instead of all the counters could do something like this with different query in the where...
//var releasedMovies = FullMovieCollection.where({ 'released' : this.model.get('released') });
// releasedMovies.length
var announced = 0; var announced = 0;
var incinemas = 0; var incinemas = 0;
var released = 0; var released = 0;
var monitored = 0; var monitored = 0;
var downloaded =0; var downloaded =0;
var missingMonitored=0; var missingMonitored=0;
var missingNotMonitored=0; var missingNotMonitored=0;
var missingNotAvailable=0; var missingNotAvailable=0;
var missingMonitoredAvailable=0; var missingMonitoredAvailable=0;
var downloadedNotMonitored=0; var downloadedNotMonitored=0;
_.each(MoviesCollection.models, function(model) { _.each(FullMovieCollection.models, function(model) {
if (model.get('status').toLowerCase() === 'released') { if (model.get('status').toLowerCase() === 'released') {
released++; released++;
} }
else if (model.get('status').toLowerCase() === 'incinemas') { else if (model.get('status').toLowerCase() === 'incinemas') {
incinemas++; incinemas++;
} }
else if (model.get('status').toLowerCase() === 'announced') { else if (model.get('status').toLowerCase() === 'announced') {
announced++; announced++;
} }
if (model.get('monitored')) { if (model.get('monitored')) {
monitored++; monitored++;
} }
else { //not monitored else { //not monitored
if (model.get('downloaded')) { if (model.get('downloaded')) {
downloadedNotMonitored++; downloadedNotMonitored++;
} }
else { //missing else { //missing
missingNotMonitored++; missingNotMonitored++;
} }
} }
if (model.get('downloaded')) { if (model.get('downloaded')) {
downloaded++; downloaded++;
} }
else { //missing else { //missing
if (!model.get('isAvailable')) { if (!model.get('isAvailable')) {
missingNotAvailable++; missingNotAvailable++;
} }
if (model.get('monitored')) { if (model.get('monitored')) {
missingMonitored++; missingMonitored++;
if (model.get('isAvailable')) { if (model.get('isAvailable')) {
missingMonitoredAvailable++; missingMonitoredAvailable++;
} }
} }
} }
}); });
footerModel.set({ footerModel.set({
movies : movies, movies : movies,
announced : announced, announced : announced,
incinemas : incinemas, incinemas : incinemas,
released : released, released : released,
monitored : monitored, monitored : monitored,
downloaded : downloaded, downloaded : downloaded,
downloadedNotMonitored : downloadedNotMonitored, downloadedNotMonitored : downloadedNotMonitored,
missingMonitored : missingMonitored, missingMonitored : missingMonitored,
missingMonitoredAvailable : missingMonitoredAvailable, missingMonitoredAvailable : missingMonitoredAvailable,
missingNotAvailable : missingNotAvailable, missingNotAvailable : missingNotAvailable,
missingNotMonitored : missingNotMonitored missingNotMonitored : missingNotMonitored
}); });
this.footer.show(new FooterView({ model : footerModel })); this.footer.show(new FooterView({ model : footerModel }));

Loading…
Cancel
Save