lidarr/src/UI/Calendar/UpcomingItemView.js
Mark McDowall 9142d1b188 Option to prevent backbone from adding new models to a collection (update only)
Prevents upcoming/calendar from blowing up when
2013-11-30 11:40:44 -08:00

33 lines
937 B
JavaScript

'use strict';
define(
[
'vent',
'marionette',
'moment'
], function (vent, Marionette, Moment) {
return Marionette.ItemView.extend({
template: 'Calendar/UpcomingItemViewTemplate',
tagName : 'div',
events: {
'click .x-episode-title': '_showEpisodeDetails'
},
initialize: function () {
var start = this.model.get('airDateUtc');
var runtime = this.model.get('series').runtime;
var end = Moment(start).add('minutes', runtime);
this.model.set({
end: end.toISOString()
});
this.listenTo(this.model, 'change', this.render);
},
_showEpisodeDetails: function () {
vent.trigger(vent.Commands.ShowEpisodeDetails, {episode: this.model});
}
});
});