From 74a4def877b7e192df75790cd8ba7a487f9dd678 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 28 Jul 2013 18:12:34 -0700 Subject: [PATCH] Added series stats to footer --- UI/Series/Index/FooterModel.js | 9 ++++++ .../Index/{LegendView.js => FooterView.js} | 2 +- UI/Series/Index/FooterViewTemplate.html | 21 +++++++++++++ UI/Series/Index/LegendViewTemplate.html | 7 ----- UI/Series/Index/SeriesIndexLayout.js | 30 +++++++++++++++---- .../Index/SeriesIndexLayoutTemplate.html | 8 ++--- UI/Series/series.less | 7 +++++ 7 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 UI/Series/Index/FooterModel.js rename UI/Series/Index/{LegendView.js => FooterView.js} (73%) create mode 100644 UI/Series/Index/FooterViewTemplate.html delete mode 100644 UI/Series/Index/LegendViewTemplate.html diff --git a/UI/Series/Index/FooterModel.js b/UI/Series/Index/FooterModel.js new file mode 100644 index 000000000..0ed6ca77c --- /dev/null +++ b/UI/Series/Index/FooterModel.js @@ -0,0 +1,9 @@ +'use strict'; +define( + [ + 'backbone', + 'underscore' + ], function (Backbone, _) { + return Backbone.Model.extend({ + }); + }); diff --git a/UI/Series/Index/LegendView.js b/UI/Series/Index/FooterView.js similarity index 73% rename from UI/Series/Index/LegendView.js rename to UI/Series/Index/FooterView.js index c5fac4c4d..0e569b70a 100644 --- a/UI/Series/Index/LegendView.js +++ b/UI/Series/Index/FooterView.js @@ -4,6 +4,6 @@ define( 'marionette' ], function (Marionette) { return Marionette.CompositeView.extend({ - template: 'Series/Index/LegendViewTemplate' + template: 'Series/Index/FooterViewTemplate' }); }); diff --git a/UI/Series/Index/FooterViewTemplate.html b/UI/Series/Index/FooterViewTemplate.html new file mode 100644 index 000000000..e55cb7755 --- /dev/null +++ b/UI/Series/Index/FooterViewTemplate.html @@ -0,0 +1,21 @@ +
+
+
    +
  • Continuing (All Episodes downloaded)
  • +
  • Ended (All Episodes downloaded)
  • +
  • Missing Episodes
  • +
+
+ +
+
+
Series
+
{{count}}
+
Episodes
+
{{episodeCount}}
+
Files
+
{{episodeFileCount}}
+
+ +
+
diff --git a/UI/Series/Index/LegendViewTemplate.html b/UI/Series/Index/LegendViewTemplate.html deleted file mode 100644 index 11a7486a4..000000000 --- a/UI/Series/Index/LegendViewTemplate.html +++ /dev/null @@ -1,7 +0,0 @@ -
- -
\ No newline at end of file diff --git a/UI/Series/Index/SeriesIndexLayout.js b/UI/Series/Index/SeriesIndexLayout.js index 916613b3e..8bfd57ef1 100644 --- a/UI/Series/Index/SeriesIndexLayout.js +++ b/UI/Series/Index/SeriesIndexLayout.js @@ -12,7 +12,8 @@ define( 'Cells/QualityProfileCell', 'Series/Index/Table/SeriesStatusCell', 'Series/Index/Table/Row', - 'Series/Index/LegendView', + 'Series/Index/FooterView', + 'Series/Index/FooterModel', 'Shared/Toolbar/ToolbarLayout', 'Shared/LoadingView' ], function (Marionette, @@ -26,7 +27,8 @@ define( QualityProfileCell, SeriesStatusCell, SeriesIndexRow, - LegendView, + FooterView, + FooterModel, ToolbarLayout, LoadingView) { return Marionette.Layout.extend({ @@ -35,7 +37,7 @@ define( regions: { seriesRegion: '#x-series', toolbar : '#x-toolbar', - legend : '#x-legend' + footer : '#x-series-footer' }, columns: @@ -155,9 +157,9 @@ define( else { this.currentView.collection = SeriesCollection; this.seriesRegion.show(this.currentView); - this.legend.show(new LegendView()); this._showToolbar(); + this._showFooter(); } }, @@ -168,7 +170,6 @@ define( this._fetchCollection(); }, - _fetchCollection: function () { if (SeriesCollection.length === 0) { this.seriesRegion.show(new LoadingView()); @@ -225,6 +226,25 @@ define( ], context: this })); + }, + + _showFooter: function () { + var footerModel = new FooterModel(); + var episodeCount = _.reduce(SeriesCollection.models, function (memo, model) { + return memo + model.get('episodeCount'); + }, 0); + + var episodeFileCount = _.reduce(SeriesCollection.models, function (memo, model) { + return memo + model.get('episodeFileCount'); + }, 0); + + footerModel.set({ + count: SeriesCollection.models.length, + episodeCount: episodeCount, + episodeFileCount: episodeFileCount + }); + + this.footer.show(new FooterView({ model: footerModel })); } }); }); diff --git a/UI/Series/Index/SeriesIndexLayoutTemplate.html b/UI/Series/Index/SeriesIndexLayoutTemplate.html index a140e82cc..40124822f 100644 --- a/UI/Series/Index/SeriesIndexLayoutTemplate.html +++ b/UI/Series/Index/SeriesIndexLayoutTemplate.html @@ -1,11 +1,9 @@ 
+
-
-
-
-
-
\ No newline at end of file + + \ No newline at end of file diff --git a/UI/Series/series.less b/UI/Series/series.less index c9491fb3b..0908c4e38 100644 --- a/UI/Series/series.less +++ b/UI/Series/series.less @@ -221,3 +221,10 @@ } } +.series-stats { + font-size: 11px; +} + +.series-legend { + padding-top: 5px; +} \ No newline at end of file