Mercurial > kallithea
changeset 1782:eaf09acf6872 beta
added sorting to bookmarks tags and branches
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sat, 17 Dec 2011 21:31:54 +0200 |
parents | 089c81cf04d9 |
children | dde0ef0d886f |
files | rhodecode/public/js/rhodecode.js rhodecode/templates/bookmarks/bookmarks.html rhodecode/templates/bookmarks/bookmarks_data.html rhodecode/templates/branches/branches.html rhodecode/templates/branches/branches_data.html rhodecode/templates/tags/tags.html rhodecode/templates/tags/tags_data.html |
diffstat | 7 files changed, 173 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/rhodecode/public/js/rhodecode.js Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/public/js/rhodecode.js Sat Dec 17 21:31:54 2011 +0200 @@ -646,6 +646,12 @@ var name = node.firstElementChild.children[1].innerHTML; return name } +var get_date = function(node){ + console.log(node.firstElementChild) + var date_ = node.firstElementChild.innerHTML; + return date_ +} + var revisionSort = function(a, b, desc, field) { var a_ = fromHTML(a.getData(field)); @@ -692,4 +698,16 @@ var comp = YAHOO.util.Sort.compare; var compState = comp(a_, b_, desc); return compState; +}; +var dateSort = function(a, b, desc, field) { + var a_ = fromHTML(a.getData(field)); + var b_ = fromHTML(b.getData(field)); + + // extract name from table + a_ = get_date(a_) + b_ = get_date(b_) + + var comp = YAHOO.util.Sort.compare; + var compState = comp(a_, b_, desc); + return compState; }; \ No newline at end of file
--- a/rhodecode/templates/bookmarks/bookmarks.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/bookmarks/bookmarks.html Sat Dec 17 21:31:54 2011 +0200 @@ -30,11 +30,49 @@ </div> </div> <script type="text/javascript"> -var nodes = YUQ('div.table tr td .logtags .tagtag a'); -var target = 'q_filter_bookmarks'; -var func = function(node){ - return node.parentNode.parentNode.parentNode.parentNode; -} -q_filter(target,nodes,func); + +// main table sorting +var myColumnDefs = [ + {key:"name",label:"${_('Name')}",sortable:true}, + {key:"date",label:"${_('Date')}",sortable:true, + sortOptions: { sortFunction: dateSort }}, + {key:"author",label:"${_('Author')}",sortable:true}, + {key:"revision",label:"${_('Revision')}",sortable:true, + sortOptions: { sortFunction: revisionSort }}, +]; + +var myDataSource = new YAHOO.util.DataSource(YUD.get("bookmarks_data")); + +myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; + +myDataSource.responseSchema = { + fields: [ + {key:"name"}, + {key:"date"}, + {key:"author"}, + {key:"revision"}, + ] +}; + +var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource, + { + sortedBy:{key:"name",dir:"asc"}, + MSG_SORTASC:"${_('Click to sort ascending')}", + MSG_SORTDESC:"${_('Click to sort descending')}", + MSG_EMPTY:"${_('No records found.')}", + MSG_ERROR:"${_('Data error.')}", + MSG_LOADING:"${_('Loading...')}", + } +); +myDataTable.subscribe('postRenderEvent',function(oArgs) { + tooltip_activate(); + var func = function(node){ + return node.parentNode.parentNode.parentNode.parentNode.parentNode; + } + q_filter('q_filter_bookmarks',YUQ('div.table tr td .logbooks .bookbook a'),func); +}); + </script> + + </%def> \ No newline at end of file
--- a/rhodecode/templates/bookmarks/bookmarks_data.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/bookmarks/bookmarks_data.html Sat Dec 17 21:31:54 2011 +0200 @@ -1,11 +1,14 @@ -%if c.repo_bookmarks: - <table class="table_disp"> +%if c.repo_bookmarks: + <div id="table_wrap" class="yui-skin-sam"> + <table id="bookmarks_data"> + <thead> <tr> - <th class="left">${_('name')}</th> - <th class="left">${_('date')}</th> - <th class="left">${_('author')}</th> - <th class="left">${_('revision')}</th> + <th class="left">${_('Name')}</th> + <th class="left">${_('Date')}</th> + <th class="left">${_('Author')}</th> + <th class="left">${_('Revision')}</th> </tr> + </thead> %for cnt,book in enumerate(c.repo_bookmarks.items()): <tr class="parity${cnt%2}"> <td> @@ -24,6 +27,7 @@ </tr> %endfor </table> + </div> %else: ${_('There are no bookmarks yet')} %endif \ No newline at end of file
--- a/rhodecode/templates/branches/branches.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/branches/branches.html Sat Dec 17 21:31:54 2011 +0200 @@ -30,11 +30,48 @@ </div> </div> <script type="text/javascript"> -var nodes = YUQ('div.table tr td .logtags .branchtag a'); -var target = 'q_filter_branches'; -var func = function(node){ - return node.parentNode.parentNode.parentNode.parentNode; -} -q_filter(target,nodes,func); + +// main table sorting +var myColumnDefs = [ + {key:"name",label:"${_('Name')}",sortable:true}, + {key:"date",label:"${_('Date')}",sortable:true, + sortOptions: { sortFunction: dateSort }}, + {key:"author",label:"${_('Author')}",sortable:true}, + {key:"revision",label:"${_('Revision')}",sortable:true, + sortOptions: { sortFunction: revisionSort }}, +]; + +var myDataSource = new YAHOO.util.DataSource(YUD.get("branches_data")); + +myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; + +myDataSource.responseSchema = { + fields: [ + {key:"name"}, + {key:"date"}, + {key:"author"}, + {key:"revision"}, + ] +}; + +var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource, + { + sortedBy:{key:"name",dir:"asc"}, + MSG_SORTASC:"${_('Click to sort ascending')}", + MSG_SORTDESC:"${_('Click to sort descending')}", + MSG_EMPTY:"${_('No records found.')}", + MSG_ERROR:"${_('Data error.')}", + MSG_LOADING:"${_('Loading...')}", + } +); +myDataTable.subscribe('postRenderEvent',function(oArgs) { + tooltip_activate(); + var func = function(node){ + return node.parentNode.parentNode.parentNode.parentNode.parentNode; + } + q_filter('q_filter_branches',YUQ('div.table tr td .logtags .branchtag a'),func); +}); + </script> + </%def> \ No newline at end of file
--- a/rhodecode/templates/branches/branches_data.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/branches/branches_data.html Sat Dec 17 21:31:54 2011 +0200 @@ -1,11 +1,14 @@ %if c.repo_branches: - <table class="table_disp"> + <div id="table_wrap" class="yui-skin-sam"> + <table id="branches_data"> + <thead> <tr> <th class="left">${_('name')}</th> <th class="left">${_('date')}</th> <th class="left">${_('author')}</th> <th class="left">${_('revision')}</th> </tr> + </thead> %for cnt,branch in enumerate(c.repo_branches.items()): <tr class="parity${cnt%2}"> <td> @@ -43,6 +46,7 @@ %endfor %endif </table> + </div> %else: ${_('There are no branches yet')} %endif \ No newline at end of file
--- a/rhodecode/templates/tags/tags.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/tags/tags.html Sat Dec 17 21:31:54 2011 +0200 @@ -30,11 +30,47 @@ </div> </div> <script type="text/javascript"> -var nodes = YUQ('div.table tr td .logtags .tagtag a'); -var target = 'q_filter_tags'; -var func = function(node){ - return node.parentNode.parentNode.parentNode.parentNode; -} -q_filter(target,nodes,func); + +// main table sorting +var myColumnDefs = [ + {key:"name",label:"${_('Name')}",sortable:true}, + {key:"date",label:"${_('Date')}",sortable:true, + sortOptions: { sortFunction: dateSort }}, + {key:"author",label:"${_('Author')}",sortable:true}, + {key:"revision",label:"${_('Revision')}",sortable:true, + sortOptions: { sortFunction: revisionSort }}, +]; + +var myDataSource = new YAHOO.util.DataSource(YUD.get("tags_data")); + +myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; + +myDataSource.responseSchema = { + fields: [ + {key:"name"}, + {key:"date"}, + {key:"author"}, + {key:"revision"}, + ] +}; + +var myDataTable = new YAHOO.widget.DataTable("table_wrap", myColumnDefs, myDataSource, + { + sortedBy:{key:"name",dir:"asc"}, + MSG_SORTASC:"${_('Click to sort ascending')}", + MSG_SORTDESC:"${_('Click to sort descending')}", + MSG_EMPTY:"${_('No records found.')}", + MSG_ERROR:"${_('Data error.')}", + MSG_LOADING:"${_('Loading...')}", + } +); +myDataTable.subscribe('postRenderEvent',function(oArgs) { + tooltip_activate(); + var func = function(node){ + return node.parentNode.parentNode.parentNode.parentNode.parentNode; + } + q_filter('q_filter_tags',YUQ('div.table tr td .logtags .tagtag a'),func); +}); + </script> </%def> \ No newline at end of file
--- a/rhodecode/templates/tags/tags_data.html Sat Dec 17 16:35:11 2011 +0200 +++ b/rhodecode/templates/tags/tags_data.html Sat Dec 17 21:31:54 2011 +0200 @@ -1,11 +1,14 @@ -%if c.repo_tags: - <table class="table_disp"> +%if c.repo_tags: + <div id="table_wrap" class="yui-skin-sam"> + <table id="tags_data"> + <thead> <tr> - <th class="left">${_('name')}</th> - <th class="left">${_('date')}</th> - <th class="left">${_('author')}</th> - <th class="left">${_('revision')}</th> + <th class="left">${_('Name')}</th> + <th class="left">${_('Date')}</th> + <th class="left">${_('Author')}</th> + <th class="left">${_('Revision')}</th> </tr> + </thead> %for cnt,tag in enumerate(c.repo_tags.items()): <tr class="parity${cnt%2}"> <td> @@ -22,9 +25,10 @@ <pre><a href="${h.url('files_home',repo_name=c.repo_name,revision=tag[1].raw_id)}">r${tag[1].revision}:${h.short_id(tag[1].raw_id)}</a></pre> </div> </td> - </tr> + </tr> %endfor </table> + </div> %else: ${_('There are no tags yet')} %endif \ No newline at end of file