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