##// END OF EJS Templates
fixes autocomplete on groups in non admin repository settings page
marcink -
r1455:9a7d0fbc beta
parent child Browse files
Show More
@@ -1,382 +1,197
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 5 ${_('Edit repository')} ${c.repo_info.repo_name} - ${c.rhodecode_name}
6 6 </%def>
7 7
8 8 <%def name="breadcrumbs_links()">
9 9 ${h.link_to(_('Admin'),h.url('admin_home'))}
10 10 &raquo;
11 11 ${h.link_to(_('Repositories'),h.url('repos'))}
12 12 &raquo;
13 13 ${_('edit')} &raquo; ${h.link_to(c.repo_info.just_name,h.url('summary_home',repo_name=c.repo_name))}
14 14 </%def>
15 15
16 16 <%def name="page_nav()">
17 17 ${self.menu('admin')}
18 18 </%def>
19 19
20 20 <%def name="main()">
21 21 <div class="box box-left">
22 22 <!-- box / title -->
23 23 <div class="title">
24 24 ${self.breadcrumbs()}
25 25 </div>
26 26 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')}
27 27 <div class="form">
28 28 <!-- fields -->
29 29 <div class="fields">
30 30 <div class="field">
31 31 <div class="label">
32 32 <label for="repo_name">${_('Name')}:</label>
33 33 </div>
34 34 <div class="input">
35 35 ${h.text('repo_name',class_="medium")}
36 36 </div>
37 37 </div>
38 38 <div class="field">
39 39 <div class="label">
40 40 <label for="clone_uri">${_('Clone uri')}:</label>
41 41 </div>
42 42 <div class="input">
43 43 ${h.text('clone_uri',class_="medium")}
44 44 </div>
45 45 </div>
46 46 <div class="field">
47 47 <div class="label">
48 48 <label for="repo_group">${_('Repository group')}:</label>
49 49 </div>
50 50 <div class="input">
51 51 ${h.select('repo_group','',c.repo_groups,class_="medium")}
52 52 </div>
53 53 </div>
54 54 <div class="field">
55 55 <div class="label">
56 56 <label for="repo_type">${_('Type')}:</label>
57 57 </div>
58 58 <div class="input">
59 59 ${h.select('repo_type','hg',c.backends,class_="medium")}
60 60 </div>
61 61 </div>
62 62 <div class="field">
63 63 <div class="label label-textarea">
64 64 <label for="description">${_('Description')}:</label>
65 65 </div>
66 66 <div class="textarea text-area editor">
67 67 ${h.textarea('description',cols=23,rows=5)}
68 68 </div>
69 69 </div>
70 70
71 71 <div class="field">
72 72 <div class="label label-checkbox">
73 73 <label for="private">${_('Private')}:</label>
74 74 </div>
75 75 <div class="checkboxes">
76 76 ${h.checkbox('private',value="True")}
77 77 </div>
78 78 </div>
79 79 <div class="field">
80 80 <div class="label label-checkbox">
81 81 <label for="enable_statistics">${_('Enable statistics')}:</label>
82 82 </div>
83 83 <div class="checkboxes">
84 84 ${h.checkbox('enable_statistics',value="True")}
85 85 </div>
86 86 </div>
87 87 <div class="field">
88 88 <div class="label label-checkbox">
89 89 <label for="enable_downloads">${_('Enable downloads')}:</label>
90 90 </div>
91 91 <div class="checkboxes">
92 92 ${h.checkbox('enable_downloads',value="True")}
93 93 </div>
94 94 </div>
95 95 <div class="field">
96 96 <div class="label">
97 97 <label for="user">${_('Owner')}:</label>
98 98 </div>
99 99 <div class="input input-small ac">
100 100 <div class="perm_ac">
101 101 ${h.text('user',class_='yui-ac-input')}
102 102 <div id="owner_container"></div>
103 103 </div>
104 104 </div>
105 105 </div>
106 106
107 107 <div class="field">
108 108 <div class="label">
109 109 <label for="input">${_('Permissions')}:</label>
110 110 </div>
111 111 <div class="input">
112 112 <%include file="repo_edit_perms.html"/>
113 113 </div>
114 114
115 115 <div class="buttons">
116 116 ${h.submit('save','Save',class_="ui-button")}
117 117 ${h.reset('reset','Reset',class_="ui-button")}
118 118 </div>
119 119 </div>
120 120 </div>
121 121 </div>
122 122 ${h.end_form()}
123 <script type="text/javascript">
124 YAHOO.util.Event.onDOMReady(function(){
125 var D = YAHOO.util.Dom;
126 if(!D.hasClass('perm_new_member_name','error')){
127 D.setStyle('add_perm_input','display','none');
128 }
129 YAHOO.util.Event.addListener('add_perm','click',function(){
130 D.setStyle('add_perm_input','display','');
131 D.setStyle('add_perm','opacity','0.6');
132 D.setStyle('add_perm','cursor','default');
133 });
134 });
135 </script>
136 <script type="text/javascript">
137 YAHOO.example.FnMultipleFields = function(){
138 var myUsers = ${c.users_array|n};
139 var myGroups = ${c.users_groups_array|n};
140
141 // Define a custom search function for the DataSource of users
142 var matchUsers = function(sQuery) {
143 // Case insensitive matching
144 var query = sQuery.toLowerCase();
145 var i=0;
146 var l=myUsers.length;
147 var matches = [];
148
149 // Match against each name of each contact
150 for(; i<l; i++) {
151 contact = myUsers[i];
152 if((contact.fname.toLowerCase().indexOf(query) > -1) ||
153 (contact.lname.toLowerCase().indexOf(query) > -1) ||
154 (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) {
155 matches[matches.length] = contact;
156 }
157 }
158 return matches;
159 };
160
161 // Define a custom search function for the DataSource of usersGroups
162 var matchGroups = function(sQuery) {
163 // Case insensitive matching
164 var query = sQuery.toLowerCase();
165 var i=0;
166 var l=myGroups.length;
167 var matches = [];
168
169 // Match against each name of each contact
170 for(; i<l; i++) {
171 matched_group = myGroups[i];
172 if(matched_group.grname.toLowerCase().indexOf(query) > -1) {
173 matches[matches.length] = matched_group;
174 }
175 }
176 return matches;
177 };
178
179 //match all
180 var matchAll = function(sQuery){
181 u = matchUsers(sQuery);
182 g = matchGroups(sQuery);
183 return u.concat(g);
184 };
185
186 // DataScheme for members
187 var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
188 memberDS.responseSchema = {
189 fields: ["id", "fname", "lname", "nname", "grname", "grmembers"]
190 };
191
192 // DataScheme for owner
193 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
194 ownerDS.responseSchema = {
195 fields: ["id", "fname", "lname", "nname"]
196 };
197
198 // Instantiate AutoComplete for perms
199 var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS);
200 membersAC.useShadow = false;
201 membersAC.resultTypeList = false;
202
203 // Instantiate AutoComplete for owner
204 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS);
205 ownerAC.useShadow = false;
206 ownerAC.resultTypeList = false;
207
208
209 // Helper highlight function for the formatter
210 var highlightMatch = function(full, snippet, matchindex) {
211 return full.substring(0, matchindex) +
212 "<span class='match'>" +
213 full.substr(matchindex, snippet.length) +
214 "</span>" +
215 full.substring(matchindex + snippet.length);
216 };
217
218 // Custom formatter to highlight the matching letters
219 var custom_formatter = function(oResultData, sQuery, sResultMatch) {
220 var query = sQuery.toLowerCase();
221
222 if (oResultData.grname != undefined){
223 var grname = oResultData.grname;
224 var grmembers = oResultData.grmembers;
225 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
226 var grprefix = "${_('Group')}: ";
227 var grsuffix = " ("+grmembers+" ${_('members')})";
228
229 if (grnameMatchIndex > -1){
230 return grprefix+highlightMatch(grname,query,grnameMatchIndex)+grsuffix;
231 }
232
233 return grprefix+oResultData.grname+grsuffix;
234 }
235 else if(oResultData.fname != undefined){
236
237 var fname = oResultData.fname,
238 lname = oResultData.lname,
239 nname = oResultData.nname || "", // Guard against null value
240 fnameMatchIndex = fname.toLowerCase().indexOf(query),
241 lnameMatchIndex = lname.toLowerCase().indexOf(query),
242 nnameMatchIndex = nname.toLowerCase().indexOf(query),
243 displayfname, displaylname, displaynname;
244
245 if(fnameMatchIndex > -1) {
246 displayfname = highlightMatch(fname, query, fnameMatchIndex);
247 }
248 else {
249 displayfname = fname;
250 }
251
252 if(lnameMatchIndex > -1) {
253 displaylname = highlightMatch(lname, query, lnameMatchIndex);
254 }
255 else {
256 displaylname = lname;
257 }
258
259 if(nnameMatchIndex > -1) {
260 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
261 }
262 else {
263 displaynname = nname ? "(" + nname + ")" : "";
264 }
265
266 return displayfname + " " + displaylname + " " + displaynname;
267 }
268 else{
269 return '';
270 }
271 };
272 membersAC.formatResult = custom_formatter;
273 ownerAC.formatResult = custom_formatter;
274
275 var myHandler = function(sType, aArgs) {
276
277 var myAC = aArgs[0]; // reference back to the AC instance
278 var elLI = aArgs[1]; // reference to the selected LI element
279 var oData = aArgs[2]; // object literal of selected item's result data
280
281 //fill the autocomplete with value
282 if(oData.nname != undefined){
283 //users
284 myAC.getInputEl().value = oData.nname;
285 YUD.get('perm_new_member_type').value = 'user';
286 }
287 else{
288 //groups
289 myAC.getInputEl().value = oData.grname;
290 YUD.get('perm_new_member_type').value = 'users_group';
291 }
292
293 };
294
295 membersAC.itemSelectEvent.subscribe(myHandler);
296 ownerAC.itemSelectEvent.subscribe(myHandler);
297
298 return {
299 memberDS: memberDS,
300 ownerDS: ownerDS,
301 membersAC: membersAC,
302 ownerAC: ownerAC,
303 };
304 }();
305
306 </script>
307
308 123 </div>
309 124
310 125 <div class="box box-right">
311 126 <div class="title">
312 127 <h5>${_('Administration')}</h5>
313 128 </div>
314 129
315 130 <h3>${_('Statistics')}</h3>
316 131 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
317 132 <div class="form">
318 133 <div class="fields">
319 134 ${h.submit('reset_stats_%s' % c.repo_info.repo_name,_('Reset current statistics'),class_="refresh_icon action_button",onclick="return confirm('Confirm to remove current statistics');")}
320 135 <div class="field" style="border:none">
321 136 <ul>
322 137 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
323 138 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
324 139 </ul>
325 140 </div>
326 141
327 142 </div>
328 143 </div>
329 144 ${h.end_form()}
330 145
331 146 %if c.repo_info.clone_uri:
332 147 <h3>${_('Remote')}</h3>
333 148 ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
334 149 <div class="form">
335 150 <div class="fields">
336 151 ${h.submit('remote_pull_%s' % c.repo_info.repo_name,_('Pull changes from remote location'),class_="pull_icon action_button",onclick="return confirm('Confirm to pull changes from remote side');")}
337 152 <div class="field" style="border:none">
338 153 <ul>
339 154 <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
340 155 </ul>
341 156 </div>
342 157 </div>
343 158 </div>
344 159 ${h.end_form()}
345 160 %endif
346 161
347 162 <h3>${_('Cache')}</h3>
348 163 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
349 164 <div class="form">
350 165 <div class="fields">
351 166 ${h.submit('reset_cache_%s' % c.repo_info.repo_name,_('Invalidate repository cache'),class_="refresh_icon action_button",onclick="return confirm('Confirm to invalidate repository cache');")}
352 167 </div>
353 168 </div>
354 169 ${h.end_form()}
355 170
356 171 <h3>${_('Public journal')}</h3>
357 172 ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
358 173 <div class="form">
359 174 <div class="fields">
360 175 ${h.hidden('auth_token',str(h.get_token()))}
361 176 %if c.in_public_journal:
362 177 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="stop_following_icon action_button")}
363 178 %else:
364 179 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="start_following_icon action_button")}
365 180 %endif
366 181 </div>
367 182 </div>
368 183 ${h.end_form()}
369 184
370 185 <h3>${_('Delete')}</h3>
371 186 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
372 187 <div class="form">
373 188 <div class="fields">
374 189 ${h.submit('remove_%s' % c.repo_info.repo_name,_('Remove this repository'),class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
375 190 </div>
376 191 </div>
377 192 ${h.end_form()}
378 193
379 194 </div>
380 195
381 196
382 197 </%def> No newline at end of file
@@ -1,97 +1,281
1 1 <table id="permissions_manage">
2 2 <tr>
3 3 <td>${_('none')}</td>
4 4 <td>${_('read')}</td>
5 5 <td>${_('write')}</td>
6 6 <td>${_('admin')}</td>
7 7 <td>${_('member')}</td>
8 8 <td></td>
9 9 </tr>
10 ## USERS
11 <script type="text/javascript">
12 function ajaxActionUser(user_id,field_id){
13 var sUrl = "${h.url('delete_repo_user',repo_name=c.repo_name)}";
14 var callback = { success:function(o){
15 var tr = YUD.get(String(field_id));
16 tr.parentNode.removeChild(tr);},
17 failure:function(o){
18 alert("${_('Failed to remove user')}");},};
19 var postData = '_method=delete&user_id='+user_id;
20 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);};
21 </script>
10 ## USERS
22 11 %for r2p in c.repo_info.repo_to_perm:
23 12 %if r2p.user.username =='default' and c.repo_info.private:
24 13 <tr>
25 14 <td colspan="4">
26 15 <span class="private_repo_msg">
27 16 ${_('private repository')}
28 17 </span>
29 18 </td>
30 19 <td class="private_repo_msg"><img style="vertical-align:bottom" src="${h.url("/images/icons/user.png")}"/>${r2p.user.username}</td>
31 20 </tr>
32 21 %else:
33 22 <tr id="id${id(r2p.user.username)}">
34 23 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.none')}</td>
35 24 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.read')}</td>
36 25 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.write')}</td>
37 26 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.admin')}</td>
38 <td style="white-space: nowrap;"><img style="vertical-align:bottom" src="${h.url("/images/icons/user.png")}"/>${r2p.user.username}</td>
27 <td style="white-space: nowrap;">
28 <img style="vertical-align:bottom" src="${h.url('/images/icons/user.png')}"/>${r2p.user.username}
29 </td>
39 30 <td>
40 31 %if r2p.user.username !='default':
41 32 <span class="delete_icon action_button" onclick="ajaxActionUser(${r2p.user.user_id},'${'id%s'%id(r2p.user.username)}')">
42 33 ${_('revoke')}
43 34 </span>
44 35 %endif
45 36 </td>
46 37 </tr>
47 38 %endif
48 39 %endfor
49 40
50 ## USERS GROUPS
51 <script type="text/javascript">
52 function ajaxActionUsersGroup(users_group_id,field_id){
53 var sUrl = "${h.url('delete_repo_users_group',repo_name=c.repo_name)}";
54 var callback = { success:function(o){
55 var tr = YUD.get(String(field_id));
56 tr.parentNode.removeChild(tr);},
57 failure:function(o){
58 alert("${_('Failed to remove users group')}");},};
59 var postData = '_method=delete&users_group_id='+users_group_id;
60 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);};
61 </script>
41 ## USERS GROUPS
62 42 %for g2p in c.repo_info.users_group_to_perm:
63 43 <tr id="id${id(g2p.users_group.users_group_name)}">
64 44 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.none')}</td>
65 45 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.read')}</td>
66 46 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.write')}</td>
67 47 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.admin')}</td>
68 <td><img style="vertical-align:bottom" src="${h.url("/images/icons/group.png")}"/>${g2p.users_group.users_group_name}</td>
48 <td style="white-space: nowrap;">
49 <img style="vertical-align:bottom" src="${h.url('/images/icons/group.png')}"/>${g2p.users_group.users_group_name}
50 </td>
69 51 <td>
70 52 <span class="delete_icon action_button" onclick="ajaxActionUsersGroup(${g2p.users_group.users_group_id},'${'id%s'%id(g2p.users_group.users_group_name)}')">
71 53 ${_('revoke')}
72 54 </span>
73 55 </td>
74 56 </tr>
75 57 %endfor
76 58 <tr id="add_perm_input">
77 59 <td>${h.radio('perm_new_member','repository.none')}</td>
78 60 <td>${h.radio('perm_new_member','repository.read')}</td>
79 61 <td>${h.radio('perm_new_member','repository.write')}</td>
80 62 <td>${h.radio('perm_new_member','repository.admin')}</td>
81 63 <td class='ac'>
82 64 <div class="perm_ac" id="perm_ac">
83 65 ${h.text('perm_new_member_name',class_='yui-ac-input')}
84 66 ${h.hidden('perm_new_member_type')}
85 67 <div id="perm_container"></div>
86 68 </div>
87 69 </td>
88 70 <td></td>
89 71 </tr>
90 72 <tr>
91 73 <td colspan="6">
92 74 <span id="add_perm" class="add_icon" style="cursor: pointer;">
93 75 ${_('Add another member')}
94 76 </span>
95 77 </td>
96 78 </tr>
97 </table> No newline at end of file
79 </table>
80 <script type="text/javascript">
81 function ajaxActionUser(user_id, field_id) {
82 var sUrl = "${h.url('delete_repo_user',repo_name=c.repo_name)}";
83 var callback = {
84 success: function (o) {
85 var tr = YUD.get(String(field_id));
86 tr.parentNode.removeChild(tr);
87 },
88 failure: function (o) {
89 alert("${_('Failed to remove user')}");
90 },
91 };
92 var postData = '_method=delete&user_id=' + user_id;
93 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
94 };
95
96 function ajaxActionUsersGroup(users_group_id,field_id){
97 var sUrl = "${h.url('delete_repo_users_group',repo_name=c.repo_name)}";
98 var callback = {
99 success:function(o){
100 var tr = YUD.get(String(field_id));
101 tr.parentNode.removeChild(tr);
102 },
103 failure:function(o){
104 alert("${_('Failed to remove users group')}");
105 },
106 };
107 var postData = '_method=delete&users_group_id='+users_group_id;
108 var request = YAHOO.util.Connect.asyncRequest('POST', sUrl, callback, postData);
109 };
110
111 YUE.onDOMReady(function () {
112 if (!YUD.hasClass('perm_new_member_name', 'error')) {
113 YUD.setStyle('add_perm_input', 'display', 'none');
114 }
115 YAHOO.util.Event.addListener('add_perm', 'click', function () {
116 YUD.setStyle('add_perm_input', 'display', '');
117 YUD.setStyle('add_perm', 'opacity', '0.6');
118 YUD.setStyle('add_perm', 'cursor', 'default');
119 });
120 });
121
122 YAHOO.example.FnMultipleFields = function () {
123 var myUsers = ${c.users_array|n};
124 var myGroups = ${c.users_groups_array|n};
125
126 // Define a custom search function for the DataSource of users
127 var matchUsers = function (sQuery) {
128 // Case insensitive matching
129 var query = sQuery.toLowerCase();
130 var i = 0;
131 var l = myUsers.length;
132 var matches = [];
133
134 // Match against each name of each contact
135 for (; i < l; i++) {
136 contact = myUsers[i];
137 if ((contact.fname.toLowerCase().indexOf(query) > -1) || (contact.lname.toLowerCase().indexOf(query) > -1) || (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) {
138 matches[matches.length] = contact;
139 }
140 }
141 return matches;
142 };
143
144 // Define a custom search function for the DataSource of usersGroups
145 var matchGroups = function (sQuery) {
146 // Case insensitive matching
147 var query = sQuery.toLowerCase();
148 var i = 0;
149 var l = myGroups.length;
150 var matches = [];
151
152 // Match against each name of each contact
153 for (; i < l; i++) {
154 matched_group = myGroups[i];
155 if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
156 matches[matches.length] = matched_group;
157 }
158 }
159 return matches;
160 };
161
162 //match all
163 var matchAll = function (sQuery) {
164 u = matchUsers(sQuery);
165 g = matchGroups(sQuery);
166 return u.concat(g);
167 };
168
169 // DataScheme for members
170 var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
171 memberDS.responseSchema = {
172 fields: ["id", "fname", "lname", "nname", "grname", "grmembers"]
173 };
174
175 // DataScheme for owner
176 var ownerDS = new YAHOO.util.FunctionDataSource(matchUsers);
177 ownerDS.responseSchema = {
178 fields: ["id", "fname", "lname", "nname"]
179 };
180
181 // Instantiate AutoComplete for perms
182 var membersAC = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", memberDS);
183 membersAC.useShadow = false;
184 membersAC.resultTypeList = false;
185
186 // Instantiate AutoComplete for owner
187 var ownerAC = new YAHOO.widget.AutoComplete("user", "owner_container", ownerDS);
188 ownerAC.useShadow = false;
189 ownerAC.resultTypeList = false;
190
191
192 // Helper highlight function for the formatter
193 var highlightMatch = function (full, snippet, matchindex) {
194 return full.substring(0, matchindex) + "<span class='match'>" + full.substr(matchindex, snippet.length) + "</span>" + full.substring(matchindex + snippet.length);
195 };
196
197 // Custom formatter to highlight the matching letters
198 var custom_formatter = function (oResultData, sQuery, sResultMatch) {
199 var query = sQuery.toLowerCase();
200
201 if (oResultData.grname != undefined) {
202 var grname = oResultData.grname;
203 var grmembers = oResultData.grmembers;
204 var grnameMatchIndex = grname.toLowerCase().indexOf(query);
205 var grprefix = "${_('Group')}: ";
206 var grsuffix = " (" + grmembers + " ${_('members')})";
207
208 if (grnameMatchIndex > -1) {
209 return grprefix + highlightMatch(grname, query, grnameMatchIndex) + grsuffix;
210 }
211
212 return grprefix + oResultData.grname + grsuffix;
213 } else if (oResultData.fname != undefined) {
214
215 var fname = oResultData.fname,
216 lname = oResultData.lname,
217 nname = oResultData.nname || "",
218 // Guard against null value
219 fnameMatchIndex = fname.toLowerCase().indexOf(query),
220 lnameMatchIndex = lname.toLowerCase().indexOf(query),
221 nnameMatchIndex = nname.toLowerCase().indexOf(query),
222 displayfname, displaylname, displaynname;
223
224 if (fnameMatchIndex > -1) {
225 displayfname = highlightMatch(fname, query, fnameMatchIndex);
226 } else {
227 displayfname = fname;
228 }
229
230 if (lnameMatchIndex > -1) {
231 displaylname = highlightMatch(lname, query, lnameMatchIndex);
232 } else {
233 displaylname = lname;
234 }
235
236 if (nnameMatchIndex > -1) {
237 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
238 } else {
239 displaynname = nname ? "(" + nname + ")" : "";
240 }
241
242 return displayfname + " " + displaylname + " " + displaynname;
243 } else {
244 return '';
245 }
246 };
247 membersAC.formatResult = custom_formatter;
248 ownerAC.formatResult = custom_formatter;
249
250 var myHandler = function (sType, aArgs) {
251
252 var myAC = aArgs[0]; // reference back to the AC instance
253 var elLI = aArgs[1]; // reference to the selected LI element
254 var oData = aArgs[2]; // object literal of selected item's result data
255 //fill the autocomplete with value
256 if (oData.nname != undefined) {
257 //users
258 myAC.getInputEl().value = oData.nname;
259 YUD.get('perm_new_member_type').value = 'user';
260 } else {
261 //groups
262 myAC.getInputEl().value = oData.grname;
263 YUD.get('perm_new_member_type').value = 'users_group';
264 }
265
266 };
267
268 membersAC.itemSelectEvent.subscribe(myHandler);
269 if(ownerAC.itemSelectEvent){
270 ownerAC.itemSelectEvent.subscribe(myHandler);
271 }
272
273 return {
274 memberDS: memberDS,
275 ownerDS: ownerDS,
276 membersAC: membersAC,
277 ownerAC: ownerAC,
278 };
279 }();
280
281 </script> No newline at end of file
@@ -1,88 +1,88
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 5 ${_('Repositories administration')} - ${c.rhodecode_name}
6 6 </%def>
7 7
8 8
9 9 <%def name="breadcrumbs_links()">
10 10 ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; ${_('Repositories')}
11 11 </%def>
12 12 <%def name="page_nav()">
13 13 ${self.menu('admin')}
14 14 </%def>
15 15 <%def name="main()">
16 16 <div class="box">
17 17 <!-- box / title -->
18 18 <div class="title">
19 19 ${self.breadcrumbs()}
20 20 <ul class="links">
21 21 <li>
22 22 <span>${h.link_to(u'ADD NEW REPOSITORY',h.url('new_repo'))}</span>
23 23 </li>
24 24 </ul>
25 25 </div>
26 26 <!-- end box / title -->
27 27 <div class="table">
28 28 <table class="table_disp">
29 29 <tr class="header">
30 30 <th class="left">${_('Name')}</th>
31 31 <th class="left">${_('Description')}</th>
32 32 <th class="left">${_('Last change')}</th>
33 33 <th class="left">${_('Tip')}</th>
34 34 <th class="left">${_('Contact')}</th>
35 35 <th class="left">${_('action')}</th>
36 36 </tr>
37 37 %for cnt,repo in enumerate(c.repos_list):
38 38 <tr class="parity${cnt%2}">
39 39 <td>
40 40 ## TYPE OF REPO
41 41 %if repo['dbrepo']['repo_type'] =='hg':
42 <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url("/images/icons/hgicon.png")}"/>
42 <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/>
43 43 %elif repo['dbrepo']['repo_type'] =='git':
44 <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url("/images/icons/giticon.png")}"/>
44 <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/>
45 45 %else:
46 46
47 47 %endif
48 48
49 49 ## PRIVATE/PUBLIC REPO
50 50 %if repo['dbrepo']['private']:
51 <img alt="${_('private')}" src="${h.url("/images/icons/lock.png")}"/>
51 <img alt="${_('private')}" src="${h.url('/images/icons/lock.png')}"/>
52 52 %else:
53 <img alt="${_('public')}" src="${h.url("/images/icons/lock_open.png")}"/>
53 <img alt="${_('public')}" src="${h.url('/images/icons/lock_open.png')}"/>
54 54 %endif
55 55 ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}
56 56
57 57 %if repo['dbrepo_fork']:
58 58 <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}">
59 59 <img class="icon" alt="${_('public')}"
60 60 title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}"
61 61 src="${h.url("/images/icons/arrow_divide.png")}"/></a>
62 62 %endif
63 63 </td>
64 64 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
65 65 <td>${h.age(repo['last_change'])}</td>
66 66 <td>
67 67 %if repo['rev']>=0:
68 68 ${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
69 69 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
70 70 class_="tooltip",
71 71 title=h.tooltip(repo['last_msg']))}
72 72 %else:
73 73 ${_('No changesets yet')}
74 74 %endif
75 75 </td>
76 76 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
77 77 <td>
78 78 ${h.form(url('repo', repo_name=repo['name']),method='delete')}
79 79 ${h.submit('remove_%s' % repo['name'],'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
80 80 ${h.end_form()}
81 81 </td>
82 82 </tr>
83 83 %endfor
84 84 </table>
85 85 </div>
86 86 </div>
87 87
88 88 </%def>
@@ -1,197 +1,75
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 5 ${c.repo_name} ${_('Settings')} - ${c.rhodecode_name}
6 6 </%def>
7 7
8 8 <%def name="breadcrumbs_links()">
9 9 ${h.link_to(u'Home',h.url('/'))}
10 10 &raquo;
11 11 ${h.link_to(c.repo_info.repo_name,h.url('summary_home',repo_name=c.repo_info.repo_name))}
12 12 &raquo;
13 13 ${_('Settings')}
14 14 </%def>
15 15
16 16 <%def name="page_nav()">
17 17 ${self.menu('settings')}
18 18 </%def>
19 19 <%def name="main()">
20 20 <div class="box">
21 21 <!-- box / title -->
22 22 <div class="title">
23 23 ${self.breadcrumbs()}
24 24 </div>
25 25 ${h.form(url('repo_settings_update', repo_name=c.repo_info.repo_name),method='put')}
26 26 <div class="form">
27 27 <!-- fields -->
28 28 <div class="fields">
29 29 <div class="field">
30 30 <div class="label">
31 31 <label for="repo_name">${_('Name')}:</label>
32 32 </div>
33 33 <div class="input input-medium">
34 34 ${h.text('repo_name',class_="small")}
35 35 </div>
36 36 </div>
37 37
38 38 <div class="field">
39 39 <div class="label label-textarea">
40 40 <label for="description">${_('Description')}:</label>
41 41 </div>
42 42 <div class="textarea text-area editor">
43 43 ${h.textarea('description',cols=23,rows=5)}
44 44 </div>
45 45 </div>
46 46
47 47 <div class="field">
48 48 <div class="label label-checkbox">
49 49 <label for="private">${_('Private')}:</label>
50 50 </div>
51 51 <div class="checkboxes">
52 52 ${h.checkbox('private',value="True")}
53 53 </div>
54 54 </div>
55 55
56 56 <div class="field">
57 57 <div class="label">
58 58 <label for="">${_('Permissions')}:</label>
59 59 </div>
60 60 <div class="input">
61 61 <%include file="../admin/repos/repo_edit_perms.html"/>
62 62 </div>
63 63
64 64 <div class="buttons">
65 ${h.submit('update','Update',class_="ui-button")}
65 ${h.submit('save','Save',class_="ui-button")}
66 66 ${h.reset('reset','Reset',class_="ui-button")}
67 67 </div>
68 68 </div>
69 69 </div>
70 70 ${h.end_form()}
71 <script type="text/javascript">
72 YAHOO.util.Event.onDOMReady(function(){
73 var D = YAHOO.util.Dom;
74 if(!D.hasClass('perm_new_member_name','error')){
75 D.setStyle('add_perm_input','display','none');
76 }
77 YAHOO.util.Event.addListener('add_perm','click',function(){
78 D.setStyle('add_perm_input','display','');
79 D.setStyle('add_perm','opacity','0.6');
80 D.setStyle('add_perm','cursor','default');
81 });
82 });
83 </script>
84 <script type="text/javascript">
85 YAHOO.example.FnMultipleFields = function(){
86 var myContacts = ${c.users_array|n}
87
88 // Define a custom search function for the DataSource
89 var matchNames = function(sQuery) {
90 // Case insensitive matching
91 var query = sQuery.toLowerCase(),
92 contact,
93 i=0,
94 l=myContacts.length,
95 matches = [];
96
97 // Match against each name of each contact
98 for(; i<l; i++) {
99 contact = myContacts[i];
100 if((contact.fname.toLowerCase().indexOf(query) > -1) ||
101 (contact.lname.toLowerCase().indexOf(query) > -1) ||
102 (contact.nname && (contact.nname.toLowerCase().indexOf(query) > -1))) {
103 matches[matches.length] = contact;
104 }
105 }
106
107 return matches;
108 };
109
110 // Use a FunctionDataSource
111 var oDS = new YAHOO.util.FunctionDataSource(matchNames);
112 oDS.responseSchema = {
113 fields: ["id", "fname", "lname", "nname"]
114 }
115
116 // Instantiate AutoComplete for perms
117 var oAC_perms = new YAHOO.widget.AutoComplete("perm_new_member_name", "perm_container", oDS);
118 oAC_perms.useShadow = false;
119 oAC_perms.resultTypeList = false;
120
121 // Instantiate AutoComplete for owner
122 var oAC_owner = new YAHOO.widget.AutoComplete("user", "owner_container", oDS);
123 oAC_owner.useShadow = false;
124 oAC_owner.resultTypeList = false;
125
126
127 // Custom formatter to highlight the matching letters
128 var custom_formatter = function(oResultData, sQuery, sResultMatch) {
129 var query = sQuery.toLowerCase(),
130 fname = oResultData.fname,
131 lname = oResultData.lname,
132 nname = oResultData.nname || "", // Guard against null value
133 query = sQuery.toLowerCase(),
134 fnameMatchIndex = fname.toLowerCase().indexOf(query),
135 lnameMatchIndex = lname.toLowerCase().indexOf(query),
136 nnameMatchIndex = nname.toLowerCase().indexOf(query),
137 displayfname, displaylname, displaynname;
138
139 if(fnameMatchIndex > -1) {
140 displayfname = highlightMatch(fname, query, fnameMatchIndex);
141 }
142 else {
143 displayfname = fname;
144 }
145
146 if(lnameMatchIndex > -1) {
147 displaylname = highlightMatch(lname, query, lnameMatchIndex);
148 }
149 else {
150 displaylname = lname;
151 }
152
153 if(nnameMatchIndex > -1) {
154 displaynname = "(" + highlightMatch(nname, query, nnameMatchIndex) + ")";
155 }
156 else {
157 displaynname = nname ? "(" + nname + ")" : "";
158 }
159
160 return displayfname + " " + displaylname + " " + displaynname;
161
162 };
163 oAC_perms.formatResult = custom_formatter;
164 oAC_owner.formatResult = custom_formatter;
165
166 // Helper function for the formatter
167 var highlightMatch = function(full, snippet, matchindex) {
168 return full.substring(0, matchindex) +
169 "<span class='match'>" +
170 full.substr(matchindex, snippet.length) +
171 "</span>" +
172 full.substring(matchindex + snippet.length);
173 };
174
175 var myHandler = function(sType, aArgs) {
176 var myAC = aArgs[0]; // reference back to the AC instance
177 var elLI = aArgs[1]; // reference to the selected LI element
178 var oData = aArgs[2]; // object literal of selected item's result data
179 myAC.getInputEl().value = oData.nname;
180 };
181
182 oAC_perms.itemSelectEvent.subscribe(myHandler);
183 //oAC_owner.itemSelectEvent.subscribe(myHandler);
184
185 return {
186 oDS: oDS,
187 oAC_perms: oAC_perms,
188 oAC_owner: oAC_owner,
189 };
190 }();
191
192 </script>
193 71 </div>
194 72 </div>
195 73 </%def>
196 74
197 75
General Comments 0
You need to be logged in to leave comments. Login now