This repository was archived by the owner on Oct 3, 2025. It is now read-only.
forked from klegro/AnalyticsSnapshotGridApp
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathApp.js
More file actions
179 lines (157 loc) · 5.06 KB
/
App.js
File metadata and controls
179 lines (157 loc) · 5.06 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
Ext.define('CustomApp', {
extend: 'Rally.app.App',
componentCls: 'app',
layout: {
type: 'vbox',
align: 'stretch'
},
items:[
{
xtype: 'component',
itemId: 'titleDate',
html: '<h1>Current Date: '+ Rally.util.DateTime.format(new Date(), "m/d/Y T(P)") +'</h1>',
style: 'text-align:center; font-size: 24px; margin: 10px 10px; color:#333333'
},
{
xtype: 'container',
layout: 'auto',
style: 'text-align:center',
border: false,
height: 60,
style: 'margin-left: 80px',
defaults: {
style: 'float:left; margin: 5px 5px'
},
defaultType: 'rallydatefield',
items: [
{
itemId: 'startDateField',
width: 100,
value: Rally.util.DateTime.add(new Date(), "day", -10)
},
{
xtype: 'container',
itemId: 'sliderHolder',
layout: 'fit',
width: 500
},
{
itemId: 'endDateField',
width: 100,
value: new Date()
},
{
xtype: 'rallybutton',
itemId: 'playButton',
text: 'Play'
}
]
},
{
xtype: 'container',
itemId: 'cardboardHolder'
}
],
launch: function() {
var startDate = this.getStartDate();
var endDate = this.down('#endDateField').getValue();
this.currentDate = endDate;
var startDateField = this.down('#startDateField');
startDateField.on('blur', this.onStartDateChange, this);
startDateField.on('select', this.onStartDateChange, this);
var endDateField = this.down('#endDateField');
endDateField.on('blur', this.onEndDateChange, this);
endDateField.on('select', this.onEndDateChange, this);
this.down('#playButton').on('click', this.playClicked, this);
this.noDays = Rally.util.DateTime.getDifference(endDate, startDate, 'day');
var app = this;
this.down('#sliderHolder').add({
xtype: 'slider',
itemId: 'dateSlider',
hideLabel: true,
width: 700,
increment: 1,
minValue: 0,
maxValue: this.noDays,
value: this.noDays,
tipText: function(thumb){
var tickerDate = Rally.util.DateTime.add(app.getStartDate(), "day", thumb.value);
return Ext.String.format('<b>{0}</b>', Rally.util.DateTime.format(tickerDate, "m/d/Y"));
},
listeners: {
'changecomplete': this.onDateChanged,
scope: this
}
});
this.down('#cardboardHolder').add({
xtype: 'historicalcardboard',
itemId: 'cardboard',
types: ['HierarchicalRequirement', 'Defect'],
attribute: 'KanbanState',
viewDate: 'current',
columnConfig: {
appContext : this.context
},
columns: [ { value: "Initial AC" }, { value: "Ranked" }, { value: "In Dev" }, { value: "In Test" }, { value: "Accepted" }, { value: "Merged" } ]
});
},
playClicked: function(){
if(this.playTimer){
clearTimeout(this.playTimer);
delete this.playTimer;
}
else{
var boundNextTick = Ext.bind(this.nextTick, this);
// reset the slider to 0
this.down('#dateSlider').setValue(0);
this.playTimer = setTimeout(boundNextTick, 6000);
}
},
nextTick: function(){
var boundNextTick = Ext.bind(this.nextTick, this);
var current = this.down('#dateSlider').getValue();
var nextVal = current +1;
if(nextVal <= this.noDays){
this.down('#dateSlider').setValue(nextVal);
this.playTimer = setTimeout(boundNextTick, 6000);
}else{
delete this.playTimer;
}
},
onStartDateChange: function(){
var newStart = this.getStartDate();
var newEnd = Rally.util.DateTime.add(newStart, "day", 10);
this.down('#endDateField').setValue(newEnd);
this.down('#dateSlider').setValue(0);
},
onEndDateChange: function(){
var newEnd = this.getEndDate();
var newStart = Rally.util.DateTime.add(newEnd, "day", -10);
this.down('#startDateField').setValue(newStart);
this.down('#dateSlider').setValue(this.noDays);
},
getStartDate: function(){
return this.down('#startDateField').getValue();
},
getEndDate: function(){
return this.down('#endDateField').getValue();
},
setCurrentDate: function(newDate){
this.currentDate = newDate;
this.setTitleDate(newDate);
this.down('#cardboard').updateViewDate(newDate);
},
setTitleDate: function(date){
var title = '<h1>Current Date: '+ Rally.util.DateTime.format(date, "m/d/Y T(P)") +'</h1>';
this.down('#titleDate').update(title);
},
getDateSliderValue: function(){
var tickCount = this.down('#dateSlider').getValue();
var date = Rally.util.DateTime.add(this.getStartDate(), "day", tickCount);
return date;
},
onDateChanged: function(slider, newTickCount){
var newDate = this.getDateSliderValue();
this.setCurrentDate(newDate);
}
});