mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2009-09-13 11:58 pm

[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 [staff profile] mark.

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 &gt;&gt;' />
+    <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 &gt;&gt;' />
+                <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='&lt;&lt; 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='&lt;&lt; Remove' />
+            </div>
         </div>
     </div>
 
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org