2013-06-21 23:24:24 -07:00
|
|
|
'use strict';
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
define(
|
|
|
|
[
|
|
|
|
'backgrid'
|
|
|
|
], function (Backgrid) {
|
|
|
|
return Backgrid.Cell.extend({
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
className: 'download-report-cell',
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
events: {
|
|
|
|
'click': '_onClick'
|
|
|
|
},
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
_onClick: function () {
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-09-21 00:45:45 -07:00
|
|
|
if (!this.model.get('downloadAllowed'))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
var self = this;
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-07-16 23:41:40 -07:00
|
|
|
this.$el.html('<i class="icon-spinner icon-spin" />');
|
|
|
|
|
2013-11-11 18:00:20 -08:00
|
|
|
//Using success callback instead of promise so it
|
|
|
|
//gets called before the sync event is triggered
|
|
|
|
this.model.save(null, { success: function () {
|
|
|
|
self.model.set('queued', true);
|
|
|
|
}});
|
2013-06-24 16:41:59 -07:00
|
|
|
},
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-06-24 16:41:59 -07:00
|
|
|
render: function () {
|
2013-09-18 22:49:15 -07:00
|
|
|
this.$el.empty();
|
2013-06-09 13:51:32 -07:00
|
|
|
|
2013-11-11 18:00:20 -08:00
|
|
|
if (this.model.get('queued')) {
|
|
|
|
this.$el.html('<i class="icon-nd-downloading" title="Added to downloaded queue" />');
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (this.model.get('downloadAllowed'))
|
2013-09-18 12:15:34 -07:00
|
|
|
{
|
|
|
|
this.$el.html('<i class="icon-download-alt" title="Add to download queue" />');
|
|
|
|
}
|
2013-06-14 16:18:37 -07:00
|
|
|
|
2013-09-21 00:45:45 -07:00
|
|
|
else {
|
|
|
|
this.className = 'no-download-report-cell';
|
|
|
|
}
|
|
|
|
|
2013-09-18 12:15:34 -07:00
|
|
|
return this;
|
2013-06-24 16:41:59 -07:00
|
|
|
}
|
|
|
|
});
|
2013-06-14 16:18:37 -07:00
|
|
|
});
|