forked from RallyApps/app-catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BlockedWorkView.js
124 lines (109 loc) · 4.62 KB
/
BlockedWorkView.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
121
122
123
124
(function() {
var Ext = window.Ext4 || window.Ext;
Ext.define('Rally.apps.blockedwork.BlockedWorkView', {
extend: 'Ext.view.View',
alias: 'widget.rallyblockedworkview',
requires: [
'Rally.nav.DetailLink',
'Rally.util.User'
],
mixins: {
userToolTip: 'Rally.ui.view.UserToolTip',
showMore: 'Rally.ui.view.ShowMore'
},
showMoreCount: 10,
profileImageSize: 50,
itemSelector : 'ul:first > li.list-item',
constructor: function(config) {
config = Ext.apply({
tpl: new Ext.XTemplate(
'<tpl if="values.length > 0">',
' <ul class="list">',
'</tpl>',
'<tpl for=".">',
' <li class="list-item {liCls}">',
' <div class="artifact-detail">',
' {detailLink}',
' <span class="name">{artifactName}</span>',
' </div>',
' <div class="list-item-info">',
' <div class="list-item-user">',
' <img src="{image_URL}" style="width: {profileImageSize}px; height: {profileImageSize}px;" class="profile"/>',
' </div>',
' <div class="list-item-details">',
' <div class="status">',
' <a class="profileLink" href="#"><span class="{userCls}">{userName}</span></a> {blockedTime}',
' </div>',
' <div class="detail-text">',
' {blockedReason}',
' </div>',
' </div>',
' </div>',
' </li>',
'</tpl>',
'<tpl if="values.length > 0">',
' </ul><span class="clear" />',
'</tpl>'
)
}, config);
this.callParent([config]);
},
initComponent: function() {
this.addEvents(
/**
* @event
* Fires when the component is fully initialized
* @param {Rally.ui.discussion.InlineDiscussionReplyEditor} this
*/
'ready'
);
if(!this.store) {
this.store = this._createStore();
}
this.callParent(arguments);
this.on('refresh', this._onRefresh, this);
this.store.on('load', function() {
this.fireEvent('ready', this);
if (Rally.BrowserTest) {
Rally.BrowserTest.publishComponentReady(this);
}
}, this);
},
_createStore: function() {
return Ext.create('Rally.data.wsapi.Store', Ext.apply({
limit: this.showMoreCount,
pageSize: this.showMoreCount,
autoLoad: true,
requester: this,
model: Ext.identityFn('Blocker'),
fetch: ['WorkProduct','Project','Name','FormattedID','CreationDate','BlockedBy','BlockedReason','Disabled','ObjectID'],
sorters: {
property: 'CreationDate',
direction: 'DESC'
}
}, this.storeConfig));
},
prepareData: function(data, recordIndex, record) {
var artifact = record.data.WorkProduct,
user = record.data.BlockedBy;
data.profileImageSize = this.profileImageSize;
data.liCls = record.index === 0 ? 'first' : '';
data.artifactName = artifact.Name;
data.detailLink = Rally.nav.DetailLink.getLink({
record: artifact,
text: artifact.FormattedID
});
data.blockedTime = record.data._CreatedAt;
data.userName = user._refObjectName;
data.user_URL = Rally.nav.Manager.getDetailUrl(user._ref);
data.image_URL = Rally.util.User.getProfileImageUrl(this.profileImageSize, user._ref);
data.blockedReason = artifact.BlockedReason !== null ? artifact.BlockedReason : " ";
data.userCls = user.Disabled ? 'inactive' : '';
return data;
},
_onRefresh: function() {
this.buildUserTooltips('BlockedBy');
this.addShowMoreLink(this.showMoreCount);
}
});
})();