[dw-free] sort users alphabetically on Manage Subscription Filters page
[commit: http://hg.dwscoalition.org/dw-free/rev/26306c6a8be1]
http://bugs.dwscoalition.org/show_bug.cgi?id=1791
Sort users by username, and also add rudimentary 'show only' dropdown so you
can show only communities, only feeds, only people.
Patch by
mark.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1791
Sort users by username, and also add rudimentary 'show only' dropdown so you
can show only communities, only feeds, only people.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- htdocs/js/subfilters.js
- htdocs/manage/subscriptions/filters.bml
-------------------------------------------------------------------------------- diff -r 797ffa6a96fb -r 26306c6a8be1 htdocs/js/subfilters.js --- a/htdocs/js/subfilters.js Sun Sep 13 16:28:56 2009 +0800 +++ b/htdocs/js/subfilters.js Sun Sep 13 23:58:51 2009 +0000 @@ -82,11 +82,22 @@ var cfSelectedFilterId = null, cfCurrent var cfSelectedFilterId = null, cfCurrentUserid = null; var cfSubs = {}, cfTags = {}, cfFilters = {}; +var cfTypeFilter = ''; +var cfSubsSorted = []; + // [ total count, selected ] var cfTagCount = [ 0, 0 ]; // current save timer var cfTimerId = null, cfSaveTicksLeft = 0; + + +function cfShowTypes( newtype ) { + if ( cfTypeFilter == newtype ) + return; + cfTypeFilter = newtype; + cfPopulateLists(); +} function cfPopulateLists() { @@ -107,11 +118,18 @@ function cfPopulateLists() { var filt = cfFilters[cfSelectedFilterId]; - // FIXME: ...sort the lists, plz - //cfSubs.sort( function( a, b ) { return ( a.username < b.username ) ? -1 : ( a.username > b.username ) ? 1 : 0; } ); + // creates a sorted list of userids + cfSubsSorted = []; + for ( i in cfSubs ) + if ( cfTypeFilter == '' || cfSubs[i].journaltype == cfTypeFilter ) + cfSubsSorted.push( i ); + cfSubsSorted.sort( function( a, b ) { + return ( cfSubs[a].username < cfSubs[b].username ) ? -1 : ( cfSubs[a].username > cfSubs[b].username ) ? 1 : 0; + } ); var inOpts = '', outOpts = ''; - for ( i in cfSubs ) { + for ( idx in cfSubsSorted ) { + var i = cfSubsSorted[idx]; var isIn = false; for ( j in filt.members ) { @@ -581,6 +599,7 @@ DW.whenPageLoaded( function() { $('#cf-new').bind( 'click', function(e) { cfNewFilter(); } ); $('#cf-rename').bind( 'click', function(e) { cfRenameFilter(); } ); $('#cf-delete').bind( 'click', function(e) { cfDeleteFilter(); } ); + $('#cf-showtypes').bind( 'change', function(e) { cfShowTypes( $(e.target).val() ); } ); // if the user is paid, we bind these. note that even if someone goes through the // trouble of hacking up the form and submitting data, the server won't actually give diff -r 797ffa6a96fb -r 26306c6a8be1 htdocs/manage/subscriptions/filters.bml --- a/htdocs/manage/subscriptions/filters.bml Sun Sep 13 16:28:56 2009 +0800 +++ b/htdocs/manage/subscriptions/filters.bml Sun Sep 13 23:58:51 2009 +0000 @@ -72,19 +72,27 @@ body<= </div> <div id='cf-edit'> - <div id='cf-notin'> - Not in filter:<br /> - <select id='cf-notin-list' size='20' multiple></select><br /> - <div id='cf-add-box'> - <input id='cf-add-btn' type='button' value='Add >>' /> + <div id='cf-members'> + <div id='cf-notin'> + Not in filter:<br /> + <select id='cf-notin-list' size='20' multiple></select><br /> + <div id='cf-add-box'> + <input id='cf-add-btn' type='button' value='Add >>' /> + <select id='cf-showtypes'> + <option value=''>All Types</option> + <option value='C'>Communities</option> + <option value='Y'>Feeds</option> + <option value='P'>People</option> + </select> + </div> </div> - </div> - - <div id='cf-in'> - In filter:<br /> - <select id='cf-in-list' size='20' multiple></select><br /> - <div id='cf-del-box'> - <input id='cf-del-btn' type='button' value='<< Remove' /> + + <div id='cf-in'> + In filter:<br /> + <select id='cf-in-list' size='20' multiple></select><br /> + <div id='cf-del-box'> + <input id='cf-del-btn' type='button' value='<< Remove' /> + </div> </div> </div> --------------------------------------------------------------------------------
no subject