1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-16 11:37:58 +02:00
Sonarr/UI/Cells/NzbDroneCell.js

63 lines
1.7 KiB
JavaScript
Raw Normal View History

2013-06-22 09:24:24 +03: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);
2013-08-21 18:24:09 +03:00
if (this._onEdit) {
this.listenTo(this.model, "backgrid:edit", function (model, column, cell, editor) {
if (column.get("name") == this.column.get("name")) {
this._onEdit(model, column, cell, editor);
}
});
}
},
_refresh: function () {
this.cellValue = this._getValue();
this.render();
},
_getValue: function () {
2013-07-18 05:09:34 +03: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 05:10:15 +03:00
//if not a model
if (!value.get && typeof value === 'object') {
value = new Backbone.Model(value);
}
return value;
}
});
});