##// END OF EJS Templates
quick filter: do an initial filtering on page load if it has a search criteria - for instance after back
Mads Kiilerich -
r4000:f60edcc4 default
parent child Browse files
Show More
@@ -1,228 +1,232 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3
4 4 <%def name="title()">
5 5 ${_('My account')} ${c.rhodecode_user.username} &middot; ${c.rhodecode_name}
6 6 </%def>
7 7
8 8 <%def name="breadcrumbs_links()">
9 9 ${_('My Account')}
10 10 </%def>
11 11
12 12 <%def name="page_nav()">
13 13 ${self.menu('admin')}
14 14 </%def>
15 15
16 16 <%def name="main()">
17 17
18 18 <div class="box box-left">
19 19 <!-- box / title -->
20 20 <div class="title">
21 21 ${self.breadcrumbs()}
22 22 </div>
23 23 <!-- end box / title -->
24 24 ${c.form|n}
25 25 </div>
26 26
27 27 <div class="box box-right">
28 28 <!-- box / title -->
29 29 <div class="title">
30 30 <h5>
31 31 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
32 32 </h5>
33 33 <ul class="links" style="color:#DADADA">
34 34 <li>
35 35 <span><a id="show_perms" class="link-white current" href="#perms">${_('My permissions')}</a> </span>
36 36 </li>
37 37 <li>
38 38 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
39 39 </li>
40 40 <li>
41 41 <span><a id="show_pullrequests" class="link-white" href="#pullrequests">${_('My pull requests')}</a> </span>
42 42 </li>
43 43 </ul>
44 44 </div>
45 45 <!-- end box / title -->
46 46 ## permissions overview
47 47 <div id="perms_container">
48 48 <%namespace name="p" file="/base/perms_summary.html"/>
49 49 ${p.perms_summary(c.perm_user.permissions)}
50 50 </div>
51 51
52 52 <div id="my_container" style="display:none">
53 53 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
54 54 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
55 55 </div>
56 56 <div id="pullrequests_container" class="table" style="display:none">
57 57 ## loaded via AJAX
58 58 ${_('Loading...')}
59 59 </div>
60 60 </div>
61 61
62 62 <script type="text/javascript">
63 63 pyroutes.register('admin_settings_my_pullrequests', "${url('admin_settings_my_pullrequests')}", []);
64 64
65 65 var show_perms = function(e){
66 66 YUD.addClass('show_perms', 'current');
67 67 YUD.removeClass('show_my','current');
68 68 YUD.removeClass('show_pullrequests','current');
69 69
70 70 YUD.setStyle('my_container','display','none');
71 71 YUD.setStyle('pullrequests_container','display','none');
72 72 YUD.setStyle('perms_container','display','');
73 73 YUD.setStyle('q_filter','display','none');
74 74 }
75 75 YUE.on('show_perms','click',function(e){
76 76 show_perms();
77 77 })
78 78
79 79 var show_my = function(e){
80 80 YUD.addClass('show_my', 'current');
81 81 YUD.removeClass('show_perms','current');
82 82 YUD.removeClass('show_pullrequests','current');
83 83
84 84 YUD.setStyle('perms_container','display','none');
85 85 YUD.setStyle('pullrequests_container','display','none');
86 86 YUD.setStyle('my_container','display','');
87 87 YUD.setStyle('q_filter','display','');
88 88 if(!YUD.hasClass('show_my', 'loaded')){
89 89 table_renderer(${c.data |n});
90 90 YUD.addClass('show_my', 'loaded');
91 91 }
92 92 }
93 93 YUE.on('show_my','click',function(e){
94 94 show_my(e);
95 95 })
96 96
97 97 var show_pullrequests = function(e){
98 98 YUD.addClass('show_pullrequests', 'current');
99 99 YUD.removeClass('show_my','current');
100 100 YUD.removeClass('show_perms','current');
101 101
102 102 YUD.setStyle('my_container','display','none');
103 103 YUD.setStyle('perms_container','display','none');
104 104 YUD.setStyle('pullrequests_container','display','');
105 105 YUD.setStyle('q_filter','display','none');
106 106
107 107 var url = pyroutes.url('admin_settings_my_pullrequests');
108 108 if(YUD.get('show_closed') && YUD.get('show_closed').checked) {
109 109 var url = pyroutes.url('admin_settings_my_pullrequests', {'pr_show_closed': '1'});
110 110 }
111 111 ypjax(url, 'pullrequests_container', function(){
112 112 YUE.on('show_closed','change',function (e) {
113 113 show_pullrequests(e);
114 114 });
115 115 });
116 116 }
117 117 YUE.on('show_pullrequests','click',function(e){
118 118 show_pullrequests(e)
119 119 })
120 120
121 121 var tabs = {
122 122 'perms': show_perms,
123 123 'my': show_my,
124 124 'pullrequests': show_pullrequests
125 125 }
126 126 var url = location.href.split('#');
127 127 if (url[1]) {
128 128 //We have a hash
129 129 var tabHash = url[1];
130 130 var func = tabs[tabHash]
131 131 if (func){
132 132 func();
133 133 }
134 134 }
135 135
136 136 function table_renderer(data){
137 137 var myDataSource = new YAHOO.util.DataSource(data);
138 138 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
139 139
140 140 myDataSource.responseSchema = {
141 141 resultsList: "records",
142 142 fields: [
143 143 {key:"menu"},
144 144 {key:"raw_name"},
145 145 {key:"name"},
146 146 {key:"last_changeset"},
147 147 {key:"action"},
148 148 ]
149 149 };
150 150 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
151 151 // This is the filter function
152 152 var data = res.results || [],
153 153 filtered = [],
154 154 i,l;
155 155
156 156 if (req) {
157 157 req = req.toLowerCase();
158 158 for (i = 0; i<data.length; i++) {
159 159 var pos = data[i].raw_name.toLowerCase().indexOf(req)
160 160 if (pos != -1) {
161 161 filtered.push(data[i]);
162 162 }
163 163 }
164 164 res.results = filtered;
165 165 }
166 166 return res;
167 167 }
168 168
169 169 // main table sorting
170 170 var myColumnDefs = [
171 171 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
172 172 {key:"name",label:"${_('Name')}",sortable:true,
173 173 sortOptions: { sortFunction: nameSort }},
174 174 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
175 175 sortOptions: { sortFunction: revisionSort }},
176 176 {key:"action",label:"${_('Action')}",sortable:false},
177 177 ];
178 178
179 179 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
180 180 sortedBy:{key:"name",dir:"asc"},
181 181 paginator: YUI_paginator(50, ['user-paginator']),
182 182
183 183 MSG_SORTASC:"${_('Click to sort ascending')}",
184 184 MSG_SORTDESC:"${_('Click to sort descending')}",
185 185 MSG_EMPTY:"${_('No records found.')}",
186 186 MSG_ERROR:"${_('Data error.')}",
187 187 MSG_LOADING:"${_('Loading...')}",
188 188 }
189 189 );
190 190 myDataTable.subscribe('postRenderEvent',function(oArgs) {
191 191 tooltip_activate();
192 192 quick_repo_menu();
193 193 });
194 194
195 195 var filterTimeout = null;
196 196
197 197 updateFilter = function() {
198 198 // Reset timeout
199 199 filterTimeout = null;
200 200
201 201 // Reset sort
202 202 var state = myDataTable.getState();
203 203 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
204 204
205 205 // Get filtered data
206 206 myDataSource.sendRequest(YUD.get('q_filter').value,{
207 207 success : myDataTable.onDataReturnInitializeTable,
208 208 failure : myDataTable.onDataReturnInitializeTable,
209 209 scope : myDataTable,
210 210 argument: state
211 211 });
212 212
213 213 };
214 214 YUE.on('q_filter','click',function(){
215 215 if(!YUD.hasClass('q_filter', 'loaded')){
216 216 //TODO: load here full list later to do search within groups
217 217 YUD.addClass('q_filter', 'loaded');
218 218 }
219 219 });
220 220
221 221 YUE.on('q_filter','keyup',function (e) {
222 222 clearTimeout(filterTimeout);
223 223 filterTimeout = setTimeout(updateFilter,600);
224 224 });
225 225
226 if(YUD.get('q_filter').value) {
227 updateFilter();
228 }
229
226 230 }
227 231 </script>
228 232 </%def>
@@ -1,178 +1,182 b''
1 1 <%page args="parent,group_name=''" />
2 2 <div class="box">
3 3 <!-- box / title -->
4 4 <div class="title">
5 5 <h5>
6 6 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value=""/> ${parent.breadcrumbs()} <span id="repo_count">0</span> ${_('repositories')}
7 7 </h5>
8 8 %if c.rhodecode_user.username != 'default':
9 9 <ul class="links">
10 10 %if h.HasPermissionAny('hg.admin','hg.create.repository')() or h.HasReposGroupPermissionAny('group.write', 'group.admin')(c.group.group_name if c.group else None):
11 11 <li>
12 12 %if c.group:
13 13 <span>${h.link_to(_('Add repository'),h.url('new_repo',parent_group=c.group.group_id))}</span>
14 14 %if h.HasPermissionAny('hg.admin')() or h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
15 15 <span>${h.link_to(_(u'Add repository group'),h.url('new_repos_group', parent_group=c.group.group_id))}</span>
16 16 %endif
17 17 %else:
18 18 <span>${h.link_to(_('Add repository'),h.url('new_repo'))}</span>
19 19 %if h.HasPermissionAny('hg.admin')():
20 20 <span>${h.link_to(_(u'Add repository group'),h.url('new_repos_group'))}</span>
21 21 %endif
22 22 %endif
23 23 </li>
24 24 %endif
25 25 %if c.group and h.HasReposGroupPermissionAny('group.admin')(c.group.group_name):
26 26 <li>
27 27 <span>${h.link_to(_('Edit repository group'),h.url('edit_repos_group',group_name=c.group.group_name), title=_('You have admin right to this group, and can edit it'))}</span>
28 28 </li>
29 29 %endif
30 30 </ul>
31 31 %endif
32 32 </div>
33 33 <!-- end box / title -->
34 34 <div class="table">
35 35 % if c.groups:
36 36 <div id='groups_list_wrap' class="yui-skin-sam">
37 37 <table id="groups_list">
38 38 <thead>
39 39 <tr>
40 40 <th class="left"><a href="#">${_('Group name')}</a></th>
41 41 <th class="left"><a href="#">${_('Description')}</a></th>
42 42 ##<th class="left"><a href="#">${_('Number of repositories')}</a></th>
43 43 </tr>
44 44 </thead>
45 45
46 46 ## REPO GROUPS
47 47 % for gr in c.groups:
48 48 <tr>
49 49 <td>
50 50 <div style="white-space: nowrap">
51 51 <img class="icon" alt="${_('Repository group')}" src="${h.url('/images/icons/database_link.png')}"/>
52 52 ${h.link_to(gr.name,url('repos_group_home',group_name=gr.group_name))}
53 53 </div>
54 54 </td>
55 55 %if c.visual.stylify_metatags:
56 56 <td>${h.urlify_text(h.desc_stylize(gr.group_description))}</td>
57 57 %else:
58 58 <td>${gr.group_description}</td>
59 59 %endif
60 60 ## this is commented out since for multi nested repos can be HEAVY!
61 61 ## in number of executed queries during traversing uncomment at will
62 62 ##<td><b>${gr.repositories_recursive_count}</b></td>
63 63 </tr>
64 64 % endfor
65 65 </table>
66 66 </div>
67 67 <div id="group-user-paginator" style="padding: 0px 0px 0px 0px"></div>
68 68 <div style="height: 20px"></div>
69 69 % endif
70 70 <div id="welcome" style="display:none;text-align:center">
71 71 <h1><a href="${h.url('home')}">${c.rhodecode_name} ${c.rhodecode_version}</a></h1>
72 72 </div>
73 73 <%cnt=0%>
74 74 <%namespace name="dt" file="/data_table/_dt_elements.html"/>
75 75 <div class="yui-skin-sam" id="repos_list_wrap"></div>
76 76 <div id="user-paginator" style="padding: 0px 0px 0px 0px"></div>
77 77 </div>
78 78 </div>
79 79
80 80 <script>
81 81 var data = ${c.data|n};
82 82 var myDataSource = new YAHOO.util.DataSource(data);
83 83 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
84 84
85 85 myDataSource.responseSchema = {
86 86 resultsList: "records",
87 87 fields: [
88 88 {key:"menu"},
89 89 {key:"raw_name"},
90 90 {key:"name"},
91 91 {key:"desc"},
92 92 {key:"last_change"},
93 93 {key:"last_changeset"},
94 94 {key:"owner"},
95 95 {key:"atom"},
96 96 ]
97 97 };
98 98 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
99 99 // This is the filter function
100 100 var data = res.results || [],
101 101 filtered = [],
102 102 i,l;
103 103
104 104 if (req) {
105 105 req = req.toLowerCase();
106 106 for (i = 0; i<data.length; i++) {
107 107 var pos = data[i].raw_name.toLowerCase().indexOf(req, ${len(group_name)})
108 108 if (pos != -1) {
109 109 filtered.push(data[i]);
110 110 }
111 111 }
112 112 res.results = filtered;
113 113 }
114 114 YUD.get('repo_count').innerHTML = res.results.length;
115 115 return res;
116 116 }
117 117
118 118 // main table sorting
119 119 var myColumnDefs = [
120 120 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
121 121 {key:"name",label:"${_('Name')}",sortable:true,
122 122 sortOptions: { sortFunction: nameSort }},
123 123 {key:"desc",label:"${_('Description')}",sortable:true},
124 124 {key:"last_change",label:"${_('Last Change')}",sortable:true,
125 125 sortOptions: { sortFunction: ageSort }},
126 126 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
127 127 sortOptions: { sortFunction: revisionSort }},
128 128 {key:"owner",label:"${_('Owner')}",sortable:true},
129 129 {key:"atom",label:"",sortable:false},
130 130 ];
131 131
132 132 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
133 133 sortedBy:{key:"name",dir:"asc"},
134 134 paginator: YUI_paginator(${c.visual.dashboard_items},['user-paginator']),
135 135
136 136 MSG_SORTASC:"${_('Click to sort ascending')}",
137 137 MSG_SORTDESC:"${_('Click to sort descending')}",
138 138 MSG_EMPTY:"${_('No repositories found.')}",
139 139 MSG_ERROR:"${_('Data error.')}",
140 140 MSG_LOADING:"${_('Loading...')}",
141 141 }
142 142 );
143 143 myDataTable.subscribe('postRenderEvent',function(oArgs) {
144 144 tooltip_activate();
145 145 quick_repo_menu();
146 146 });
147 147
148 148 var filterTimeout = null;
149 149
150 150 updateFilter = function () {
151 151 // Reset timeout
152 152 filterTimeout = null;
153 153
154 154 // Reset sort
155 155 var state = myDataTable.getState();
156 156 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
157 157
158 158 // Get filtered data
159 159 myDataSource.sendRequest(YUD.get('q_filter').value,{
160 160 success : myDataTable.onDataReturnInitializeTable,
161 161 failure : myDataTable.onDataReturnInitializeTable,
162 162 scope : myDataTable,
163 163 argument: state
164 164 });
165 165
166 166 };
167 167 YUE.on('q_filter','click',function(){
168 168 if(!YUD.hasClass('q_filter', 'loaded')){
169 169 //TODO: load here full list later to do search within groups
170 170 YUD.addClass('q_filter', 'loaded');
171 171 }
172 172 });
173 173
174 174 YUE.on('q_filter','keyup',function (e) {
175 175 clearTimeout(filterTimeout);
176 176 filterTimeout = setTimeout(updateFilter,600);
177 177 });
178
179 if(YUD.get('q_filter').value) {
180 updateFilter();
181 }
178 182 </script>
@@ -1,339 +1,343 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <%inherit file="/base/base.html"/>
3 3 <%def name="title()">
4 4 ${_('Journal')} &middot; ${c.rhodecode_name}
5 5 </%def>
6 6 <%def name="breadcrumbs()">
7 7 <h5>
8 8 <form id="filter_form">
9 9 <input class="q_filter_box ${'' if c.search_term else 'initial'}" id="j_filter" size="15" type="text" name="filter" value="${c.search_term or _('quick filter...')}"/>
10 10 <span class="tooltip" title="${h.tooltip(h.journal_filter_help())}">?</span>
11 11 <input type='submit' value="${_('filter')}" class="ui-btn" style="padding:0px 2px 0px 2px;margin:0px"/>
12 12 ${_('journal')} - ${ungettext('%s entry', '%s entries', c.journal_pager.item_count) % (c.journal_pager.item_count)}
13 13 </form>
14 14 ${h.end_form()}
15 15 </h5>
16 16 </%def>
17 17 <%def name="page_nav()">
18 18 ${self.menu('journal')}
19 19 </%def>
20 20 <%def name="head_extra()">
21 21 <link href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('ATOM journal feed')}" type="application/atom+xml" />
22 22 <link href="${h.url('journal_rss', api_key=c.rhodecode_user.api_key)}" rel="alternate" title="${_('RSS journal feed')}" type="application/rss+xml" />
23 23 </%def>
24 24 <%def name="main()">
25 25
26 26 <div class="box box-left">
27 27 <!-- box / title -->
28 28 <div class="title">
29 29 ${self.breadcrumbs()}
30 30 <ul class="links">
31 31 <li>
32 32 <span><a id="refresh" href="${h.url('journal')}"><img class="icon" title="${_('Refresh')}" alt="${_('Refresh')}" src="${h.url('/images/icons/arrow_refresh.png')}"/></a></span>
33 33 </li>
34 34 <li>
35 35 <span><a href="${h.url('journal_atom', api_key=c.rhodecode_user.api_key)}"><img class="icon" title="${_('ATOM feed')}" alt="${_('ATOM feed')}" src="${h.url('/images/icons/rss_16.png')}"/></a></span>
36 36 </li>
37 37 </ul>
38 38 </div>
39 39 <div id="journal">${c.journal_data}</div>
40 40 </div>
41 41 <div class="box box-right">
42 42 <!-- box / title -->
43 43
44 44 <div class="title">
45 45 <h5>
46 46 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
47 47 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" placeholder="${_('quick filter...')}" value="" style="display: none"/>
48 48 </h5>
49 49 <ul class="links" style="color:#DADADA">
50 50 <li>
51 51 <span><a id="show_watched" class="link-white current" href="#watched">${_('Watched')}</a> </span>
52 52 </li>
53 53 <li>
54 54 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span>
55 55 </li>
56 56 </ul>
57 57 </div>
58 58
59 59 <!-- end box / title -->
60 60 <div id="my_container" style="display:none">
61 61 <div class="table yui-skin-sam" id="repos_list_wrap"></div>
62 62 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div>
63 63 </div>
64 64
65 65 <div id="watched_container">
66 66 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div>
67 67 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div>
68 68 </div>
69 69 </div>
70 70
71 71 <script type="text/javascript">
72 72
73 73 YUE.on('j_filter','click',function(){
74 74 var jfilter = YUD.get('j_filter');
75 75 if(YUD.hasClass(jfilter, 'initial')){
76 76 jfilter.value = '';
77 77 }
78 78 });
79 79 var fix_j_filter_width = function(len){
80 80 YUD.setStyle(YUD.get('j_filter'),'width',Math.max(80, len*6.50)+'px');
81 81 }
82 82 YUE.on('j_filter','keyup',function(){
83 83 fix_j_filter_width(YUD.get('j_filter').value.length);
84 84 });
85 85 YUE.on('filter_form','submit',function(e){
86 86 YUE.preventDefault(e)
87 87 var val = YUD.get('j_filter').value;
88 88 window.location = "${url.current(filter='__FILTER__')}".replace('__FILTER__',val);
89 89 });
90 90 fix_j_filter_width(YUD.get('j_filter').value.length);
91 91
92 92 YUE.on('refresh','click',function(e){
93 93 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){
94 94 show_more_event();
95 95 tooltip_activate();
96 96 show_changeset_tooltip();
97 97 });
98 98 YUE.preventDefault(e);
99 99 });
100 100
101 101 var show_my = function(e){
102 102 YUD.setStyle('watched_container','display','none');
103 103 YUD.setStyle('my_container','display','');
104 104 YUD.setStyle('q_filter','display','');
105 105 YUD.setStyle('q_filter_watched','display','none');
106 106
107 107 YUD.addClass('show_my', 'current');
108 108 YUD.removeClass('show_watched','current');
109 109
110 110 if(!YUD.hasClass('show_my', 'loaded')){
111 111 table_renderer(${c.data |n});
112 112 YUD.addClass('show_my', 'loaded');
113 113 }
114 114 }
115 115 YUE.on('show_my','click',function(e){
116 116 show_my(e);
117 117 })
118 118 var show_watched = function(e){
119 119 YUD.setStyle('my_container','display','none');
120 120 YUD.setStyle('watched_container','display','');
121 121 YUD.setStyle('q_filter_watched','display','');
122 122 YUD.setStyle('q_filter','display','none');
123 123
124 124 YUD.addClass('show_watched', 'current');
125 125 YUD.removeClass('show_my','current');
126 126 if(!YUD.hasClass('show_watched', 'loaded')){
127 127 watched_renderer(${c.watched_data |n});
128 128 YUD.addClass('show_watched', 'loaded');
129 129 }
130 130
131 131 return
132 132 var nodes = YUQ('#watched_container .watched_repo a');
133 133 var target = 'q_filter';
134 134 var func = function(node){
135 135 return node.parentNode.parentNode;
136 136 }
137 137 q_filter(target,nodes,func);
138 138 }
139 139 YUE.on('show_watched','click',function(e){
140 140 show_watched(e);
141 141 })
142 142 //init watched
143 143 show_watched();
144 144
145 145 var tabs = {
146 146 'watched': show_watched,
147 147 'my': show_my,
148 148 }
149 149 var url = location.href.split('#');
150 150 if (url[1]) {
151 151 //We have a hash
152 152 var tabHash = url[1];
153 153 var func = tabs[tabHash]
154 154 if (func){
155 155 func();
156 156 }
157 157 }
158 158 function watched_renderer(data){
159 159 var myDataSource = new YAHOO.util.DataSource(data);
160 160 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
161 161
162 162 myDataSource.responseSchema = {
163 163 resultsList: "records",
164 164 fields: [
165 165 {key:"menu"},
166 166 {key:"raw_name"},
167 167 {key:"name"},
168 168 {key:"last_changeset"},
169 169 {key:"action"},
170 170 ]
171 171 };
172 172 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
173 173 // This is the filter function
174 174 var data = res.results || [],
175 175 filtered = [],
176 176 i,l;
177 177
178 178 if (req) {
179 179 req = req.toLowerCase();
180 180 for (i = 0; i<data.length; i++) {
181 181 var pos = data[i].raw_name.toLowerCase().indexOf(req)
182 182 if (pos != -1) {
183 183 filtered.push(data[i]);
184 184 }
185 185 }
186 186 res.results = filtered;
187 187 }
188 188 return res;
189 189 }
190 190 // main table sorting
191 191 var myColumnDefs = [
192 192 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
193 193 {key:"name",label:"${_('Name')}",sortable:true,
194 194 sortOptions: { sortFunction: nameSort }},
195 195 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
196 196 sortOptions: { sortFunction: revisionSort }},
197 197 {key:"action",label:"${_('Action')}",sortable:false},
198 198 ];
199 199
200 200 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{
201 201 sortedBy:{key:"name",dir:"asc"},
202 202 paginator: YUI_paginator(25, ['watched-user-paginator']),
203 203
204 204 MSG_SORTASC:"${_('Click to sort ascending')}",
205 205 MSG_SORTDESC:"${_('Click to sort descending')}",
206 206 MSG_EMPTY:"${_('No records found.')}",
207 207 MSG_ERROR:"${_('Data error.')}",
208 208 MSG_LOADING:"${_('Loading...')}",
209 209 }
210 210 );
211 211 myDataTable.subscribe('postRenderEvent',function(oArgs) {
212 212 tooltip_activate();
213 213 quick_repo_menu();
214 214 });
215 215
216 216 var filterTimeout = null;
217 217
218 218 updateFilter = function () {
219 219 // Reset timeout
220 220 filterTimeout = null;
221 221
222 222 // Reset sort
223 223 var state = myDataTable.getState();
224 224 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
225 225
226 226 // Get filtered data
227 227 myDataSource.sendRequest(YUD.get('q_filter_watched').value,{
228 228 success : myDataTable.onDataReturnInitializeTable,
229 229 failure : myDataTable.onDataReturnInitializeTable,
230 230 scope : myDataTable,
231 231 argument: state
232 232 });
233 233
234 234 };
235 235 YUE.on('q_filter_watched','click',function(){
236 236 if(!YUD.hasClass('q_filter_watched', 'loaded')){
237 237 //TODO: load here full list later to do search within groups
238 238 YUD.addClass('q_filter_watched', 'loaded');
239 239 }
240 240 });
241 241
242 242 YUE.on('q_filter_watched','keyup',function (e) {
243 243 clearTimeout(filterTimeout);
244 244 filterTimeout = setTimeout(updateFilter,600);
245 245 });
246 246 }
247 247
248 248 function table_renderer(data){
249 249 var myDataSource = new YAHOO.util.DataSource(data);
250 250 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON;
251 251
252 252 myDataSource.responseSchema = {
253 253 resultsList: "records",
254 254 fields: [
255 255 {key:"menu"},
256 256 {key:"raw_name"},
257 257 {key:"name"},
258 258 {key:"last_changeset"},
259 259 {key:"action"},
260 260 ]
261 261 };
262 262 myDataSource.doBeforeCallback = function(req,raw,res,cb) {
263 263 // This is the filter function
264 264 var data = res.results || [],
265 265 filtered = [],
266 266 i,l;
267 267
268 268 if (req) {
269 269 req = req.toLowerCase();
270 270 for (i = 0; i<data.length; i++) {
271 271 var pos = data[i].raw_name.toLowerCase().indexOf(req)
272 272 if (pos != -1) {
273 273 filtered.push(data[i]);
274 274 }
275 275 }
276 276 res.results = filtered;
277 277 }
278 278 return res;
279 279 }
280 280 // main table sorting
281 281 var myColumnDefs = [
282 282 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"},
283 283 {key:"name",label:"${_('Name')}",sortable:true,
284 284 sortOptions: { sortFunction: nameSort }},
285 285 {key:"last_changeset",label:"${_('Tip')}",sortable:true,
286 286 sortOptions: { sortFunction: revisionSort }},
287 287 {key:"action",label:"${_('Action')}",sortable:false},
288 288 ];
289 289
290 290 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{
291 291 sortedBy:{key:"name",dir:"asc"},
292 292 paginator: YUI_paginator(25, ['user-paginator']),
293 293
294 294 MSG_SORTASC:"${_('Click to sort ascending')}",
295 295 MSG_SORTDESC:"${_('Click to sort descending')}",
296 296 MSG_EMPTY:"${_('No records found.')}",
297 297 MSG_ERROR:"${_('Data error.')}",
298 298 MSG_LOADING:"${_('Loading...')}",
299 299 }
300 300 );
301 301 myDataTable.subscribe('postRenderEvent',function(oArgs) {
302 302 tooltip_activate();
303 303 quick_repo_menu();
304 304 });
305 305
306 306 var filterTimeout = null;
307 307
308 308 updateFilter = function () {
309 309 // Reset timeout
310 310 filterTimeout = null;
311 311
312 312 // Reset sort
313 313 var state = myDataTable.getState();
314 314 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC};
315 315
316 316 // Get filtered data
317 317 myDataSource.sendRequest(YUD.get('q_filter').value,{
318 318 success : myDataTable.onDataReturnInitializeTable,
319 319 failure : myDataTable.onDataReturnInitializeTable,
320 320 scope : myDataTable,
321 321 argument: state
322 322 });
323 323
324 324 };
325 325 YUE.on('q_filter','click',function(){
326 326 if(!YUD.hasClass('q_filter', 'loaded')){
327 327 //TODO: load here full list later to do search within groups
328 328 YUD.addClass('q_filter', 'loaded');
329 329 }
330 330 });
331 331
332 332 YUE.on('q_filter','keyup',function (e) {
333 333 clearTimeout(filterTimeout);
334 334 filterTimeout = setTimeout(updateFilter,600);
335 335 });
336
337 if(YUD.get('q_filter').value) {
338 updateFilter();
339 }
336 340 }
337 341
338 342 </script>
339 343 </%def>
General Comments 0
You need to be logged in to leave comments. Login now