[Rt-commit] r6561 - in rt/branches/3.6-RELEASE: . html/Prefs

jesse at bestpractical.com jesse at bestpractical.com
Fri Dec 1 13:53:09 EST 2006


Author: jesse
Date: Fri Dec  1 13:53:07 2006
New Revision: 6561

Added:
   rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT
Modified:
   rt/branches/3.6-RELEASE/   (props changed)
   rt/branches/3.6-RELEASE/html/Prefs/MyRT.html

Log:
 r45285 at pinglin (orig r6495):  clkao | 2006-11-22 06:04:43 -0500
 Refactor MyRT configuration to an element.


Added: rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT
==============================================================================
--- (empty file)
+++ rt/branches/3.6-RELEASE/html/Admin/Elements/ConfigureMyRT	Fri Dec  1 13:53:07 2006
@@ -0,0 +1,33 @@
+<%args>
+$Action
+$OnSave
+$items
+$panes
+$current_portlets
+</%args>
+<%init>
+my $portlets = $current_portlets;
+my @panes;
+for my $pane (@$panes) {
+    push @panes, $m->comp(
+        '/Widgets/SelectionBox:new',
+        Action    => $Action,
+        Name      => $pane,
+        Available => $items,
+        AutoSave  => 1,
+        OnSubmit  => sub {
+            my $sel = shift;
+            $portlets->{$pane} = [
+                map { m/(\w+)-(.*)$}/;
+                      { type => $1,
+                        name => $2 } } @{ $sel->{Current} }
+            ];
+            $OnSave->( $portlets, $pane );
+        },
+        Selected => [ map { join( '-', @{$_}{qw/type name/} ) }
+                      @{ $portlets->{$pane} } ]
+    );
+}
+
+return @panes;
+</%init>

Modified: rt/branches/3.6-RELEASE/html/Prefs/MyRT.html
==============================================================================
--- rt/branches/3.6-RELEASE/html/Prefs/MyRT.html	(original)
+++ rt/branches/3.6-RELEASE/html/Prefs/MyRT.html	Fri Dec  1 13:53:07 2006
@@ -118,30 +118,21 @@
     }
 }
 
-my %item_map = map {$_->[0] => $_->[1]} @items;
-my @panes;
-for my $pane ('body', 'summary') {
-    push @panes,
-	$m->comp ('/Widgets/SelectionBox:new',
-		  Action => 'MyRT.html',
-		  Name => $pane,
-                  Available => \@items,
-                  AutoSave => 1,
-		  OnSubmit =>
-		  sub { my $sel = shift;
-			$portlets->{$pane} =
-			    [map { m/(\w+)-(.*)$}/;
-				   { type => $1,
-				     name => $2,
-				 }} @{$sel->{Current}}];
-			$user->SetPreferences('HomepageSettings', $portlets);
-			push @actions, loc ('Preferences saved for [_1].', $pane);
-			delete $session{'my_rt_portlets'};
-
-		  },
-		  Selected => [map {join('-',@{$_}{qw/type name/})} @{$portlets->{$pane}}]);
-}
+my @panes = $m->comp(
+    '/Admin/Elements/ConfigureMyRT',
+    panes  => ['body', 'summary'],
+    Action => 'MyRT.html',
+    items => \@items,
+    current_portlets => $portlets,
+    OnSave => sub {
+        my ( $conf, $pane ) = @_;
+        $user->SetPreferences( 'HomepageSettings', $conf );
+        push @actions, loc( 'Preferences saved for [_1].', $pane );
+        delete $session{'my_rt_portlets'};
+    }
+);
 
-$m->comp ('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1) for @panes;
+$m->comp( '/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1 )
+    for @panes;
 
 </%INIT>


More information about the Rt-commit mailing list