cleaned up all the cells. there is a cell for pretty much everything.

pull/2/head
kay.one 12 years ago
parent ac3582d5c4
commit 70cfa5e685

@ -40,7 +40,6 @@ namespace NzbDrone.Api.Test.MappingTests
[TestCase(typeof(DownloadDecision), typeof(ReleaseResource))] [TestCase(typeof(DownloadDecision), typeof(ReleaseResource))]
[TestCase(typeof(Core.History.History), typeof(HistoryResource))] [TestCase(typeof(Core.History.History), typeof(HistoryResource))]
[TestCase(typeof(UpdatePackage), typeof(UpdateResource))] [TestCase(typeof(UpdatePackage), typeof(UpdateResource))]
[TestCase(typeof(QualityProfile), typeof(QualityProfileResource))]
[TestCase(typeof(Quality), typeof(QualityResource))] [TestCase(typeof(Quality), typeof(QualityResource))]
[TestCase(typeof(Log), typeof(LogResource))] [TestCase(typeof(Log), typeof(LogResource))]
public void matching_fields(Type modelType, Type resourceType) public void matching_fields(Type modelType, Type resourceType)

@ -2,11 +2,13 @@
using System.Collections.Generic; using System.Collections.Generic;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Core.Parser; using NzbDrone.Core.Parser;
using NzbDrone.Core.Tv;
namespace NzbDrone.Api.Indexers namespace NzbDrone.Api.Indexers
{ {
public class ReleaseResource : RestResource public class ReleaseResource : RestResource
{ {
public QualityModel Quality { get; set; }
public Int32 Age { get; set; } public Int32 Age { get; set; }
public Int64 Size { get; set; } public Int64 Size { get; set; }
public String Indexer { get; set; } public String Indexer { get; set; }

@ -3,7 +3,6 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using NzbDrone.Api.REST; using NzbDrone.Api.REST;
using NzbDrone.Common.Reflection; using NzbDrone.Common.Reflection;
using NzbDrone.Core.Datastore;
namespace NzbDrone.Api.Mapping namespace NzbDrone.Api.Mapping
{ {
@ -11,7 +10,7 @@ namespace NzbDrone.Api.Mapping
{ {
public static void ValidateMapping(Type modelType, Type resourceType) public static void ValidateMapping(Type modelType, Type resourceType)
{ {
var errors = modelType.GetSimpleProperties().Select(p => GetError(resourceType, p)).Where(c => c != null).ToList(); var errors = modelType.GetSimpleProperties().Where(c=>!c.GetGetMethod().IsStatic).Select(p => GetError(resourceType, p)).Where(c => c != null).ToList();
if (errors.Any()) if (errors.Any())
{ {
@ -48,9 +47,9 @@ namespace NzbDrone.Api.Mapping
return string.Format("public {0} {1} {{ get; set; }}", modelProperty.PropertyType.Name, modelProperty.Name); return string.Format("public {0} {1} {{ get; set; }}", modelProperty.PropertyType.Name, modelProperty.Name);
} }
if (resourceProperty.PropertyType != modelProperty.PropertyType) if (resourceProperty.PropertyType != modelProperty.PropertyType && !typeof(RestResource).IsAssignableFrom(resourceProperty.PropertyType))
{ {
return string.Format("Excpected {0}.{1} to have type of {2} but found {3}", resourceType.Name, resourceProperty.Name, modelProperty.PropertyType, resourceProperty.PropertyType); return string.Format("Expected {0}.{1} to have type of {2} but found {3}", resourceType.Name, resourceProperty.Name, modelProperty.PropertyType, resourceProperty.PropertyType);
} }
return null; return null;

@ -33,7 +33,8 @@ namespace NzbDrone.Common.Reflection
|| type == typeof(string) || type == typeof(string)
|| type == typeof(DateTime) || type == typeof(DateTime)
|| type == typeof(Version) || type == typeof(Version)
|| type == typeof(Decimal); || type == typeof(Decimal)
|| type.GetInterface("IEmbeddedDocument") != null;
} }
public static bool IsReadable(this PropertyInfo propertyInfo) public static bool IsReadable(this PropertyInfo propertyInfo)

@ -1,6 +1,6 @@
<SolutionConfiguration> <SolutionConfiguration>
<FileVersion>1</FileVersion> <FileVersion>1</FileVersion>
<AutoEnableOnStartup>True</AutoEnableOnStartup> <AutoEnableOnStartup>False</AutoEnableOnStartup>
<AllowParallelTestExecution>true</AllowParallelTestExecution> <AllowParallelTestExecution>true</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves> <AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit> <FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>

@ -8,6 +8,7 @@
<w>rootfolder</w> <w>rootfolder</w>
<w>rootfolders</w> <w>rootfolders</w>
<w>signalr</w> <w>signalr</w>
<w>templated</w>
<w>thetvdb</w> <w>thetvdb</w>
<w>trakt</w> <w>trakt</w>
<w>tvdb</w> <w>tvdb</w>

@ -0,0 +1,15 @@
"use strict";
define(['app', 'Shared/FormatHelpers'], function () {
NzbDrone.Cells.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(NzbDrone.Shared.FormatHelpers.DateHelper(airDate));
return this;
}
});
});

@ -0,0 +1,34 @@
"use strict";
define(['app', 'Cells/NzbDroneCell'], function () {
NzbDrone.Cells.EpisodeNumberCell = NzbDrone.Cells.NzbDroneCell.extend({
className: "episode-number-cell",
render: function () {
var airDate = this.cellValue.get('airDate') || this.get(this.column.get("airDate"));
var seasonNumber = this.cellValue.get('seasonNumber') || this.model.get(this.column.get("seasonNumber"));
var episodes = this.cellValue.get('episodeNumber') || this.model.get(this.column.get("episodes"));
var result = 'Unknown';
if (airDate) {
result = new Date(airDate).toLocaleDateString();
}
else {
var paddedEpisodes = _.map(episodes, function (episodeNumber) {
return episodeNumber.pad(2);
});
result = 'S{0}-E{1}'.format(seasonNumber, paddedEpisodes.join());
}
this.$el.html(result);
this.delegateEvents();
return this;
}
});
});

@ -1,7 +1,7 @@
"use strict"; "use strict";
define(['app', 'Episode/Layout'], function () { define(['app' ], function () {
NzbDrone.Series.Details.EpisodeStatusCell = Backgrid.Cell.extend({ NzbDrone.Cells.EpisodeStatusCell = Backgrid.Cell.extend({
className: 'episode-status-cell', className: 'episode-status-cell',

@ -1,7 +1,7 @@
"use strict"; "use strict";
define(['app', 'Episode/Layout'], function () { define(['app', 'Cells/NzbDroneCell'], function () {
NzbDrone.Series.Details.EpisodeTitleCell = Backgrid.StringCell.extend({ NzbDrone.Cells.EpisodeTitleCell = NzbDrone.Cells.NzbDroneCell.extend({
className: 'episode-title-cell', className: 'episode-title-cell',
@ -10,8 +10,13 @@ define(['app', 'Episode/Layout'], function () {
}, },
showDetails: function () { showDetails: function () {
var view = new NzbDrone.Episode.Layout({ model: this.model }); var view = new NzbDrone.Episode.Layout({ model: this.cellValue });
NzbDrone.modalRegion.show(view); NzbDrone.modalRegion.show(view);
},
render: function () {
this.$el.html(this.cellValue.get('title'));
return this;
} }
}); });
}); });

@ -0,0 +1,15 @@
"use strict";
define(['app', 'Shared/FormatHelpers'], function () {
NzbDrone.Cells.FileSizeCell = Backgrid.Cell.extend({
className: "file-size-cell",
render: function () {
var size = this.model.get(this.column.get("name"));
this.$el.html(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
this.delegateEvents();
return this;
}
});
});

@ -0,0 +1,13 @@
"use strict";
define(['app'], function () {
NzbDrone.Cells.IndexerCell = Backgrid.Cell.extend({
class : 'indexer-cell',
render: function () {
var indexer = this.model.get(this.column.get('name'));
this.$el.html(indexer);
return this;
}
});
});

@ -0,0 +1,40 @@
"use strict";
define(['app'], function () {
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({
_originalInit: Backgrid.Cell.prototype.initialize,
initialize: function () {
this._originalInit.apply(this, arguments);
this.cellValue = this._getValue();
this.model.on('change', this._refresh, this);
},
_refresh: function () {
this.cellValue = this._getValue();
this.render();
},
_getValue: function () {
var name = this.column.get('name');
if(name === 'this'){
return this.model;
}
var value = this.model.get(name);
//if not a model
if (!value.get) {
return value = new Backbone.Model(value);
}
return value;
}
});
});

@ -0,0 +1,9 @@
"use strict";
define(['app', 'Cells/TemplatedCell'], function () {
NzbDrone.Cells.QualityCell = NzbDrone.Cells.TemplatedCell.extend({
className: 'quality-cell',
template : 'Cells/QualityTemplate'
});
});

@ -0,0 +1,13 @@
"use strict";
define(['app'], function () {
NzbDrone.Cells.RelativeDateCell = Backgrid.Cell.extend({
render: function () {
var date = this.model.get(this.column.get('name'));
this.$el.html(Date.create(date).relative());
return this;
}
});
});

@ -0,0 +1,9 @@
"use strict";
define(['app', 'Cells/TemplatedCell'], function () {
NzbDrone.Cells.SeriesTitleCell = NzbDrone.Cells.TemplatedCell.extend({
className: 'series-title',
template : 'Cells/SeriesTitleTemplate'
});
});

@ -0,0 +1,2 @@
<a href="{{route}}">{{title}}</a>
{{debug}}

@ -0,0 +1,19 @@
"use strict";
define(['app','Cells/NzbDroneCell'], function () {
NzbDrone.Cells.TemplatedCell = NzbDrone.Cells.NzbDroneCell.extend({
render: function () {
var templateName = this.column.get('template') || this.template;
this.templateFunction = Marionette.TemplateCache.get(templateName);
var data = this.cellValue.toJSON();
var html = this.templateFunction(data);
this.$el.html(html);
return this;
}
});
});

@ -1,7 +1,7 @@
"use strict"; "use strict";
define(['app', 'Episode/Layout'], function () { define(['app', 'Episode/Layout'], function () {
NzbDrone.Shared.Cells.ToggleCell = Backgrid.Cell.extend({ NzbDrone.Cells.ToggleCell = Backgrid.Cell.extend({
className: 'toggle-cell clickable', className: 'toggle-cell clickable',

@ -0,0 +1,7 @@
@import "../content/Bootstrap/mixins";
@import "../content/Bootstrap/variables";
@import "../content/Bootstrap/buttons";
.episode-title-cell {
.btn-link;
}

@ -1,5 +1,5 @@
"use strict"; "use strict";
define(['app', 'Shared/Cells/FileSizeCell', 'Shared/Cells/ApprovalStatusCell'], function () { define(['app', 'Cells/FileSizeCell', 'Release/ApprovalStatusCell', 'Release/DownloadReportCell' ], function () {
NzbDrone.Episode.Search.Layout = Backbone.Marionette.Layout.extend({ NzbDrone.Episode.Search.Layout = Backbone.Marionette.Layout.extend({
template: 'Episode/Search/LayoutTemplate', template: 'Episode/Search/LayoutTemplate',
@ -19,7 +19,7 @@ define(['app', 'Shared/Cells/FileSizeCell', 'Shared/Cells/ApprovalStatusCell'],
name : 'size', name : 'size',
label : 'Size', label : 'Size',
sortable: true, sortable: true,
cell : NzbDrone.Shared.Cells.FileSizeCell cell : NzbDrone.Cells.FileSizeCell
}, },
{ {
name : 'title', name : 'title',
@ -30,7 +30,12 @@ define(['app', 'Shared/Cells/FileSizeCell', 'Shared/Cells/ApprovalStatusCell'],
{ {
name : 'rejections', name : 'rejections',
label: 'decision', label: 'decision',
cell : NzbDrone.Shared.Cells.ApprovalStatusCell cell : NzbDrone.Release.ApprovalStatusCell
},
{
name : 'download',
label: '',
cell : NzbDrone.Release.DownloadReportCell
} }
], ],

@ -1 +0,0 @@
{{episode.title}}

@ -2,7 +2,13 @@
define([ define([
'app', 'app',
'History/Collection', 'History/Collection',
'Series/Index/Table/AirDateCell', 'Cells/RelativeDateCell',
'Cells/IndexerCell',
'Cells/TemplatedCell',
'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell',
'Cells/QualityCell',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Shared/LoadingView' 'Shared/LoadingView'
], ],
@ -18,42 +24,36 @@ define([
columns: [ columns: [
{ {
name : 'indexer', name : 'indexer',
label : '', label: '',
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/IndexerTemplate' }) cell : NzbDrone.Cells.IndexerCell
}, },
{ {
name : 'Series.Title', name : 'series',
label : 'Series Title', label : 'Series',
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' }) cell : NzbDrone.Cells.SeriesTitleCell
}, },
{ {
name : 'episode', name : 'episode',
label : 'Episode', label : 'Episode',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' }) cell : NzbDrone.Cells.EpisodeNumberCell
}, },
{ {
name : 'Episode.Title', name : 'episode',
label : 'Episode Title', label : 'Episode Title',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/EpisodeTitleTemplate' }) cell : NzbDrone.Cells.EpisodeTitleCell
}, },
{ {
name : 'quality', name : 'quality',
label : 'Quality', label: 'Quality',
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/QualityTemplate' }) cell : NzbDrone.Cells.QualityCell
}, },
{ {
name : 'date', name : 'date',
label : 'Grabbed', label: 'Date',
cell : 'airDate' cell : NzbDrone.Cells.RelativeDateCell
},
{
name : 'edit',
label : '',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'History/ControlsColumnTemplate' })
} }
], ],
@ -68,7 +68,7 @@ define([
})); }));
this.pager.show(new Backgrid.NzbDronePaginator({ this.pager.show(new Backgrid.NzbDronePaginator({
columns: this.columns, columns : this.columns,
collection: this.historyCollection collection: this.historyCollection
})); }));
}, },
@ -80,9 +80,9 @@ define([
this.historyCollection = new NzbDrone.History.Collection(); this.historyCollection = new NzbDrone.History.Collection();
this.historyCollection.fetch() this.historyCollection.fetch()
.done(function () { .done(function () {
self._showTable(); self._showTable();
}); });
//this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this})); //this.toolbar.show(new NzbDrone.Shared.Toolbar.ToolbarLayout({right: [ viewButtons], context: this}));
} }

@ -1,5 +1,5 @@
"use strict"; "use strict";
define(['app'], function (app) { define(['app','Series/SeriesModel', 'Series/EpisodeModel'], function () {
NzbDrone.History.Model = Backbone.Model.extend({ NzbDrone.History.Model = Backbone.Model.extend({
mutators: { mutators: {
seasonNumber: function () { seasonNumber: function () {
@ -9,6 +9,14 @@ define(['app'], function (app) {
paddedEpisodeNumber: function () { paddedEpisodeNumber: function () {
return this.get('episode').episodeNumber.pad(2); return this.get('episode').episodeNumber.pad(2);
} }
},
parse: function (model) {
model.series = new NzbDrone.Series.SeriesModel(model.series);
model.episode = new NzbDrone.Series.EpisodeModel(model.episode);
return model;
} }
}); });
}); });

@ -9,6 +9,7 @@
<link href="/Content/Messenger/messenger.css" rel='stylesheet' type='text/css'/> <link href="/Content/Messenger/messenger.css" rel='stylesheet' type='text/css'/>
<link href="/Content/Messenger/messenger.future.css" rel='stylesheet' type='text/css'/> <link href="/Content/Messenger/messenger.future.css" rel='stylesheet' type='text/css'/>
<link href="/content/theme.css" rel='stylesheet' type='text/css'> <link href="/content/theme.css" rel='stylesheet' type='text/css'>
<link href="/Cells/cells.css" rel='stylesheet' type='text/css'>
<link href="/content/fullcalendar.css" rel='stylesheet' type='text/css'> <link href="/content/fullcalendar.css" rel='stylesheet' type='text/css'>
<link href="/content/backbone.css" rel='stylesheet' type='text/css'/> <link href="/content/backbone.css" rel='stylesheet' type='text/css'/>
<link href="/content/backbone.backgrid.filter.css" rel='stylesheet' type='text/css'/> <link href="/content/backbone.backgrid.filter.css" rel='stylesheet' type='text/css'/>
@ -84,7 +85,6 @@
<script src="/JsLibraries/underscore.js"></script> <script src="/JsLibraries/underscore.js"></script>
<script src="/JsLibraries/handlebars.runtime.js"></script> <script src="/JsLibraries/handlebars.runtime.js"></script>
<script src="/JsLibraries/backbone.js"></script> <script src="/JsLibraries/backbone.js"></script>
<script src="/JsLibraries/backbone.associations.js"></script>
<script src="/JsLibraries/backbone.modelbinder.js"></script> <script src="/JsLibraries/backbone.modelbinder.js"></script>
<script src="/JsLibraries/backbone.deep.model.js"></script> <script src="/JsLibraries/backbone.deep.model.js"></script>
<script src="/JsLibraries/backbone.mutators.js"></script> <script src="/JsLibraries/backbone.mutators.js"></script>

@ -1,2 +0,0 @@

{{seasonNumber}}x{{paddedEpisodeNumber}}

@ -2,9 +2,14 @@
define([ define([
'app', 'app',
'Missing/Collection', 'Missing/Collection',
'Series/Index/Table/AirDateCell', 'Missing/Row',
'Cells/AirDateCell',
'Series/Index/Table/SeriesStatusCell', 'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Cells/SeriesTitleCell',
'Cells/EpisodeNumberCell',
'Cells/EpisodeTitleCell',
'Cells/AirDateCell',
'Shared/LoadingView' 'Shared/LoadingView'
], ],
function () { function () {
@ -19,33 +24,27 @@ define([
columns: [ columns: [
{ {
name : 'series.Title', name : 'series',
label : 'Series Title', label : 'Series Title',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/SeriesTitleTemplate' }) cell : NzbDrone.Cells.SeriesTitleCell
}, },
{ {
name : 'episode', name : 'this',
label : 'Episode', label : 'Episode',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/EpisodeColumnTemplate' }) cell : NzbDrone.Cells.EpisodeNumberCell
}, },
{ {
name : 'title', name : 'this',
label : 'Episode Title', label : 'Episode Title',
sortable : false, sortable: false,
cell : 'string' cell : NzbDrone.Cells.EpisodeTitleCell
}, },
{ {
name : 'airDate', name : 'airDate',
label : 'Air Date', label: 'Air Date',
cell : 'airDate' cell : NzbDrone.Cells.AirDateCell
},
{
name : 'edit',
label : '',
sortable : false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Missing/ControlsColumnTemplate' })
} }
], ],
@ -59,7 +58,7 @@ define([
})); }));
this.pager.show(new Backgrid.NzbDronePaginator({ this.pager.show(new Backgrid.NzbDronePaginator({
columns: this.columns, columns : this.columns,
collection: this.missingCollection collection: this.missingCollection
})); }));
}, },
@ -71,9 +70,9 @@ define([
this.missingCollection = new NzbDrone.Missing.Collection(); this.missingCollection = new NzbDrone.Missing.Collection();
this.missingCollection.fetch() this.missingCollection.fetch()
.done(function () { .done(function () {
self._showTable(); self._showTable();
}); });
} }
}); });
}); });

@ -1,2 +0,0 @@
{{! TODO: Should use route instead of hard coding link }}
<a href="/series/details/{{series.titleSlug}}">{{series.title}}</a>

@ -11,19 +11,6 @@ Backgrid.Column.prototype.defaults = {
headerCell: 'nzbDrone' headerCell: 'nzbDrone'
}; };
Backgrid.TemplateBackedCell = Backgrid.Cell.extend({
className: '',
template : 'Series/Index/Table/ControlsColumnTemplate',
render: function () {
var data = this.model.toJSON();
var templateFunction = Marionette.TemplateCache.get(this.template);
var html = templateFunction(data);
this.$el.html(html);
return this;
}
});
Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({ Backgrid.NzbDroneHeaderCell = Backgrid.HeaderCell.extend({
events: { events: {

@ -1,5 +1,5 @@
"use strict"; "use strict";
NzbDrone.Shared.Cells.ApprovalStatusCell = Backgrid.Cell.extend({ NzbDrone.Release.ApprovalStatusCell = Backgrid.Cell.extend({
className: "approval-status-cell", className: "approval-status-cell",

@ -0,0 +1,27 @@
"use strict";
NzbDrone.Release.DownloadReportCell = Backgrid.Cell.extend({
className: "download-report-cell",
events: {
'click': '_onClick'
},
_onClick: function () {
var self = this;
this.$el.html('<i class ="icon-spinner icon-spin" />');
this.model.save()
.always(function () {
self.$el.html('<i class ="icon-download-alt" />');
});
},
render: function () {
this.$el.html('<i class ="icon-download-alt" />');
return this;
}
});

@ -2,11 +2,12 @@
define([ define([
'app', 'app',
'Release/Collection', 'Release/Collection',
'Release/ApprovalStatusCell',
'Shared/SpinnerView', 'Shared/SpinnerView',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Shared/Cells/EpisodeNumberCell', 'Cells/EpisodeNumberCell',
'Shared/Cells/FileSizeCell', 'Cells/FileSizeCell',
'Shared/Cells/ApprovalStatusCell' 'Cells/IndexerCell'
], ],
function () { function () {
NzbDrone.Release.Layout = Backbone.Marionette.Layout.extend({ NzbDrone.Release.Layout = Backbone.Marionette.Layout.extend({
@ -22,13 +23,13 @@ define([
name : 'indexer', name : 'indexer',
label : 'Indexer', label : 'Indexer',
sortable: true, sortable: true,
cell : Backgrid.StringCell cell : NzbDrone.Cells.IndexerCell
}, },
{ {
name : 'size', name : 'size',
label : 'Size', label : 'Size',
sortable: true, sortable: true,
cell : NzbDrone.Shared.Cells.FileSizeCell cell : NzbDrone.Cells.FileSizeCell
}, },
{ {
name : 'title', name : 'title',
@ -38,16 +39,14 @@ define([
}, },
{ {
name : 'episodeNumbers', name : 'episodeNumbers',
season : 'seasonNumber',
airDate : 'airDate',
episodes: 'episodeNumbers', episodes: 'episodeNumbers',
label : 'season', label : 'season',
cell : NzbDrone.Shared.Cells.EpisodeNumberCell cell : NzbDrone.Cells.EpisodeNumberCell
}, },
{ {
name : 'rejections', name : 'rejections',
label: 'decision', label: 'decision',
cell : NzbDrone.Shared.Cells.ApprovalStatusCell cell : NzbDrone.Release.ApprovalStatusCell
} }
], ],

@ -1,64 +1,68 @@
'use strict'; 'use strict';
define(['app', 'Series/Details/EpisodeStatusCell', 'Series/Details/EpisodeTitleCell','Shared/Cells/ToggleCell'], function () { define([
NzbDrone.Series.Details.SeasonLayout = Backbone.Marionette.Layout.extend({ 'app',
template: 'Series/Details/SeasonLayoutTemplate', 'Cells/EpisodeStatusCell',
'Cells/EpisodeTitleCell',
'Cells/AirDateCell',
'Cells/ToggleCell'],
function () {
NzbDrone.Series.Details.SeasonLayout = Backbone.Marionette.Layout.extend({
template: 'Series/Details/SeasonLayoutTemplate',
regions: { regions: {
episodeGrid: '#x-episode-grid' episodeGrid: '#x-episode-grid'
}, },
columns: [ columns: [
{ {
name : 'ignored', name : 'ignored',
label: '', label : '',
cell : NzbDrone.Shared.Cells.ToggleCell, cell : NzbDrone.Cells.ToggleCell,
trueClass : 'icon-bookmark-empty', trueClass : 'icon-bookmark-empty',
falseClass :'icon-bookmark' falseClass: 'icon-bookmark'
}, },
{ {
name : 'episodeNumber', name : 'episodeNumber',
label: '#', label: '#',
cell : Backgrid.IntegerCell.extend({ cell : Backgrid.IntegerCell.extend({
className: 'episode-number-cell' className: 'episode-number-cell'
}) })
}, },
{ {
name : 'title', name : 'this',
label: 'Title', label: 'Title',
cell : NzbDrone.Series.Details.EpisodeTitleCell cell : NzbDrone.Cells.EpisodeTitleCell
}, },
{ {
name : 'airDate', name : 'airDate',
label: 'Air Date', label: 'Air Date',
cell : Backgrid.DateCell.extend({ cell : NzbDrone.Cells.AirDateCell
className: 'episode-air-date-cell' } ,
}) {
} , name : 'status',
{ label: 'Status',
name : 'status', cell : NzbDrone.Cells.EpisodeStatusCell
label: 'Status', }
cell : NzbDrone.Series.Details.EpisodeStatusCell ],
}
],
initialize: function (options) { initialize: function (options) {
if (!options.episodeCollection) { if (!options.episodeCollection) {
throw 'episodeCollection is needed'; throw 'episodeCollection is needed';
} }
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber')); this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
}, },
onShow: function () { onShow: function () {
this.episodeGrid.show(new Backgrid.Grid( this.episodeGrid.show(new Backgrid.Grid(
{ {
columns : this.columns, columns : this.columns,
collection: this.episodeCollection, collection: this.episodeCollection,
className : 'table table-hover season-grid' className : 'table table-hover season-grid'
})); }));
} }
});
}); });
});

@ -1,5 +1,5 @@
'use strict'; 'use strict';
define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/QualityProfileCollection'], function () { define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/QualityProfileCollection'], function (app, seriesModel, deleteSeriesView, qualityProfiles) {
NzbDrone.Series.Edit.EditSeriesView = Backbone.Marionette.ItemView.extend({ NzbDrone.Series.Edit.EditSeriesView = Backbone.Marionette.ItemView.extend({
template : 'Series/Edit/EditSeriesTemplate', template : 'Series/Edit/EditSeriesTemplate',
@ -16,6 +16,13 @@ define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/
}, },
initialize : function(){
this.model.set('qualityProfiles',qualityProfiles);
},
saveSeries: function () { saveSeries: function () {
//Todo: Get qualityProfile + backlog setting from UI //Todo: Get qualityProfile + backlog setting from UI
var qualityProfile = this.ui.qualityProfile.val(); var qualityProfile = this.ui.qualityProfile.val();
@ -35,4 +42,4 @@ define(['app', 'Series/SeriesModel', 'Series/Delete/DeleteSeriesView', 'Quality/
} }
}); });
}); });

@ -1,5 +1,5 @@
"use strict"; "use strict";
define(['app'], function () { define(['app','Series/SeriesModel'], function () {
NzbDrone.Series.EpisodeModel = Backbone.Model.extend({ NzbDrone.Series.EpisodeModel = Backbone.Model.extend({
mutators: { mutators: {
@ -55,6 +55,13 @@ define(['app'], function () {
} }
}, },
parse: function (model) {
model.series = new NzbDrone.Series.SeriesModel(model.series);
return model;
},
defaults: { defaults: {
seasonNumber: 0, seasonNumber: 0,
status : 0 status : 0

@ -4,7 +4,9 @@ define([
'Series/Index/List/CollectionView', 'Series/Index/List/CollectionView',
'Series/Index/Posters/CollectionView', 'Series/Index/Posters/CollectionView',
'Series/Index/EmptyView', 'Series/Index/EmptyView',
'Series/Index/Table/AirDateCell', 'Cells/AirDateCell',
'Cells/SeriesTitleCell',
'Cells/TemplatedCell',
'Series/Index/Table/SeriesStatusCell', 'Series/Index/Table/SeriesStatusCell',
'Shared/Toolbar/ToolbarLayout', 'Shared/Toolbar/ToolbarLayout',
'Config', 'Config',
@ -21,46 +23,48 @@ define([
columns: [ columns: [
{ {
name : 'status', name : 'status',
label : '', label: '',
cell : 'seriesStatus' cell : 'seriesStatus'
}, },
{ {
name : 'title', name : 'this',
label : 'Title', label: 'Title',
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/SeriesTitleTemplate' }) cell : NzbDrone.Cells.SeriesTitleCell
}, },
{ {
name : 'seasonCount', name : 'seasonCount',
label : 'Seasons', label: 'Seasons',
cell : 'integer' cell : 'integer'
}, },
{ {
name : 'quality', name : 'quality',
label : 'Quality', label: 'Quality',
cell : 'integer' cell : 'integer'
}, },
{ {
name : 'network', name : 'network',
label : 'Network', label: 'Network',
cell : 'string' cell : 'string'
}, },
{ {
name : 'nextAiring', name : 'nextAiring',
label : 'Next Airing', label: 'Next Airing',
cell : 'airDate' cell : NzbDrone.Cells.AirDateCell
}, },
{ {
name : 'episodes', name : 'this',
label : 'Episodes', label : 'Episodes',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/EpisodeProgressTemplate' }) template: 'Series/EpisodeProgressTemplate',
cell : NzbDrone.Cells.TemplatedCell
}, },
{ {
name : 'edit', name : 'this',
label : '', label : '',
sortable : false, sortable: false,
cell : Backgrid.TemplateBackedCell.extend({ template: 'Series/Index/Table/ControlsColumnTemplate' }) template: 'Series/Index/Table/ControlsColumnTemplate',
cell : NzbDrone.Cells.TemplatedCell
} }
], ],
@ -92,12 +96,12 @@ define([
_showTable: function () { _showTable: function () {
var view = new Backgrid.Grid( var view = new Backgrid.Grid(
{ {
row : NzbDrone.Series.Index.Table.Row, row : NzbDrone.Series.Index.Table.Row,
columns : this.columns, columns : this.columns,
collection: this.seriesCollection, collection: this.seriesCollection,
className : 'table table-hover' className : 'table table-hover'
}); });
this._fetchCollection(view); this._fetchCollection(view);
}, },
@ -149,10 +153,10 @@ define([
//TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?) //TODO: Move this outside of the function - 'this' is not available for the call back though (use string like events?)
var viewButtons = { var viewButtons = {
type : 'radio', type : 'radio',
storeState : true, storeState : true,
menuKey : 'seriesViewMode', menuKey : 'seriesViewMode',
defaultAction: 'listView', defaultAction: 'listView',
items : [ items : [
{ {
key : 'tableView', key : 'tableView',
title : '', title : '',

@ -1,13 +0,0 @@
"use strict";
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(NzbDrone.Shared.FormatHelpers.DateHelper(airDate));
return this;
}
});

@ -1,5 +1,4 @@
<ul> <ul>
{{debug}}
{{#each handles}} {{#each handles}}
<li {{#if className}}class="{{className}}"{{/if}}> <li {{#if className}}class="{{className}}"{{/if}}>
{{#if pageNumber}} {{#if pageNumber}}
@ -9,4 +8,4 @@
{{/if}} {{/if}}
</li> </li>
{{/each}} {{/each}}
</ul> </ul>

@ -1,30 +0,0 @@
"use strict";
NzbDrone.Shared.Cells.EpisodeNumberCell = Backgrid.Cell.extend({
className: "episode-number-cell",
render: function () {
var airDate = this.model.get(this.column.get("airDate"));
var result = 'Unknown';
if (airDate) {
result = new Date(airDate).toLocaleDateString();
}
else {
var season = this.model.get(this.column.get("season")).pad(2);
var episodes = _.map(this.model.get(this.column.get("episodes")), function (episodeNumber) {
return episodeNumber.pad(2);
});
result = 'S{0}-E{1}'.format(season, episodes.join());
}
this.$el.html(result);
this.delegateEvents();
return this;
}
});

@ -1,12 +0,0 @@
"use strict";
NzbDrone.Shared.Cells.FileSizeCell = Backgrid.Cell.extend({
className: "file-size-cell",
render: function () {
var size = this.model.get(this.column.get("name"));
this.$el.html(NzbDrone.Shared.FormatHelpers.FileSizeHelper(size));
this.delegateEvents();
return this;
}
});

@ -62,12 +62,14 @@ define('app', ['shared/modal/region'], function (ModalRegion) {
window.NzbDrone.Commands = {}; window.NzbDrone.Commands = {};
window.NzbDrone.Shared = { window.NzbDrone.Shared = {
Toolbar : {}, Toolbar : {},
Messenger: {}, Messenger : {},
Cells: {},
FormatHelpers: {} FormatHelpers: {}
}; };
window.NzbDrone.Cells = {};
window.NzbDrone.Calendar = {}; window.NzbDrone.Calendar = {};
window.NzbDrone.Settings = { window.NzbDrone.Settings = {
@ -79,7 +81,7 @@ define('app', ['shared/modal/region'], function (ModalRegion) {
Indexers : {}, Indexers : {},
DownloadClient: {}, DownloadClient: {},
Notifications : {}, Notifications : {},
General : {}, General : {},
Misc : {} Misc : {}
}; };

Loading…
Cancel
Save