2013-06-22 06:24:24 +00:00
|
|
|
'use strict';
|
2013-06-09 20:51:32 +00:00
|
|
|
|
2013-06-14 23:18:37 +00:00
|
|
|
define(['app','backgrid'], function () {
|
2013-06-09 20:51:32 +00:00
|
|
|
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({
|
|
|
|
|
|
|
|
_originalInit: Backgrid.Cell.prototype.initialize,
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this._originalInit.apply(this, arguments);
|
|
|
|
this.cellValue = this._getValue();
|
|
|
|
|
2013-06-19 01:02:23 +00:00
|
|
|
this.listenTo(this.model, 'change', this._refresh);
|
2013-06-09 20:51:32 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_refresh: function () {
|
|
|
|
this.cellValue = this._getValue();
|
|
|
|
this.render();
|
|
|
|
},
|
|
|
|
|
|
|
|
_getValue: function () {
|
|
|
|
|
|
|
|
var name = this.column.get('name');
|
|
|
|
|
2013-06-11 01:55:05 +00:00
|
|
|
if (name === 'this') {
|
2013-06-09 20:51:32 +00:00
|
|
|
return this.model;
|
|
|
|
}
|
|
|
|
|
|
|
|
var value = this.model.get(name);
|
|
|
|
|
2013-06-11 01:55:05 +00:00
|
|
|
if (!value) {
|
2013-06-10 02:10:15 +00:00
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2013-06-09 20:51:32 +00:00
|
|
|
//if not a model
|
2013-06-11 01:55:05 +00:00
|
|
|
if (!value.get && typeof value === 'object') {
|
2013-06-10 02:10:15 +00:00
|
|
|
value = new Backbone.Model(value);
|
2013-06-09 20:51:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|