[Rt-commit] r6495 - in rt/branches/3.6-EXPERIMENTAL-LONDRES/html:
Prefs
clkao at bestpractical.com
clkao at bestpractical.com
Wed Nov 22 06:05:24 EST 2006
Author: clkao
Date: Wed Nov 22 06:04:43 2006
New Revision: 6495
Added:
rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Admin/Elements/ConfigureMyRT
Modified:
rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Prefs/MyRT.html
Log:
Refactor MyRT configuration to an element.
Added: rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Admin/Elements/ConfigureMyRT
==============================================================================
--- (empty file)
+++ rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Admin/Elements/ConfigureMyRT Wed Nov 22 06:04:43 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-EXPERIMENTAL-LONDRES/html/Prefs/MyRT.html
==============================================================================
--- rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Prefs/MyRT.html (original)
+++ rt/branches/3.6-EXPERIMENTAL-LONDRES/html/Prefs/MyRT.html Wed Nov 22 06:04:43 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