1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-15 07:22:35 +01:00
Radarr/UI/Cells/NzbDroneCell.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2013-06-22 08:24:24 +02:00
'use strict';
define(
[
'backgrid'
], function (Backgrid) {
return Backgrid.Cell.extend({
_originalInit: Backgrid.Cell.prototype.initialize,
initialize: function () {
this._originalInit.apply(this, arguments);
this.cellValue = this._getValue();
this.listenTo(this.model, 'change', this._refresh);
},
_refresh: function () {
this.cellValue = this._getValue();
this.render();
},
_getValue: function () {
2013-07-18 04:09:34 +02:00
var cellValue = this.column.get('cellValue');
if (cellValue) {
if (cellValue === 'this') {
return this.model;
}
}
var name = this.column.get('name');
if (name === 'this') {
return this.model;
}
var value = this.model.get(name);
if (!value) {
return undefined;
}
2013-06-10 04:10:15 +02:00
//if not a model
if (!value.get && typeof value === 'object') {
value = new Backbone.Model(value);
}
return value;
}
});
});