##// 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 ## -*- 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 ${_('Edit repository')} ${c.repo_info.repo_name} - ${c.rhodecode_name}
5 ${_('Edit repository')} ${c.repo_info.repo_name} - ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 ${h.link_to(_('Admin'),h.url('admin_home'))}
9 ${h.link_to(_('Admin'),h.url('admin_home'))}
10 &raquo;
10 &raquo;
11 ${h.link_to(_('Repositories'),h.url('repos'))}
11 ${h.link_to(_('Repositories'),h.url('repos'))}
12 &raquo;
12 &raquo;
13 ${_('edit')} &raquo; ${h.link_to(c.repo_info.just_name,h.url('summary_home',repo_name=c.repo_name))}
13 ${_('edit')} &raquo; ${h.link_to(c.repo_info.just_name,h.url('summary_home',repo_name=c.repo_name))}
14 </%def>
14 </%def>
15
15
16 <%def name="page_nav()">
16 <%def name="page_nav()">
17 ${self.menu('admin')}
17 ${self.menu('admin')}
18 </%def>
18 </%def>
19
19
20 <%def name="main()">
20 <%def name="main()">
21 <div class="box box-left">
21 <div class="box box-left">
22 <!-- box / title -->
22 <!-- box / title -->
23 <div class="title">
23 <div class="title">
24 ${self.breadcrumbs()}
24 ${self.breadcrumbs()}
25 </div>
25 </div>
26 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')}
26 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='put')}
27 <div class="form">
27 <div class="form">
28 <!-- fields -->
28 <!-- fields -->
29 <div class="fields">
29 <div class="fields">
30 <div class="field">
30 <div class="field">
31 <div class="label">
31 <div class="label">
32 <label for="repo_name">${_('Name')}:</label>
32 <label for="repo_name">${_('Name')}:</label>
33 </div>
33 </div>
34 <div class="input">
34 <div class="input">
35 ${h.text('repo_name',class_="medium")}
35 ${h.text('repo_name',class_="medium")}
36 </div>
36 </div>
37 </div>
37 </div>
38 <div class="field">
38 <div class="field">
39 <div class="label">
39 <div class="label">
40 <label for="clone_uri">${_('Clone uri')}:</label>
40 <label for="clone_uri">${_('Clone uri')}:</label>
41 </div>
41 </div>
42 <div class="input">
42 <div class="input">
43 ${h.text('clone_uri',class_="medium")}
43 ${h.text('clone_uri',class_="medium")}
44 </div>
44 </div>
45 </div>
45 </div>
46 <div class="field">
46 <div class="field">
47 <div class="label">
47 <div class="label">
48 <label for="repo_group">${_('Repository group')}:</label>
48 <label for="repo_group">${_('Repository group')}:</label>
49 </div>
49 </div>
50 <div class="input">
50 <div class="input">
51 ${h.select('repo_group','',c.repo_groups,class_="medium")}
51 ${h.select('repo_group','',c.repo_groups,class_="medium")}
52 </div>
52 </div>
53 </div>
53 </div>
54 <div class="field">
54 <div class="field">
55 <div class="label">
55 <div class="label">
56 <label for="repo_type">${_('Type')}:</label>
56 <label for="repo_type">${_('Type')}:</label>
57 </div>
57 </div>
58 <div class="input">
58 <div class="input">
59 ${h.select('repo_type','hg',c.backends,class_="medium")}
59 ${h.select('repo_type','hg',c.backends,class_="medium")}
60 </div>
60 </div>
61 </div>
61 </div>
62 <div class="field">
62 <div class="field">
63 <div class="label label-textarea">
63 <div class="label label-textarea">
64 <label for="description">${_('Description')}:</label>
64 <label for="description">${_('Description')}:</label>
65 </div>
65 </div>
66 <div class="textarea text-area editor">
66 <div class="textarea text-area editor">
67 ${h.textarea('description',cols=23,rows=5)}
67 ${h.textarea('description',cols=23,rows=5)}
68 </div>
68 </div>
69 </div>
69 </div>
70
70
71 <div class="field">
71 <div class="field">
72 <div class="label label-checkbox">
72 <div class="label label-checkbox">
73 <label for="private">${_('Private')}:</label>
73 <label for="private">${_('Private')}:</label>
74 </div>
74 </div>
75 <div class="checkboxes">
75 <div class="checkboxes">
76 ${h.checkbox('private',value="True")}
76 ${h.checkbox('private',value="True")}
77 </div>
77 </div>
78 </div>
78 </div>
79 <div class="field">
79 <div class="field">
80 <div class="label label-checkbox">
80 <div class="label label-checkbox">
81 <label for="enable_statistics">${_('Enable statistics')}:</label>
81 <label for="enable_statistics">${_('Enable statistics')}:</label>
82 </div>
82 </div>
83 <div class="checkboxes">
83 <div class="checkboxes">
84 ${h.checkbox('enable_statistics',value="True")}
84 ${h.checkbox('enable_statistics',value="True")}
85 </div>
85 </div>
86 </div>
86 </div>
87 <div class="field">
87 <div class="field">
88 <div class="label label-checkbox">
88 <div class="label label-checkbox">
89 <label for="enable_downloads">${_('Enable downloads')}:</label>
89 <label for="enable_downloads">${_('Enable downloads')}:</label>
90 </div>
90 </div>
91 <div class="checkboxes">
91 <div class="checkboxes">
92 ${h.checkbox('enable_downloads',value="True")}
92 ${h.checkbox('enable_downloads',value="True")}
93 </div>
93 </div>
94 </div>
94 </div>
95 <div class="field">
95 <div class="field">
96 <div class="label">
96 <div class="label">
97 <label for="user">${_('Owner')}:</label>
97 <label for="user">${_('Owner')}:</label>
98 </div>
98 </div>
99 <div class="input input-small ac">
99 <div class="input input-small ac">
100 <div class="perm_ac">
100 <div class="perm_ac">
101 ${h.text('user',class_='yui-ac-input')}
101 ${h.text('user',class_='yui-ac-input')}
102 <div id="owner_container"></div>
102 <div id="owner_container"></div>
103 </div>
103 </div>
104 </div>
104 </div>
105 </div>
105 </div>
106
106
107 <div class="field">
107 <div class="field">
108 <div class="label">
108 <div class="label">
109 <label for="input">${_('Permissions')}:</label>
109 <label for="input">${_('Permissions')}:</label>
110 </div>
110 </div>
111 <div class="input">
111 <div class="input">
112 <%include file="repo_edit_perms.html"/>
112 <%include file="repo_edit_perms.html"/>
113 </div>
113 </div>
114
114
115 <div class="buttons">
115 <div class="buttons">
116 ${h.submit('save','Save',class_="ui-button")}
116 ${h.submit('save','Save',class_="ui-button")}
117 ${h.reset('reset','Reset',class_="ui-button")}
117 ${h.reset('reset','Reset',class_="ui-button")}
118 </div>
118 </div>
119 </div>
119 </div>
120 </div>
120 </div>
121 </div>
121 </div>
122 ${h.end_form()}
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 </div>
123 </div>
309
124
310 <div class="box box-right">
125 <div class="box box-right">
311 <div class="title">
126 <div class="title">
312 <h5>${_('Administration')}</h5>
127 <h5>${_('Administration')}</h5>
313 </div>
128 </div>
314
129
315 <h3>${_('Statistics')}</h3>
130 <h3>${_('Statistics')}</h3>
316 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
131 ${h.form(url('repo_stats', repo_name=c.repo_info.repo_name),method='delete')}
317 <div class="form">
132 <div class="form">
318 <div class="fields">
133 <div class="fields">
319 ${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');")}
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 <div class="field" style="border:none">
135 <div class="field" style="border:none">
321 <ul>
136 <ul>
322 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
137 <li>${_('Fetched to rev')}: ${c.stats_revision}/${c.repo_last_rev}</li>
323 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
138 <li>${_('Percentage of stats gathered')}: ${c.stats_percentage} %</li>
324 </ul>
139 </ul>
325 </div>
140 </div>
326
141
327 </div>
142 </div>
328 </div>
143 </div>
329 ${h.end_form()}
144 ${h.end_form()}
330
145
331 %if c.repo_info.clone_uri:
146 %if c.repo_info.clone_uri:
332 <h3>${_('Remote')}</h3>
147 <h3>${_('Remote')}</h3>
333 ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
148 ${h.form(url('repo_pull', repo_name=c.repo_info.repo_name),method='put')}
334 <div class="form">
149 <div class="form">
335 <div class="fields">
150 <div class="fields">
336 ${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');")}
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 <div class="field" style="border:none">
152 <div class="field" style="border:none">
338 <ul>
153 <ul>
339 <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
154 <li><a href="${c.repo_info.clone_uri}">${c.repo_info.clone_uri}</a></li>
340 </ul>
155 </ul>
341 </div>
156 </div>
342 </div>
157 </div>
343 </div>
158 </div>
344 ${h.end_form()}
159 ${h.end_form()}
345 %endif
160 %endif
346
161
347 <h3>${_('Cache')}</h3>
162 <h3>${_('Cache')}</h3>
348 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
163 ${h.form(url('repo_cache', repo_name=c.repo_info.repo_name),method='delete')}
349 <div class="form">
164 <div class="form">
350 <div class="fields">
165 <div class="fields">
351 ${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');")}
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 </div>
167 </div>
353 </div>
168 </div>
354 ${h.end_form()}
169 ${h.end_form()}
355
170
356 <h3>${_('Public journal')}</h3>
171 <h3>${_('Public journal')}</h3>
357 ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
172 ${h.form(url('repo_public_journal', repo_name=c.repo_info.repo_name),method='put')}
358 <div class="form">
173 <div class="form">
359 <div class="fields">
174 <div class="fields">
360 ${h.hidden('auth_token',str(h.get_token()))}
175 ${h.hidden('auth_token',str(h.get_token()))}
361 %if c.in_public_journal:
176 %if c.in_public_journal:
362 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="stop_following_icon action_button")}
177 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Remove from public journal'),class_="stop_following_icon action_button")}
363 %else:
178 %else:
364 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="start_following_icon action_button")}
179 ${h.submit('set_public_%s' % c.repo_info.repo_name,_('Add to public journal'),class_="start_following_icon action_button")}
365 %endif
180 %endif
366 </div>
181 </div>
367 </div>
182 </div>
368 ${h.end_form()}
183 ${h.end_form()}
369
184
370 <h3>${_('Delete')}</h3>
185 <h3>${_('Delete')}</h3>
371 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
186 ${h.form(url('repo', repo_name=c.repo_info.repo_name),method='delete')}
372 <div class="form">
187 <div class="form">
373 <div class="fields">
188 <div class="fields">
374 ${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');")}
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 </div>
190 </div>
376 </div>
191 </div>
377 ${h.end_form()}
192 ${h.end_form()}
378
193
379 </div>
194 </div>
380
195
381
196
382 </%def> No newline at end of file
197 </%def>
@@ -1,97 +1,281
1 <table id="permissions_manage">
1 <table id="permissions_manage">
2 <tr>
2 <tr>
3 <td>${_('none')}</td>
3 <td>${_('none')}</td>
4 <td>${_('read')}</td>
4 <td>${_('read')}</td>
5 <td>${_('write')}</td>
5 <td>${_('write')}</td>
6 <td>${_('admin')}</td>
6 <td>${_('admin')}</td>
7 <td>${_('member')}</td>
7 <td>${_('member')}</td>
8 <td></td>
8 <td></td>
9 </tr>
9 </tr>
10 ## USERS
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>
22 %for r2p in c.repo_info.repo_to_perm:
11 %for r2p in c.repo_info.repo_to_perm:
23 %if r2p.user.username =='default' and c.repo_info.private:
12 %if r2p.user.username =='default' and c.repo_info.private:
24 <tr>
13 <tr>
25 <td colspan="4">
14 <td colspan="4">
26 <span class="private_repo_msg">
15 <span class="private_repo_msg">
27 ${_('private repository')}
16 ${_('private repository')}
28 </span>
17 </span>
29 </td>
18 </td>
30 <td class="private_repo_msg"><img style="vertical-align:bottom" src="${h.url("/images/icons/user.png")}"/>${r2p.user.username}</td>
19 <td class="private_repo_msg"><img style="vertical-align:bottom" src="${h.url("/images/icons/user.png")}"/>${r2p.user.username}</td>
31 </tr>
20 </tr>
32 %else:
21 %else:
33 <tr id="id${id(r2p.user.username)}">
22 <tr id="id${id(r2p.user.username)}">
34 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.none')}</td>
23 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.none')}</td>
35 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.read')}</td>
24 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.read')}</td>
36 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.write')}</td>
25 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.write')}</td>
37 <td>${h.radio('u_perm_%s' % r2p.user.username,'repository.admin')}</td>
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 <td>
30 <td>
40 %if r2p.user.username !='default':
31 %if r2p.user.username !='default':
41 <span class="delete_icon action_button" onclick="ajaxActionUser(${r2p.user.user_id},'${'id%s'%id(r2p.user.username)}')">
32 <span class="delete_icon action_button" onclick="ajaxActionUser(${r2p.user.user_id},'${'id%s'%id(r2p.user.username)}')">
42 ${_('revoke')}
33 ${_('revoke')}
43 </span>
34 </span>
44 %endif
35 %endif
45 </td>
36 </td>
46 </tr>
37 </tr>
47 %endif
38 %endif
48 %endfor
39 %endfor
49
40
50 ## USERS GROUPS
41 ## 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>
62 %for g2p in c.repo_info.users_group_to_perm:
42 %for g2p in c.repo_info.users_group_to_perm:
63 <tr id="id${id(g2p.users_group.users_group_name)}">
43 <tr id="id${id(g2p.users_group.users_group_name)}">
64 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.none')}</td>
44 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.none')}</td>
65 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.read')}</td>
45 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.read')}</td>
66 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.write')}</td>
46 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.write')}</td>
67 <td>${h.radio('g_perm_%s' % g2p.users_group.users_group_name,'repository.admin')}</td>
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 <td>
51 <td>
70 <span class="delete_icon action_button" onclick="ajaxActionUsersGroup(${g2p.users_group.users_group_id},'${'id%s'%id(g2p.users_group.users_group_name)}')">
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 ${_('revoke')}
53 ${_('revoke')}
72 </span>
54 </span>
73 </td>
55 </td>
74 </tr>
56 </tr>
75 %endfor
57 %endfor
76 <tr id="add_perm_input">
58 <tr id="add_perm_input">
77 <td>${h.radio('perm_new_member','repository.none')}</td>
59 <td>${h.radio('perm_new_member','repository.none')}</td>
78 <td>${h.radio('perm_new_member','repository.read')}</td>
60 <td>${h.radio('perm_new_member','repository.read')}</td>
79 <td>${h.radio('perm_new_member','repository.write')}</td>
61 <td>${h.radio('perm_new_member','repository.write')}</td>
80 <td>${h.radio('perm_new_member','repository.admin')}</td>
62 <td>${h.radio('perm_new_member','repository.admin')}</td>
81 <td class='ac'>
63 <td class='ac'>
82 <div class="perm_ac" id="perm_ac">
64 <div class="perm_ac" id="perm_ac">
83 ${h.text('perm_new_member_name',class_='yui-ac-input')}
65 ${h.text('perm_new_member_name',class_='yui-ac-input')}
84 ${h.hidden('perm_new_member_type')}
66 ${h.hidden('perm_new_member_type')}
85 <div id="perm_container"></div>
67 <div id="perm_container"></div>
86 </div>
68 </div>
87 </td>
69 </td>
88 <td></td>
70 <td></td>
89 </tr>
71 </tr>
90 <tr>
72 <tr>
91 <td colspan="6">
73 <td colspan="6">
92 <span id="add_perm" class="add_icon" style="cursor: pointer;">
74 <span id="add_perm" class="add_icon" style="cursor: pointer;">
93 ${_('Add another member')}
75 ${_('Add another member')}
94 </span>
76 </span>
95 </td>
77 </td>
96 </tr>
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 ## -*- 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 ${_('Repositories administration')} - ${c.rhodecode_name}
5 ${_('Repositories administration')} - ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8
8
9 <%def name="breadcrumbs_links()">
9 <%def name="breadcrumbs_links()">
10 ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; ${_('Repositories')}
10 ${h.link_to(_('Admin'),h.url('admin_home'))} &raquo; ${_('Repositories')}
11 </%def>
11 </%def>
12 <%def name="page_nav()">
12 <%def name="page_nav()">
13 ${self.menu('admin')}
13 ${self.menu('admin')}
14 </%def>
14 </%def>
15 <%def name="main()">
15 <%def name="main()">
16 <div class="box">
16 <div class="box">
17 <!-- box / title -->
17 <!-- box / title -->
18 <div class="title">
18 <div class="title">
19 ${self.breadcrumbs()}
19 ${self.breadcrumbs()}
20 <ul class="links">
20 <ul class="links">
21 <li>
21 <li>
22 <span>${h.link_to(u'ADD NEW REPOSITORY',h.url('new_repo'))}</span>
22 <span>${h.link_to(u'ADD NEW REPOSITORY',h.url('new_repo'))}</span>
23 </li>
23 </li>
24 </ul>
24 </ul>
25 </div>
25 </div>
26 <!-- end box / title -->
26 <!-- end box / title -->
27 <div class="table">
27 <div class="table">
28 <table class="table_disp">
28 <table class="table_disp">
29 <tr class="header">
29 <tr class="header">
30 <th class="left">${_('Name')}</th>
30 <th class="left">${_('Name')}</th>
31 <th class="left">${_('Description')}</th>
31 <th class="left">${_('Description')}</th>
32 <th class="left">${_('Last change')}</th>
32 <th class="left">${_('Last change')}</th>
33 <th class="left">${_('Tip')}</th>
33 <th class="left">${_('Tip')}</th>
34 <th class="left">${_('Contact')}</th>
34 <th class="left">${_('Contact')}</th>
35 <th class="left">${_('action')}</th>
35 <th class="left">${_('action')}</th>
36 </tr>
36 </tr>
37 %for cnt,repo in enumerate(c.repos_list):
37 %for cnt,repo in enumerate(c.repos_list):
38 <tr class="parity${cnt%2}">
38 <tr class="parity${cnt%2}">
39 <td>
39 <td>
40 ## TYPE OF REPO
40 ## TYPE OF REPO
41 %if repo['dbrepo']['repo_type'] =='hg':
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 %elif repo['dbrepo']['repo_type'] =='git':
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 %else:
45 %else:
46
46
47 %endif
47 %endif
48
48
49 ## PRIVATE/PUBLIC REPO
49 ## PRIVATE/PUBLIC REPO
50 %if repo['dbrepo']['private']:
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 %else:
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 %endif
54 %endif
55 ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}
55 ${h.link_to(repo['name'],h.url('edit_repo',repo_name=repo['name']))}
56
56
57 %if repo['dbrepo_fork']:
57 %if repo['dbrepo_fork']:
58 <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}">
58 <a href="${h.url('summary_home',repo_name=repo['dbrepo_fork']['repo_name'])}">
59 <img class="icon" alt="${_('public')}"
59 <img class="icon" alt="${_('public')}"
60 title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}"
60 title="${_('Fork of')} ${repo['dbrepo_fork']['repo_name']}"
61 src="${h.url("/images/icons/arrow_divide.png")}"/></a>
61 src="${h.url("/images/icons/arrow_divide.png")}"/></a>
62 %endif
62 %endif
63 </td>
63 </td>
64 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
64 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
65 <td>${h.age(repo['last_change'])}</td>
65 <td>${h.age(repo['last_change'])}</td>
66 <td>
66 <td>
67 %if repo['rev']>=0:
67 %if repo['rev']>=0:
68 ${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
68 ${h.link_to('r%s:%s' % (repo['rev'],h.short_id(repo['tip'])),
69 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
69 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
70 class_="tooltip",
70 class_="tooltip",
71 title=h.tooltip(repo['last_msg']))}
71 title=h.tooltip(repo['last_msg']))}
72 %else:
72 %else:
73 ${_('No changesets yet')}
73 ${_('No changesets yet')}
74 %endif
74 %endif
75 </td>
75 </td>
76 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
76 <td title="${repo['contact']}">${h.person(repo['contact'])}</td>
77 <td>
77 <td>
78 ${h.form(url('repo', repo_name=repo['name']),method='delete')}
78 ${h.form(url('repo', repo_name=repo['name']),method='delete')}
79 ${h.submit('remove_%s' % repo['name'],'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
79 ${h.submit('remove_%s' % repo['name'],'delete',class_="delete_icon action_button",onclick="return confirm('Confirm to delete this repository');")}
80 ${h.end_form()}
80 ${h.end_form()}
81 </td>
81 </td>
82 </tr>
82 </tr>
83 %endfor
83 %endfor
84 </table>
84 </table>
85 </div>
85 </div>
86 </div>
86 </div>
87
87
88 </%def>
88 </%def>
@@ -1,197 +1,75
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 ${c.repo_name} ${_('Settings')} - ${c.rhodecode_name}
5 ${c.repo_name} ${_('Settings')} - ${c.rhodecode_name}
6 </%def>
6 </%def>
7
7
8 <%def name="breadcrumbs_links()">
8 <%def name="breadcrumbs_links()">
9 ${h.link_to(u'Home',h.url('/'))}
9 ${h.link_to(u'Home',h.url('/'))}
10 &raquo;
10 &raquo;
11 ${h.link_to(c.repo_info.repo_name,h.url('summary_home',repo_name=c.repo_info.repo_name))}
11 ${h.link_to(c.repo_info.repo_name,h.url('summary_home',repo_name=c.repo_info.repo_name))}
12 &raquo;
12 &raquo;
13 ${_('Settings')}
13 ${_('Settings')}
14 </%def>
14 </%def>
15
15
16 <%def name="page_nav()">
16 <%def name="page_nav()">
17 ${self.menu('settings')}
17 ${self.menu('settings')}
18 </%def>
18 </%def>
19 <%def name="main()">
19 <%def name="main()">
20 <div class="box">
20 <div class="box">
21 <!-- box / title -->
21 <!-- box / title -->
22 <div class="title">
22 <div class="title">
23 ${self.breadcrumbs()}
23 ${self.breadcrumbs()}
24 </div>
24 </div>
25 ${h.form(url('repo_settings_update', repo_name=c.repo_info.repo_name),method='put')}
25 ${h.form(url('repo_settings_update', repo_name=c.repo_info.repo_name),method='put')}
26 <div class="form">
26 <div class="form">
27 <!-- fields -->
27 <!-- fields -->
28 <div class="fields">
28 <div class="fields">
29 <div class="field">
29 <div class="field">
30 <div class="label">
30 <div class="label">
31 <label for="repo_name">${_('Name')}:</label>
31 <label for="repo_name">${_('Name')}:</label>
32 </div>
32 </div>
33 <div class="input input-medium">
33 <div class="input input-medium">
34 ${h.text('repo_name',class_="small")}
34 ${h.text('repo_name',class_="small")}
35 </div>
35 </div>
36 </div>
36 </div>
37
37
38 <div class="field">
38 <div class="field">
39 <div class="label label-textarea">
39 <div class="label label-textarea">
40 <label for="description">${_('Description')}:</label>
40 <label for="description">${_('Description')}:</label>
41 </div>
41 </div>
42 <div class="textarea text-area editor">
42 <div class="textarea text-area editor">
43 ${h.textarea('description',cols=23,rows=5)}
43 ${h.textarea('description',cols=23,rows=5)}
44 </div>
44 </div>
45 </div>
45 </div>
46
46
47 <div class="field">
47 <div class="field">
48 <div class="label label-checkbox">
48 <div class="label label-checkbox">
49 <label for="private">${_('Private')}:</label>
49 <label for="private">${_('Private')}:</label>
50 </div>
50 </div>
51 <div class="checkboxes">
51 <div class="checkboxes">
52 ${h.checkbox('private',value="True")}
52 ${h.checkbox('private',value="True")}
53 </div>
53 </div>
54 </div>
54 </div>
55
55
56 <div class="field">
56 <div class="field">
57 <div class="label">
57 <div class="label">
58 <label for="">${_('Permissions')}:</label>
58 <label for="">${_('Permissions')}:</label>
59 </div>
59 </div>
60 <div class="input">
60 <div class="input">
61 <%include file="../admin/repos/repo_edit_perms.html"/>
61 <%include file="../admin/repos/repo_edit_perms.html"/>
62 </div>
62 </div>
63
63
64 <div class="buttons">
64 <div class="buttons">
65 ${h.submit('update','Update',class_="ui-button")}
65 ${h.submit('save','Save',class_="ui-button")}
66 ${h.reset('reset','Reset',class_="ui-button")}
66 ${h.reset('reset','Reset',class_="ui-button")}
67 </div>
67 </div>
68 </div>
68 </div>
69 </div>
69 </div>
70 ${h.end_form()}
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 </div>
71 </div>
194 </div>
72 </div>
195 </%def>
73 </%def>
196
74
197
75
General Comments 0
You need to be logged in to leave comments. Login now