Mercurial > kallithea
comparison rhodecode/templates/journal/journal.html @ 3154:0226b6d6b2b5 beta
Use common function for generation of grid data
- admin grid now has dedicated edit button, and uses changeset_cache
- some small improvements to grid
- all other datatables use this
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 09 Jan 2013 01:59:43 +0100 |
parents | 68f9c216377d |
children | 2fb94c52e20e |
comparison
equal
deleted
inserted
replaced
3153:8046d1979674 | 3154:0226b6d6b2b5 |
---|---|
41 </div> | 41 </div> |
42 <div id="journal">${c.journal_data}</div> | 42 <div id="journal">${c.journal_data}</div> |
43 </div> | 43 </div> |
44 <div class="box box-right"> | 44 <div class="box box-right"> |
45 <!-- box / title --> | 45 <!-- box / title --> |
46 | |
46 <div class="title"> | 47 <div class="title"> |
47 <h5> | 48 <h5> |
48 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}"/> | 49 <input class="q_filter_box" id="q_filter" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/> |
49 <a id="show_watched" class="link-white" href="#watched">${_('Watched')}</a> / <a id="show_my" class="link-white" href="#my">${_('My repos')}</a> | 50 <input class="q_filter_box" id="q_filter_watched" size="15" type="text" name="filter" value="${_('quick filter...')}" style="display: none"/> |
50 </h5> | 51 </h5> |
51 %if h.HasPermissionAny('hg.admin','hg.create.repository')(): | 52 <ul class="links" style="color:#DADADA"> |
52 <ul class="links"> | |
53 <li> | 53 <li> |
54 <span>${h.link_to(_('ADD'),h.url('admin_settings_create_repository'))}</span> | 54 <span><a id="show_watched" class="link-white current" href="#watched">${_('Watched')}</a> </span> |
55 </li> | 55 </li> |
56 <li> | |
57 <span><a id="show_my" class="link-white" href="#my">${_('My repos')}</a> </span> | |
58 </li> | |
59 %if h.HasPermissionAny('hg.admin','hg.create.repository')(): | |
60 <li> | |
61 <span>${h.link_to(_('Add repo'),h.url('admin_settings_create_repository'))}</span> | |
62 </li> | |
63 %endif | |
56 </ul> | 64 </ul> |
57 %endif | 65 </div> |
66 | |
67 <!-- end box / title --> | |
68 <div id="my_container" style="display:none"> | |
69 <div class="table yui-skin-sam" id="repos_list_wrap"></div> | |
70 <div id="user-paginator" style="padding: 0px 0px 0px 20px"></div> | |
58 </div> | 71 </div> |
59 <!-- end box / title --> | 72 |
60 <div id="my" class="table" style="display:none"> | 73 <div id="watched_container"> |
61 ## loaded via AJAX | 74 <div class="table yui-skin-sam" id="watched_repos_list_wrap"></div> |
62 ${_('Loading...')} | 75 <div id="watched-user-paginator" style="padding: 0px 0px 0px 20px"></div> |
63 </div> | |
64 | |
65 <div id="watched" class="table"> | |
66 %if c.following: | |
67 <table> | |
68 <thead> | |
69 <tr> | |
70 <th class="left">${_('Name')}</th> | |
71 </thead> | |
72 <tbody> | |
73 %for entry in c.following: | |
74 <tr> | |
75 <td> | |
76 %if entry.follows_user_id: | |
77 <img title="${_('following user')}" alt="${_('user')}" src="${h.url('/images/icons/user.png')}"/> | |
78 ${entry.follows_user.full_contact} | |
79 %endif | |
80 | |
81 %if entry.follows_repo_id: | |
82 <div style="float:right;padding-right:5px"> | |
83 <span id="follow_toggle_${entry.follows_repository.repo_id}" class="following" title="${_('Stop following this repository')}" | |
84 onclick="javascript:toggleFollowingRepo(this,${entry.follows_repository.repo_id},'${str(h.get_token())}')"> | |
85 </span> | |
86 </div> | |
87 | |
88 %if h.is_hg(entry.follows_repository): | |
89 <img class="icon" title="${_('Mercurial repository')}" alt="${_('Mercurial repository')}" src="${h.url('/images/icons/hgicon.png')}"/> | |
90 %elif h.is_git(entry.follows_repository): | |
91 <img class="icon" title="${_('Git repository')}" alt="${_('Git repository')}" src="${h.url('/images/icons/giticon.png')}"/> | |
92 %endif | |
93 | |
94 %if entry.follows_repository.private and c.visual.show_private_icon: | |
95 <img class="icon" title="${_('private repository')}" alt="${_('private repository')}" src="${h.url('/images/icons/lock.png')}"/> | |
96 %elif not entry.follows_repository.private and c.visual.show_public_icon: | |
97 <img class="icon" title="${_('public repository')}" alt="${_('public repository')}" src="${h.url('/images/icons/lock_open.png')}"/> | |
98 %endif | |
99 <span class="watched_repo"> | |
100 ${h.link_to(entry.follows_repository.repo_name,h.url('summary_home',repo_name=entry.follows_repository.repo_name))} | |
101 </span> | |
102 %endif | |
103 </td> | |
104 </tr> | |
105 %endfor | |
106 </tbody> | |
107 </table> | |
108 %else: | |
109 <div style="padding:5px 0px 10px 0px;"> | |
110 ${_('You are not following any users or repositories')} | |
111 </div> | |
112 %endif | |
113 </div> | 76 </div> |
114 </div> | 77 </div> |
115 | 78 |
116 <script type="text/javascript"> | 79 <script type="text/javascript"> |
117 | 80 |
132 var val = YUD.get('j_filter').value; | 95 var val = YUD.get('j_filter').value; |
133 window.location = "${url.current(filter='__FILTER__')}".replace('__FILTER__',val); | 96 window.location = "${url.current(filter='__FILTER__')}".replace('__FILTER__',val); |
134 }); | 97 }); |
135 fix_j_filter_width(YUD.get('j_filter').value.length); | 98 fix_j_filter_width(YUD.get('j_filter').value.length); |
136 | 99 |
100 YUE.on('refresh','click',function(e){ | |
101 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){ | |
102 show_more_event(); | |
103 tooltip_activate(); | |
104 show_changeset_tooltip(); | |
105 }); | |
106 YUE.preventDefault(e); | |
107 }); | |
108 | |
137 var show_my = function(e){ | 109 var show_my = function(e){ |
138 YUD.setStyle('watched','display','none'); | 110 YUD.setStyle('watched_container','display','none'); |
139 YUD.setStyle('my','display',''); | 111 YUD.setStyle('my_container','display',''); |
140 | 112 YUD.setStyle('q_filter','display',''); |
141 var url = "${h.url('admin_settings_my_repos')}"; | 113 YUD.setStyle('q_filter_watched','display','none'); |
142 ypjax(url, 'my', function(){ | 114 |
143 tooltip_activate(); | 115 YUD.addClass('show_my', 'current'); |
144 quick_repo_menu(); | 116 YUD.removeClass('show_watched','current'); |
145 var nodes = YUQ('#my tr td a.repo_name'); | 117 |
146 var func = function(node){ | 118 if(!YUD.hasClass('show_my', 'loaded')){ |
147 return node.parentNode.parentNode.parentNode; | 119 table_renderer(${c.data |n}); |
148 } | 120 YUD.addClass('show_my', 'loaded'); |
149 q_filter('q_filter',nodes,func); | 121 } |
150 }); | |
151 | |
152 } | 122 } |
153 YUE.on('show_my','click',function(e){ | 123 YUE.on('show_my','click',function(e){ |
154 show_my(e); | 124 show_my(e); |
155 }) | 125 }) |
156 var show_watched = function(e){ | 126 var show_watched = function(e){ |
157 YUD.setStyle('my','display','none'); | 127 YUD.setStyle('my_container','display','none'); |
158 YUD.setStyle('watched','display',''); | 128 YUD.setStyle('watched_container','display',''); |
159 var nodes = YUQ('#watched .watched_repo a'); | 129 YUD.setStyle('q_filter_watched','display',''); |
130 YUD.setStyle('q_filter','display','none'); | |
131 | |
132 YUD.addClass('show_watched', 'current'); | |
133 YUD.removeClass('show_my','current'); | |
134 if(!YUD.hasClass('show_watched', 'loaded')){ | |
135 watched_renderer(${c.watched_data |n}); | |
136 YUD.addClass('show_watched', 'loaded'); | |
137 } | |
138 | |
139 return | |
140 var nodes = YUQ('#watched_container .watched_repo a'); | |
160 var target = 'q_filter'; | 141 var target = 'q_filter'; |
161 var func = function(node){ | 142 var func = function(node){ |
162 return node.parentNode.parentNode; | 143 return node.parentNode.parentNode; |
163 } | 144 } |
164 q_filter(target,nodes,func); | 145 q_filter(target,nodes,func); |
180 var func = tabs[tabHash] | 161 var func = tabs[tabHash] |
181 if (func){ | 162 if (func){ |
182 func(); | 163 func(); |
183 } | 164 } |
184 } | 165 } |
185 | 166 function watched_renderer(data){ |
186 YUE.on('refresh','click',function(e){ | 167 var myDataSource = new YAHOO.util.DataSource(data); |
187 ypjax("${h.url.current(filter=c.search_term)}","journal",function(){ | 168 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; |
188 show_more_event(); | 169 |
189 tooltip_activate(); | 170 myDataSource.responseSchema = { |
190 show_changeset_tooltip(); | 171 resultsList: "records", |
191 }); | 172 fields: [ |
192 YUE.preventDefault(e); | 173 {key:"menu"}, |
193 }); | 174 {key:"raw_name"}, |
194 | 175 {key:"name"}, |
195 | 176 {key:"last_changeset"}, |
196 // main table sorting | 177 {key:"action"}, |
197 var myColumnDefs = [ | 178 ] |
198 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"}, | 179 }; |
199 {key:"name",label:"${_('Name')}",sortable:true, | 180 myDataSource.doBeforeCallback = function(req,raw,res,cb) { |
200 sortOptions: { sortFunction: nameSort }}, | 181 // This is the filter function |
201 {key:"tip",label:"${_('Tip')}",sortable:true, | 182 var data = res.results || [], |
202 sortOptions: { sortFunction: revisionSort }}, | 183 filtered = [], |
203 {key:"action1",label:"",sortable:false}, | 184 i,l; |
204 {key:"action2",label:"",sortable:false}, | 185 |
205 ]; | 186 if (req) { |
206 | 187 req = req.toLowerCase(); |
207 var myDataSource = new YAHOO.util.DataSource(YUD.get("repos_list")); | 188 for (i = 0; i<data.length; i++) { |
208 | 189 var pos = data[i].raw_name.toLowerCase().indexOf(req) |
209 myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; | 190 if (pos != -1) { |
210 | 191 filtered.push(data[i]); |
211 myDataSource.responseSchema = { | 192 } |
212 fields: [ | 193 } |
213 {key:"menu"}, | 194 res.results = filtered; |
214 {key:"name"}, | |
215 {key:"tip"}, | |
216 {key:"action1"}, | |
217 {key:"action2"} | |
218 ] | |
219 }; | |
220 | |
221 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource, | |
222 { | |
223 sortedBy:{key:"name",dir:"asc"}, | |
224 MSG_SORTASC:"${_('Click to sort ascending')}", | |
225 MSG_SORTDESC:"${_('Click to sort descending')}", | |
226 MSG_EMPTY:"${_('No records found.')}", | |
227 MSG_ERROR:"${_('Data error.')}", | |
228 MSG_LOADING:"${_('Loading...')}", | |
229 } | 195 } |
230 ); | 196 return res; |
231 myDataTable.subscribe('postRenderEvent',function(oArgs) { | 197 } |
232 tooltip_activate(); | 198 // main table sorting |
233 quick_repo_menu(); | 199 var myColumnDefs = [ |
234 var func = function(node){ | 200 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"}, |
235 return node.parentNode.parentNode.parentNode.parentNode; | 201 {key:"name",label:"${_('Name')}",sortable:true, |
236 } | 202 sortOptions: { sortFunction: nameSort }}, |
237 q_filter('q_filter',YUQ('#my tr td a.repo_name'),func); | 203 {key:"last_changeset",label:"${_('Tip')}",sortable:true, |
238 }); | 204 sortOptions: { sortFunction: revisionSort }}, |
239 | 205 {key:"action",label:"${_('Action')}",sortable:false}, |
206 ]; | |
207 | |
208 var myDataTable = new YAHOO.widget.DataTable("watched_repos_list_wrap", myColumnDefs, myDataSource,{ | |
209 sortedBy:{key:"name",dir:"asc"}, | |
210 paginator: new YAHOO.widget.Paginator({ | |
211 rowsPerPage: 25, | |
212 alwaysVisible: false, | |
213 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", | |
214 pageLinks: 5, | |
215 containerClass: 'pagination-wh', | |
216 currentPageClass: 'pager_curpage', | |
217 pageLinkClass: 'pager_link', | |
218 nextPageLinkLabel: '>', | |
219 previousPageLinkLabel: '<', | |
220 firstPageLinkLabel: '<<', | |
221 lastPageLinkLabel: '>>', | |
222 containers:['watched-user-paginator'] | |
223 }), | |
224 | |
225 MSG_SORTASC:"${_('Click to sort ascending')}", | |
226 MSG_SORTDESC:"${_('Click to sort descending')}", | |
227 MSG_EMPTY:"${_('No records found.')}", | |
228 MSG_ERROR:"${_('Data error.')}", | |
229 MSG_LOADING:"${_('Loading...')}", | |
230 } | |
231 ); | |
232 myDataTable.subscribe('postRenderEvent',function(oArgs) { | |
233 tooltip_activate(); | |
234 quick_repo_menu(); | |
235 }); | |
236 | |
237 var filterTimeout = null; | |
238 | |
239 updateFilter = function () { | |
240 // Reset timeout | |
241 filterTimeout = null; | |
242 | |
243 // Reset sort | |
244 var state = myDataTable.getState(); | |
245 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC}; | |
246 | |
247 // Get filtered data | |
248 myDataSource.sendRequest(YUD.get('q_filter_watched').value,{ | |
249 success : myDataTable.onDataReturnInitializeTable, | |
250 failure : myDataTable.onDataReturnInitializeTable, | |
251 scope : myDataTable, | |
252 argument: state | |
253 }); | |
254 | |
255 }; | |
256 YUE.on('q_filter_watched','click',function(){ | |
257 if(!YUD.hasClass('q_filter_watched', 'loaded')){ | |
258 YUD.get('q_filter_watched').value = ''; | |
259 //TODO: load here full list later to do search within groups | |
260 YUD.addClass('q_filter_watched', 'loaded'); | |
261 } | |
262 }); | |
263 | |
264 YUE.on('q_filter_watched','keyup',function (e) { | |
265 clearTimeout(filterTimeout); | |
266 filterTimeout = setTimeout(updateFilter,600); | |
267 }); | |
268 } | |
269 | |
270 function table_renderer(data){ | |
271 var myDataSource = new YAHOO.util.DataSource(data); | |
272 myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSON; | |
273 | |
274 myDataSource.responseSchema = { | |
275 resultsList: "records", | |
276 fields: [ | |
277 {key:"menu"}, | |
278 {key:"raw_name"}, | |
279 {key:"name"}, | |
280 {key:"last_changeset"}, | |
281 {key:"action"}, | |
282 ] | |
283 }; | |
284 myDataSource.doBeforeCallback = function(req,raw,res,cb) { | |
285 // This is the filter function | |
286 var data = res.results || [], | |
287 filtered = [], | |
288 i,l; | |
289 | |
290 if (req) { | |
291 req = req.toLowerCase(); | |
292 for (i = 0; i<data.length; i++) { | |
293 var pos = data[i].raw_name.toLowerCase().indexOf(req) | |
294 if (pos != -1) { | |
295 filtered.push(data[i]); | |
296 } | |
297 } | |
298 res.results = filtered; | |
299 } | |
300 return res; | |
301 } | |
302 // main table sorting | |
303 var myColumnDefs = [ | |
304 {key:"menu",label:"",sortable:false,className:"quick_repo_menu hidden"}, | |
305 {key:"name",label:"${_('Name')}",sortable:true, | |
306 sortOptions: { sortFunction: nameSort }}, | |
307 {key:"last_changeset",label:"${_('Tip')}",sortable:true, | |
308 sortOptions: { sortFunction: revisionSort }}, | |
309 {key:"action",label:"${_('Action')}",sortable:false}, | |
310 ]; | |
311 | |
312 var myDataTable = new YAHOO.widget.DataTable("repos_list_wrap", myColumnDefs, myDataSource,{ | |
313 sortedBy:{key:"name",dir:"asc"}, | |
314 paginator: new YAHOO.widget.Paginator({ | |
315 rowsPerPage: 25, | |
316 alwaysVisible: false, | |
317 template : "{PreviousPageLink} {FirstPageLink} {PageLinks} {LastPageLink} {NextPageLink}", | |
318 pageLinks: 5, | |
319 containerClass: 'pagination-wh', | |
320 currentPageClass: 'pager_curpage', | |
321 pageLinkClass: 'pager_link', | |
322 nextPageLinkLabel: '>', | |
323 previousPageLinkLabel: '<', | |
324 firstPageLinkLabel: '<<', | |
325 lastPageLinkLabel: '>>', | |
326 containers:['user-paginator'] | |
327 }), | |
328 | |
329 MSG_SORTASC:"${_('Click to sort ascending')}", | |
330 MSG_SORTDESC:"${_('Click to sort descending')}", | |
331 MSG_EMPTY:"${_('No records found.')}", | |
332 MSG_ERROR:"${_('Data error.')}", | |
333 MSG_LOADING:"${_('Loading...')}", | |
334 } | |
335 ); | |
336 myDataTable.subscribe('postRenderEvent',function(oArgs) { | |
337 tooltip_activate(); | |
338 quick_repo_menu(); | |
339 }); | |
340 | |
341 var filterTimeout = null; | |
342 | |
343 updateFilter = function () { | |
344 // Reset timeout | |
345 filterTimeout = null; | |
346 | |
347 // Reset sort | |
348 var state = myDataTable.getState(); | |
349 state.sortedBy = {key:'name', dir:YAHOO.widget.DataTable.CLASS_ASC}; | |
350 | |
351 // Get filtered data | |
352 myDataSource.sendRequest(YUD.get('q_filter').value,{ | |
353 success : myDataTable.onDataReturnInitializeTable, | |
354 failure : myDataTable.onDataReturnInitializeTable, | |
355 scope : myDataTable, | |
356 argument: state | |
357 }); | |
358 | |
359 }; | |
360 YUE.on('q_filter','click',function(){ | |
361 if(!YUD.hasClass('q_filter', 'loaded')){ | |
362 YUD.get('q_filter').value = ''; | |
363 //TODO: load here full list later to do search within groups | |
364 YUD.addClass('q_filter', 'loaded'); | |
365 } | |
366 }); | |
367 | |
368 YUE.on('q_filter','keyup',function (e) { | |
369 clearTimeout(filterTimeout); | |
370 filterTimeout = setTimeout(updateFilter,600); | |
371 }); | |
372 } | |
373 | |
240 </script> | 374 </script> |
241 </%def> | 375 </%def> |