2013-06-09 23:51:32 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
define(['app'], function () {
|
|
|
|
NzbDrone.Cells.NzbDroneCell = Backgrid.Cell.extend({
|
|
|
|
|
|
|
|
_originalInit: Backgrid.Cell.prototype.initialize,
|
|
|
|
|
|
|
|
|
|
|
|
initialize: function () {
|
|
|
|
this._originalInit.apply(this, arguments);
|
|
|
|
this.cellValue = this._getValue();
|
|
|
|
|
|
|
|
this.model.on('change', this._refresh, this);
|
|
|
|
},
|
|
|
|
|
|
|
|
_refresh: function () {
|
|
|
|
this.cellValue = this._getValue();
|
|
|
|
this.render();
|
|
|
|
},
|
|
|
|
|
|
|
|
_getValue: function () {
|
|
|
|
|
|
|
|
var name = this.column.get('name');
|
|
|
|
|
|
|
|
if(name === 'this'){
|
|
|
|
return this.model;
|
|
|
|
}
|
|
|
|
|
|
|
|
var value = this.model.get(name);
|
|
|
|
|
2013-06-10 05:10:15 +03:00
|
|
|
if(!value){
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2013-06-09 23:51:32 +03:00
|
|
|
//if not a model
|
|
|
|
if (!value.get) {
|
2013-06-10 05:10:15 +03:00
|
|
|
value = new Backbone.Model(value);
|
2013-06-09 23:51:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|