fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-04-20 09:44 am

[dw-free] Unsubscribe from multiple notifications

[commit: http://hg.dwscoalition.org/dw-free/rev/2324d3e50a3b]

http://bugs.dwscoalition.org/show_bug.cgi?id=1683

AJAX-y one-click deletion of subscriptions; no longer need to reload the
page each time we delete a subscription. (For multiple delete if you have JS
disabled, you can also uncheck subscriptions, making them inactive, then
delete all inactive subs -- feature added in a previous bug)

Patch by [personal profile] yvi.

Files modified:
  • cgi-bin/weblib.pl
  • htdocs/manage/settings/index.bml
--------------------------------------------------------------------------------
diff -r 9aeea4fde8d4 -r 2324d3e50a3b cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Tue Apr 20 09:43:15 2010 +0000
+++ b/cgi-bin/weblib.pl	Tue Apr 20 02:49:34 2010 -0700
@@ -3403,9 +3403,13 @@ sub subscribe_interface {
 
             if ($is_tracking_category && ! $pending_sub->pending) {
                 my $subid = $pending_sub->id;
+                my $auth_token = $u->ajax_auth_token( "/__rpc_esn_subs",
+                    subid => $subid,
+                    action => 'delsub'
+                );
                 my $deletesub_url = $settings_page ? "$LJ::SITEROOT/manage/settings/?cat=notifications&deletesub_$subid=1" : "?deletesub_$subid=1";
                 $cat_html .= qq {
-                    <a href='$deletesub_url'><img src="$LJ::IMGPREFIX/portal/btn_del.gif" alt="Delete"/></a>
+                    <a href='$deletesub_url' class='delete-button' subid=$subid auth_token=$auth_token><img src="$LJ::IMGPREFIX/portal/btn_del.gif" alt="Delete"/></a>
                 };
             }
             my $always_checked = eval { "$evt_class"->always_checked; };
diff -r 9aeea4fde8d4 -r 2324d3e50a3b htdocs/manage/settings/index.bml
--- a/htdocs/manage/settings/index.bml	Tue Apr 20 09:43:15 2010 +0000
+++ b/htdocs/manage/settings/index.bml	Tue Apr 20 02:49:34 2010 -0700
@@ -420,6 +420,9 @@ body<=
 
     if ($given_cat eq "notifications") {
 
+    LJ::set_active_resource_group( 'jquery' );
+    LJ::need_res( { group => 'jquery' }, 'js/notifications.js' );
+
     $ret .= "<div id='settings_save'>";
     $ret .= $cats_with_settings{$given_cat}->{form} ? LJ::html_submit($ML{'.btn.save'}) : "&nbsp;";
     $ret .= "&nbsp;";
--------------------------------------------------------------------------------