forked from RallyApps/PortfolioKanban
-
Notifications
You must be signed in to change notification settings - Fork 1
/
PortfolioKanbanCard.js
96 lines (73 loc) · 2.85 KB
/
PortfolioKanbanCard.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
(function () {
var Ext = window.Ext4 || window.Ext;
/**
* A special cardboard card for use by the PortfolioKanbanApp
*/
Ext.define('Rally.app.portfolioitem.PortfolioKanbanCard', {
extend:'Rally.ui.cardboard.ArtifactCard',
alias:'widget.rallyportfoliokanbancard',
inheritableStatics:{
getAdditionalFetchFields:function () {
return ['Owner', 'FormattedID', 'PercentDoneByStoryCount', 'StateChangedDate',
'DirectChildrenCount', 'Children', 'PortfolioItemType', 'UserStories',
'ScheduleState', 'Parent'];
}
},
_hasReadyField:function () {
return false;
},
_hasBlockedField:function () {
return false;
},
buildContent:function () {
var cardBody = Ext.widget('container', {
cls:'cardContent'
});
cardBody.add({
xtype: 'rallyfieldrenderer',
field: this.getRecord().getField('_refObjectName'),
record: this.getRecord()
});
cardBody.add({
xtype: 'rallyfieldrenderer',
cls: 'cardParent',
field: this.getRecord().getField('Parent'),
record: this.getRecord()
});
var percentDoneByStoryCount = this.getRecord().get('PercentDoneByStoryCount');
if (percentDoneByStoryCount > 0) {
var percentDoneField = Ext.widget('rallyfieldrenderer', {
field:this.getRecord().getField('PercentDoneByStoryCount'),
record:this.getRecord()
});
cardBody.add(percentDoneField);
}
cardBody.add({
xtype: 'relateditemssummarizer',
field:this.getRecord().getField('Children'),
record: this.getRecord()
});
var stateChangedDate = this.getRecord().get('StateChangedDate');
var timeInState = Math.floor((((new Date().getTime()) - stateChangedDate.getTime()) / (1000 * 60 * 60 * 24)));
var timeInStateStr;
if (timeInState === 1) {
timeInStateStr = timeInState + ' day';
} else if (timeInState < 21) {
timeInStateStr = timeInState + ' days';
} else {
timeInStateStr = Math.floor(timeInState / 7) + " weeks";
}
if (timeInState > 0) {
cardBody.add({
xtype:'component',
cls:'timeInState',
renderTpl:'{timeInState} in this column',
renderData:{
timeInState:timeInStateStr
}
});
}
return cardBody;
}
});
}());