forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintTaskCardsApp.js
69 lines (63 loc) · 2.21 KB
/
PrintTaskCardsApp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
(function() {
var Ext = window.Ext4 || window.Ext;
Ext.define('Rally.apps.printcards.printtaskcards.PrintTaskCardsApp', {
extend: 'Rally.app.TimeboxScopedApp',
alias: 'widget.printtaskcards',
requires: [
'Rally.apps.printcards.PrintCard',
'Rally.app.plugin.Print'
],
plugins: [{
ptype: 'rallyappprinting'
}],
helpId: 242,
componentCls: 'printcards',
scopeType: 'iteration',
autoScroll: false,
launch: function() {
this.add({
xtype: 'container',
itemId: 'cards'
});
this.callParent(arguments);
},
onScopeChange: function(scope) {
this.down('#cards').getEl().setHTML('');
this._loadTasks(scope);
},
_loadTasks: function(scope) {
Ext.create('Rally.data.wsapi.Store', {
context: this.getContext().getDataContext(),
model: Ext.identityFn('Task'),
autoLoad: true,
fetch: ['FormattedID', 'Name', 'Owner', 'Description', 'Estimate', 'WorkProduct'],
limit: (scope.getRecord()) ? 200 : 50,
listeners: {
load: this._onTasksLoaded,
scope: this
},
filters: [
scope.getQueryFilter()
]
});
},
_onTasksLoaded: function(store, records) {
var printCardHtml = '';
_.each(records, function(record, idx) {
printCardHtml += Ext.create('Rally.apps.printcards.PrintCard').tpl.apply(record.data);
if (idx%4 === 3) {
printCardHtml += '<div class="pb"></div>';
}
}, this);
Ext.DomHelper.insertHtml('beforeEnd', this.down('#cards').getEl().dom, printCardHtml);
if(Rally.BrowserTest) {
Rally.BrowserTest.publishComponentReady(this);
}
},
getOptions: function() {
return [
this.getPrintMenuOption({title: 'Print Task Cards App'}) //from printable mixin
];
}
});
})();