1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-27 02:09:59 +00:00

EpisodeModel will include mutators in toJson

This commit is contained in:
Mark McDowall 2013-06-09 22:27:20 -07:00
parent 30d85d425d
commit e1de291f8c
2 changed files with 15 additions and 4 deletions

View file

@ -10,14 +10,14 @@ define(['app', 'Cells/NzbDroneCell'], function () {
this.$el.empty(); this.$el.empty();
var airDateField = this.column.get('airDate') || 'airDate'; var airDateField = this.column.get('airDate') || 'airDate';
var seasonFiled = this.column.get('seasonNumber') || 'seasonNumber'; var seasonField = this.column.get('seasonNumber') || 'seasonNumber';
var episodeFiled = this.column.get('episodes') || 'episodeNumber'; var episodeField = this.column.get('episodes') || 'episodeNumber';
if (this.cellValue) { if (this.cellValue) {
var airDate = this.cellValue.get(airDateField); var airDate = this.cellValue.get(airDateField);
var seasonNumber = this.cellValue.get(seasonFiled); var seasonNumber = this.cellValue.get(seasonField);
var episodes = this.cellValue.get(episodeFiled); var episodes = this.cellValue.get(episodeField);
var result = 'Unknown'; var result = 'Unknown';

View file

@ -4,6 +4,7 @@ define(['app', 'Series/SeriesModel'], function () {
mutators: { mutators: {
paddedEpisodeNumber: function () { paddedEpisodeNumber: function () {
var test = this.get('episodeNumber');
return this.get('episodeNumber').pad(2); return this.get('episodeNumber').pad(2);
}, },
day : function () { day : function () {
@ -64,6 +65,16 @@ define(['app', 'Series/SeriesModel'], function () {
toJSON: function () { toJSON: function () {
var json = _.clone(this.attributes); var json = _.clone(this.attributes);
_.each(this.mutators, _.bind(function (mutator, name) {
// check if we have some getter mutations
if (_.isObject(this.mutators[name]) === true && _.isFunction(this.mutators[name].get)) {
json[name] = _.bind(this.mutators[name].get, this)();
} else {
json[name] = _.bind(this.mutators[name], this)();
}
}, this));
json.series = this.get('series').toJSON(); json.series = this.get('series').toJSON();
return json; return json;