From 4cc4e8133ee7ddf818eebf7e54ef851954f8a0da Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 22 Apr 2013 23:06:55 -0700 Subject: [PATCH] Finished Series Index Table formatting --- UI/Index.html | 1 + UI/Mixins/backbone.Backgrid.mixin.js | 83 +++++++++++++++++++ UI/Series/EpisodeProgressTemplate.html | 5 ++ UI/Series/Index/SeriesIndexLayout.js | 8 +- .../Index/Table/ControlsColumnTemplate.html | 2 + UI/app.js | 44 ---------- 6 files changed, 95 insertions(+), 48 deletions(-) create mode 100644 UI/Mixins/backbone.Backgrid.mixin.js create mode 100644 UI/Series/EpisodeProgressTemplate.html create mode 100644 UI/Series/Index/Table/ControlsColumnTemplate.html diff --git a/UI/Index.html b/UI/Index.html index 27872d6d8..3b9894255 100644 --- a/UI/Index.html +++ b/UI/Index.html @@ -104,6 +104,7 @@ + diff --git a/UI/Mixins/backbone.Backgrid.mixin.js b/UI/Mixins/backbone.Backgrid.mixin.js new file mode 100644 index 000000000..11dcacb48 --- /dev/null +++ b/UI/Mixins/backbone.Backgrid.mixin.js @@ -0,0 +1,83 @@ +Backgrid.SeriesStatusCell = Backgrid.Cell.extend({ + className: "series-status-cell", + + render: function () { + this.$el.empty(); + var monitored = this.model.get('monitored'); + var status = this.model.get('status'); + + if (!monitored) { + this.$el.html(''); + } + else if (status === 0) { + this.$el.html(''); + } + + else { + this.$el.html(''); + } + + return this; + } +}); + +Backgrid.AirDateCell = Backgrid.Cell.extend({ + className: "air-date-cell", + + render: function () { + this.$el.empty(); + var airDate = this.model.get(this.column.get("name")); + + this.$el.html(bestDateString(airDate)); + + return this; + } +}); + +Backgrid.EpisodeProgressCell = Backgrid.Cell.extend({ + className: "episode-progress-cell", + template: 'Series/EpisodeProgressTemplate', + + render: function () { + var data = this.model.toJSON(); + var html = Marionette.Renderer.render(this.template, data); + this.$el.html(html); + + return this; + } +}); + +Backgrid.ControlsColumnCell = Backgrid.Cell.extend({ + className: "controls-cell", + template: 'Series/Index/Table/ControlsColumnTemplate', + + render: function () { + var data = this.model.toJSON(); + var html = Marionette.Renderer.render(this.template, data); + this.$el.html(html); + + return this; + } +}); + +Backgrid.SeriesIndexTableRow = Backgrid.Row.extend({ + events: { + 'click .x-edit' : 'editSeries', + 'click .x-remove': 'removeSeries' + }, + + editSeries: function () { + var view = new NzbDrone.Series.Edit.EditSeriesView({ model: this.model}); + + NzbDrone.vent.trigger(NzbDrone.Events.OpenModalDialog, { + view: view + }); + }, + + removeSeries: function () { + var view = new NzbDrone.Series.Delete.DeleteSeriesView({ model: this.model }); + NzbDrone.vent.trigger(NzbDrone.Events.OpenModalDialog, { + view: view + }); + } +}); \ No newline at end of file diff --git a/UI/Series/EpisodeProgressTemplate.html b/UI/Series/EpisodeProgressTemplate.html new file mode 100644 index 000000000..2fa193038 --- /dev/null +++ b/UI/Series/EpisodeProgressTemplate.html @@ -0,0 +1,5 @@ +
+ {{episodeFileCount}} / {{episodeCount}} + +
{{episodeFileCount}} / {{episodeCount}}
+
\ No newline at end of file diff --git a/UI/Series/Index/SeriesIndexLayout.js b/UI/Series/Index/SeriesIndexLayout.js index e47404495..ca1235126 100644 --- a/UI/Series/Index/SeriesIndexLayout.js +++ b/UI/Series/Index/SeriesIndexLayout.js @@ -58,27 +58,27 @@ define([ name: 'nextAiring', label: 'Next Airing', editable: false, - cell: 'datetime', - formatter: new Backgrid.AirDateFormatter() + cell: 'airDate' }, { name: 'episodes', label: 'Episodes', editable: false, sortable: false, - cell: 'string' + cell: 'episodeProgress' }, { name: 'edit', label: '', editable: false, sortable: false, - cell: 'string' + cell: 'controlsColumn' } ]; this.series.show(new Backgrid.Grid( { + row: Backgrid.SeriesIndexTableRow, columns : columns, collection : this.seriesCollection, className: 'table table-hover' diff --git a/UI/Series/Index/Table/ControlsColumnTemplate.html b/UI/Series/Index/Table/ControlsColumnTemplate.html new file mode 100644 index 000000000..48f19e1df --- /dev/null +++ b/UI/Series/Index/Table/ControlsColumnTemplate.html @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/UI/app.js b/UI/app.js index 092de2656..eabbaea3a 100644 --- a/UI/app.js +++ b/UI/app.js @@ -71,49 +71,6 @@ define('app', function () { console.log('starting application'); - //TODO: move these out of here - Backgrid.SeriesStatusCell = Backgrid.Cell.extend({ - className: "series-status-cell", - - render: function () { - this.$el.empty(); - var monitored = this.model.get('monitored'); - var status = this.model.get('status'); - - if (!monitored) { - this.$el.html(''); - } - else if (status === 0) { - this.$el.html(''); - } - - else { - this.$el.html(''); - } - - return this; - } - }); - - var AirDateFormatter = Backgrid.AirDateFormatter = function () {}; - AirDateFormatter.prototype = new Backgrid.CellFormatter(); - _.extend(AirDateFormatter.prototype, { - /** - Converts any value to a string using Ecmascript's implicit type - conversion. If the given value is `null` or `undefined`, an empty string is - returned instead. - - @member Backgrid.StringFormatter - @param {*} rawValue - @return {string} - */ - fromRaw: function (rawValue) { - return 'Hello World'; - - if (_.isUndefined(rawValue) || _.isNull(rawValue)) return ''; - return rawValue + ''; - } - }); }); NzbDrone.addRegions({ @@ -122,7 +79,6 @@ define('app', function () { notificationRegion: '#notification-region' }); - window.NzbDrone.start(); return NzbDrone;