##// END OF EJS Templates
my_account: change markup so permission list get perms.table style
Mads Kiilerich -
r3196:809fe2d3 beta
parent child Browse files
Show More
@@ -1,278 +1,280 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 5 ${_('My account')} ${c.rhodecode_user.username} - ${c.rhodecode_name}
6 6 </%def>
7 7
8 8 <%def name="breadcrumbs_links()">
9 9 ${_('My Account')}
10 10 </%def>
11 11
12 12 <%def name="page_nav()">
13 13 ${self.menu('admin')}
14 14 </%def>
15 15
16 16 <%def name="main()">
17 17
18 18 <div class="box box-left">
19 19 <!-- box / title -->
20 20 <div class="title">
21 21 ${self.breadcrumbs()}
22 22 </div>
23 23 <!-- end box / title -->
24 24 ${c.form|n}
25 25 </div>
26 26
27 27 <div class="box box-right">
28 28 <!-- box / title -->
29 29 <div class="title">
30 30 <h5>
31 31 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/>
32 32 </h5>
33 33 <ul class="links" style="color:#DADADA">
34 34 <li>
35 35 <span><a id="show_perms" class="link-white current" href="#perms">${_('My permissions')}</a> </span>
36 36 </li>
37 37 <li>
38 38 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
39 39 </li>
40 40 <li>
41 41 <span><a id="show_pullrequests" class="link-white" href="#pullrequests">${_('My pull requests')}</a> </span>
42 42 </li>
43 43 %if h.HasPermissionAny('hg.admin','hg.create.repository')():
44 44 <li>
45 45 <span>${h.link_to(_('Add repo'),h.url('admin_settings_create_repository'))}</span>
46 46 </li>
47 47 %endif
48 48 </ul>
49 49 </div>
50 50 <!-- end box / title -->
51 <div id="perms_container" class="table">
51 <div id="perms_container">
52 <div id="perms" class="table">
52 53 %for section in sorted(c.rhodecode_user.permissions.keys()):
53 54 <div class="perms_section_head">${section.replace("_"," ").capitalize()}</div>
54 55
55 56 <div id='tbl_list_wrap_${section}' class="yui-skin-sam">
56 57 <table id="tbl_list_${section}">
57 58 <thead>
58 59 <tr>
59 60 <th class="left">${_('Name')}</th>
60 61 <th class="left">${_('Permission')}</th>
61 62 </thead>
62 63 <tbody>
63 64 %for k in c.rhodecode_user.permissions[section]:
64 65 <%
65 66 if section != 'global':
66 67 section_perm = c.rhodecode_user.permissions[section].get(k)
67 68 _perm = section_perm.split('.')[-1]
68 69 else:
69 70 _perm = section_perm = None
70 71 %>
71 72 %if _perm not in ['none']:
72 73 <tr>
73 74 <td>
74 75 %if section == 'repositories':
75 76 <a href="${h.url('summary_home',repo_name=k)}">${k}</a>
76 77 %elif section == 'repositories_groups':
77 78 <a href="${h.url('repos_group_home',group_name=k)}">${k}</a>
78 79 %else:
79 80 ${k}
80 81 %endif
81 82 </td>
82 83 <td>
83 84 %if section == 'global':
84 85 ${h.bool2icon(True)}
85 86 %else:
86 87 <span class="perm_tag ${_perm}">${section_perm}</span>
87 88 %endif
88 89 </td>
89 90 </tr>
90 91 %endif
91 92 %endfor
92 93 </tbody>
93 94 </table>
94 95 </div>
95 96 %endfor
96 97 </div>
98 </div>
97 99 <div id="my_container" style="display:none">
98 100 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
99 101 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
100 102 </div>
101 103 <div id="pullrequests_container" class="table" style="display:none">
102 104 ## loaded via AJAX
103 105 ${_('Loading...')}
104 106 </div>
105 107 </div>
106 108
107 109 <script type="text/javascript">
108 110
109 111 var show_perms = function(e){
110 112 YUD.addClass('show_perms', 'current');
111 113 YUD.removeClass('show_my','current');
112 114 YUD.removeClass('show_pullrequests','current');
113 115
114 116 YUD.setStyle('my_container','display','none');
115 117 YUD.setStyle('pullrequests_container','display','none');
116 118 YUD.setStyle('perms_container','display','');
117 119 YUD.setStyle('q_filter','display','none');
118 120 }
119 121 YUE.on('show_perms','click',function(e){
120 122 show_perms();
121 123 })
122 124
123 125 var show_my = function(e){
124 126 YUD.addClass('show_my', 'current');
125 127 YUD.removeClass('show_perms','current');
126 128 YUD.removeClass('show_pullrequests','current');
127 129
128 130 YUD.setStyle('perms_container','display','none');
129 131 YUD.setStyle('pullrequests_container','display','none');
130 132 YUD.setStyle('my_container','display','');
131 133 YUD.setStyle('q_filter','display','');
132 134 if(!YUD.hasClass('show_my', 'loaded')){
133 135 table_renderer(${c.data |n});
134 136 YUD.addClass('show_my', 'loaded');
135 137 }
136 138 }
137 139 YUE.on('show_my','click',function(e){
138 140 show_my(e);
139 141 })
140 142
141 143 var show_pullrequests = function(e){
142 144 YUD.addClass('show_pullrequests', 'current');
143 145 YUD.removeClass('show_my','current');
144 146 YUD.removeClass('show_perms','current');
145 147
146 148 YUD.setStyle('my_container','display','none');
147 149 YUD.setStyle('perms_container','display','none');
148 150 YUD.setStyle('pullrequests_container','display','');
149 151 YUD.setStyle('q_filter','display','none');
150 152
151 153 var url = "${h.url('admin_settings_my_pullrequests')}";
152 154 ypjax(url, 'pullrequests_container');
153 155 }
154 156 YUE.on('show_pullrequests','click',function(e){
155 157 show_pullrequests(e)
156 158 })
157 159
158 160 var tabs = {
159 161 'perms': show_perms,
160 162 'my': show_my,
161 163 'pullrequests': show_pullrequests
162 164 }
163 165 var url = location.href.split('#');
164 166 if (url[1]) {
165 167 //We have a hash
166 168 var tabHash = url[1];
167 169 var func = tabs[tabHash]
168 170 if (func){
169 171 func();
170 172 }
171 173 }
172 174
173 175 function table_renderer(data){
174 176 var myDataSource = new YAHOO.util.DataSource(data);
175 177 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
176 178
177 179 myDataSource.responseSchema = {
178 180 resultsList: "records",
179 181 fields: [
180 182 {key:"menu"},
181 183 {key:"raw_name"},
182 184 {key:"name"},
183 185 {key:"last_changeset"},
184 186 {key:"action"},
185 187 ]
186 188 };
187 189 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
188 190 // This is the filter function
189 191 var data = res.results || [],
190 192 filtered = [],
191 193 i,l;
192 194
193 195 if (req) {
194 196 req = req.toLowerCase();
195 197 for (i = 0; i<data.length; i++) {
196 198 var pos = data[i].raw_name.toLowerCase().indexOf(req)
197 199 if (pos != -1) {
198 200 filtered.push(data[i]);
199 201 }
200 202 }
201 203 res.results = filtered;
202 204 }
203 205 return res;
204 206 }
205 207
206 208 // main table sorting
207 209 var myColumnDefs = [
208 210 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
209 211 {key:"name",label:"${_('Name')}",sortable:true,
210 212 sortOptions: { sortFunction: nameSort }},
211 213 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
212 214 sortOptions: { sortFunction: revisionSort }},
213 215 {key:"action",label:"${_('Action')}",sortable:false},
214 216 ];
215 217
216 218 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
217 219 sortedBy:{key:"name",dir:"asc"},
218 220 paginator: new YAHOO.widget.Paginator({
219 221 rowsPerPage: 50,
220 222 alwaysVisible: false,
221 223 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}",
222 224 pageLinks: 5,
223 225 containerClass: 'pagination-wh',
224 226 currentPageClass: 'pager_curpage',
225 227 pageLinkClass: 'pager_link',
226 228 nextPageLinkLabel: '&gt;',
227 229 previousPageLinkLabel: '&lt;',
228 230 firstPageLinkLabel: '&lt;&lt;',
229 231 lastPageLinkLabel: '&gt;&gt;',
230 232 containers:['user-paginator']
231 233 }),
232 234
233 235 MSG_SORTASC:"${_('Click to sort ascending')}",
234 236 MSG_SORTDESC:"${_('Click to sort descending')}",
235 237 MSG_EMPTY:"${_('No records found.')}",
236 238 MSG_ERROR:"${_('Data error.')}",
237 239 MSG_LOADING:"${_('Loading...')}",
238 240 }
239 241 );
240 242 myDataTable.subscribe('postRenderEvent',function(oArgs) {
241 243 tooltip_activate();
242 244 quick_repo_menu();
243 245 });
244 246
245 247 var filterTimeout = null;
246 248
247 249 updateFilter = function() {
248 250 // Reset timeout
249 251 filterTimeout = null;
250 252
251 253 // Reset sort
252 254 var state = myDataTable.getState();
253 255 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
254 256
255 257 // Get filtered data
256 258 myDataSource.sendRequest(YUD.get('q_filter').value,{
257 259 success : myDataTable.onDataReturnInitializeTable,
258 260 failure : myDataTable.onDataReturnInitializeTable,
259 261 scope : myDataTable,
260 262 argument: state
261 263 });
262 264
263 265 };
264 266 YUE.on('q_filter','click',function(){
265 267 if(!YUD.hasClass('q_filter', 'loaded')){
266 268 YUD.get('q_filter').value = '';
267 269 //TODO: load here full list later to do search within groups
268 270 YUD.addClass('q_filter', 'loaded');
269 271 }
270 272 });
271 273
272 274 YUE.on('q_filter','keyup',function (e) {
273 275 clearTimeout(filterTimeout);
274 276 filterTimeout = setTimeout(updateFilter,600);
275 277 });
276 278 }
277 279 </script>
278 280 </%def>
General Comments 0
You need to be logged in to leave comments. Login now