Less model pollution

This commit is contained in:
Mark McDowall 2013-08-21 14:47:39 -07:00
parent 488da59143
commit 8e2364966a
8 changed files with 26 additions and 31 deletions

View File

@ -57,14 +57,17 @@ define(
success: function (calendarCollection) {
_.each(calendarCollection.models, function (element) {
var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title');
var seriesTitle = element.get('series').title;
var start = element.get('airDateUtc');
var statusLevel = _instance.getStatusLevel(element);
var runtime = element.get('series').runtime;
var end = Moment(start).add('minutes', runtime);
element.set({
title : seriesTitle,
episodeTitle: episodeTitle,
start : start,
end : end,
allDay : false,
statusLevel : statusLevel
});

View File

@ -2,11 +2,11 @@
define(
[
'backgrid',
'Cells/NzbDroneCell',
'moment',
'Shared/FormatHelpers'
], function (Backgrid, Moment, FormatHelpers) {
return Backgrid.Cell.extend({
], function (NzbDroneCell, Moment, FormatHelpers) {
return NzbDroneCell.extend({
className: 'episode-status-cell',

View File

@ -25,7 +25,9 @@ define(
},
_showDetails: function () {
App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.cellValue});
var hideSeriesLink = this.column.get('hideSeriesLink');
App.vent.trigger(App.Commands.ShowEpisodeDetails, {episode: this.cellValue, hideSeriesLink: hideSeriesLink });
}
});
});

View File

@ -3,8 +3,9 @@ define(
[
'marionette',
'Episode/Summary/Layout',
'Episode/Search/Layout'
], function (Marionette, SummaryLayout, SearchLayout) {
'Episode/Search/Layout',
'Series/SeriesCollection'
], function (Marionette, SummaryLayout, SearchLayout, SeriesCollection) {
return Marionette.Layout.extend({
template: 'Episode/LayoutTemplate',
@ -30,6 +31,16 @@ define(
'click .x-episode-monitored': '_toggleMonitored'
},
templateHelpers: {},
initialize: function (options) {
this.templateHelpers.hideSeriesLink = options.hideSeriesLink;
var series = SeriesCollection.find({ id: this.model.get('seriesId') });
this.templateHelpers.series = series.toJSON();
var test = 1;
},
onShow: function () {
this._showSummary();
this.searchLayout = new SearchLayout({ model: this.model });

View File

@ -3,6 +3,7 @@
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>
{{debug}}
<i class="icon-bookmark x-episode-monitored" title="Toggle monitored status" />
{{#if episodeTitle}}
{{title}} - {{EpisodeNumber}} - {{episodeTitle}}

View File

@ -50,6 +50,7 @@ define(
{
name : 'this',
label : 'Title',
hideSeriesLink : true,
cell : EpisodeTitleCell,
sortable: false
},
@ -74,10 +75,6 @@ define(
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber'));
_.each(this.episodeCollection.models, function (episode) {
episode.set({ hideSeriesLink: true, series: options.series });
});
this.listenTo(this.model, 'sync', function () {
this._afterSeasonMonitored();
}, this);

View File

@ -8,17 +8,7 @@ define(
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
return Backbone.Model.extend({
initialize: function () {
if (this.has('series')) {
var start = Moment(this.get('airDateUtc'));
var runtime = this.get('series').get('runtime');
this.set('end', start.add('minutes', runtime));
}
},
parse: function (model) {
model.series = new SeriesModel(model.series);
if (model.episodeFile) {
model.episodeFile = new EpisodeFileModel(model.episodeFile);
@ -27,15 +17,6 @@ define(
return model;
},
toJSON: function () {
var json = _.clone(this.attributes);
if (this.has('series')) {
json.series = this.get('series').toJSON();
}
return json;
},
defaults: {
seasonNumber: 0,
status : 0

View File

@ -33,7 +33,7 @@ define(
},
_showEpisode: function (options) {
var view = new EpisodeLayout({ model: options.episode });
var view = new EpisodeLayout({ model: options.episode, hideSeriesLink: options.hideSeriesLink });
App.modalRegion.show(view);
}
});