forked from RallyCommunity/RallyTreeGrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRallyTreeDataStore.js
120 lines (87 loc) · 2.88 KB
/
RallyTreeDataStore.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
(function (global) {
var totalProcessed = 0;
Ext.define("Rally.data.WsapiTreeStore", {
extend: "Ext.data.TreeStore",
topLevelModels: ["HierarchicalRequirement"],
childModels: ["HierarchicalRequirement", "Task"],
pageSize: 25,
totalProcessed: 0,
totalCount: 0,
currentPage: 1,
filterFn: function defaultFilterFn() { return true; },
constructor: function wsapi_tree_store_ctor(config) {
var me = this,
trmConfig = {};
Ext.apply(me, config);
me.callParent([config]);
//console.log("WsapiTreeStore Root Artifacts", me.topLevelModels);
me.setRootNode(Ext.create("Rally.data.TreeRootModel", {
topLevelModels: me.topLevelModels,
leaf: false
}));
//me.proxy = Ext.create("Rally.data.WsapiTreeProxy", {
//topLevelModels: me.topLevelModels,
//childModels: me.childModels
//});
},
onProxyLoad: function(operation) {
var me = this;
if (operation.success && !operation.node.parentNode) {
me.totalProcessed = me.totalProcessed + operation.resultSet.length;
me.totalCount = operation.totalResultCount;
}
me.callParent(arguments);
},
load: function load(options) {
var me = this,
ocb = options.callback;
options.wsapi = {
page: me.currentPage,
start: (me.currentPage - 1) * me.pageSize,
limit: me.pageSize,
isPaging: true,
query: me.query
};
//console.log("Tree Store Load Options");
//console.dir(options);
//console.log("Is Node Loaded?", options.node.isLoaded());
options.callback = function updateTotals(nodes, ops, success) {
//console.log("Tree Loaded", totalProcessed, arguments);
if (ocb) {
Ext.callback(ocb, options.scope || me, arguments);
}
};
me.setProxy(Ext.create("Rally.data.WsapiTreeProxy", {
model: options.node,
topLevelModels: me.topLevelModels,
childModels: me.childModels,
isRoot: me.getRootNode().modelName === options.node.modelName,
canExpandFn: me.canExpandFn,
filterFn: me.filterFn,
wsapiStoreOptions: options.wsapi
}));
me.callParent([options]);
},
getCount: function getCount() {
return this.totalProcessed || 0;
},
getTotalCount: function getTotalCount() {
return this.totalCount || 0;
},
loadPage: function loadPage(num, options) {
this.currentPage = num;
options = options || {};
options.node = this.getRootNode();
this.load(options);
},
nextPage: function nextPage(options) {
this.loadPage(this.currentPage + 1, options);
},
previousPage: function previousPage(options) {
this.loadPage(this.currentPage - 1, options);
},
getPageSize: function getPageSize() {
return this.pageSize;
}
});
}(this));