1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

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) { success: function (calendarCollection) {
_.each(calendarCollection.models, function (element) { _.each(calendarCollection.models, function (element) {
var episodeTitle = element.get('title'); var episodeTitle = element.get('title');
var seriesTitle = element.get('series').get('title'); var seriesTitle = element.get('series').title;
var start = element.get('airDateUtc'); var start = element.get('airDateUtc');
var statusLevel = _instance.getStatusLevel(element); var statusLevel = _instance.getStatusLevel(element);
var runtime = element.get('series').runtime;
var end = Moment(start).add('minutes', runtime);
element.set({ element.set({
title : seriesTitle, title : seriesTitle,
episodeTitle: episodeTitle, episodeTitle: episodeTitle,
start : start, start : start,
end : end,
allDay : false, allDay : false,
statusLevel : statusLevel statusLevel : statusLevel
}); });

View File

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

View File

@ -25,7 +25,9 @@ define(
}, },
_showDetails: function () { _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', 'marionette',
'Episode/Summary/Layout', 'Episode/Summary/Layout',
'Episode/Search/Layout' 'Episode/Search/Layout',
], function (Marionette, SummaryLayout, SearchLayout) { 'Series/SeriesCollection'
], function (Marionette, SummaryLayout, SearchLayout, SeriesCollection) {
return Marionette.Layout.extend({ return Marionette.Layout.extend({
template: 'Episode/LayoutTemplate', template: 'Episode/LayoutTemplate',
@ -30,6 +31,16 @@ define(
'click .x-episode-monitored': '_toggleMonitored' '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 () { onShow: function () {
this._showSummary(); this._showSummary();
this.searchLayout = new SearchLayout({ model: this.model }); 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> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3> <h3>
{{debug}}
<i class="icon-bookmark x-episode-monitored" title="Toggle monitored status" /> <i class="icon-bookmark x-episode-monitored" title="Toggle monitored status" />
{{#if episodeTitle}} {{#if episodeTitle}}
{{title}} - {{EpisodeNumber}} - {{episodeTitle}} {{title}} - {{EpisodeNumber}} - {{episodeTitle}}

View File

@ -50,6 +50,7 @@ define(
{ {
name : 'this', name : 'this',
label : 'Title', label : 'Title',
hideSeriesLink : true,
cell : EpisodeTitleCell, cell : EpisodeTitleCell,
sortable: false sortable: false
}, },
@ -74,10 +75,6 @@ define(
this.episodeCollection = options.episodeCollection.bySeason(this.model.get('seasonNumber')); 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.listenTo(this.model, 'sync', function () {
this._afterSeasonMonitored(); this._afterSeasonMonitored();
}, this); }, this);

View File

@ -8,17 +8,7 @@ define(
], function (Backbone, Moment, SeriesModel, EpisodeFileModel) { ], function (Backbone, Moment, SeriesModel, EpisodeFileModel) {
return Backbone.Model.extend({ 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) { parse: function (model) {
model.series = new SeriesModel(model.series);
if (model.episodeFile) { if (model.episodeFile) {
model.episodeFile = new EpisodeFileModel(model.episodeFile); model.episodeFile = new EpisodeFileModel(model.episodeFile);
@ -27,15 +17,6 @@ define(
return model; return model;
}, },
toJSON: function () {
var json = _.clone(this.attributes);
if (this.has('series')) {
json.series = this.get('series').toJSON();
}
return json;
},
defaults: { defaults: {
seasonNumber: 0, seasonNumber: 0,
status : 0 status : 0

View File

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