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