forked from RallyApps/getting-started
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.js
70 lines (65 loc) · 2.01 KB
/
App.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
70
/**
* This example uses stores to read items from WSAPI
*/
Ext.define('Rally.gettingstarted.DataStores', {
extend: 'Rally.app.App',
/**
* The app execution entry point
*/
launch: function() {
this._loadStories();
},
/**
* Create a store to load unaccepted stories that
* have at least one defect associated to it. The data should be loaded
* using the current project scoping. Call _onStoriesLoaded on successful load.
*/
_loadStories: function() {
Ext.create('Rally.data.wsapi.Store', {
model: 'UserStory',
context: this.getContext().getDataContext(),
filters: [
{
property: 'ScheduleState',
operator: '<',
value: 'Accepted'
},
{
property: 'Defects.ObjectID',
operator: '!=',
value: null
}
],
autoLoad: true,
listeners: {
load: this._onStoriesLoaded,
scope: this
},
fetch: ['Defects']
});
},
/**
* Load the defects collection of the first story in the result store.
* Call _onDefectsLoaded when complete.
*/
_onStoriesLoaded: function(store, records, success) {
if(success && store.getCount() > 0) {
var story = records[0],
defectsStore = story.getCollection('Defects', {
fetch: ['FormattedID', 'Name'],
});
defectsStore.load({
callback: this._onDefectsLoaded,
scope: this
});
}
},
/**
* Print the associated defects to the console in FormattedID: Name format.
*/
_onDefectsLoaded: function(records, operation, success) {
_.each(records, function(defect) {
console.log(defect.get('FormattedID') + ':', defect.get('Name'));
});
}
});