[Rt-commit] [rtir] 07/08: Use refactored ConfigureMyRT template

Kevin Falcone falcone at bestpractical.com
Fri Mar 28 17:06:04 EDT 2014


This is an automated email from the git hooks/post-receive script.

falcone pushed a commit to branch master
in repository rtir.

commit 6fb45763caf029b24e9d9a2e10e70b02c796b2a3
Author: Jim Brandt <jbrandt at bestpractical.com>
Date:   Tue Mar 4 17:01:22 2014 -0500

    Use refactored ConfigureMyRT template
    
    The code to build the selection boxes on the homepage
    customization page was refactored in RT. Use the refactored
    ConfigureMyRT component for the same purpose in RTIR.
---
 html/RTIR/Prefs/Home.html | 45 +++++++++++++++++----------------------------
 1 file changed, 17 insertions(+), 28 deletions(-)

diff --git a/html/RTIR/Prefs/Home.html b/html/RTIR/Prefs/Home.html
index 5d64dac..00fea97 100644
--- a/html/RTIR/Prefs/Home.html
+++ b/html/RTIR/Prefs/Home.html
@@ -49,13 +49,12 @@
 <& /Elements/Tabs &>
 <& /Elements/ListActions, actions => \@results &>
 
-<& /Widgets/SelectionBox:header, nojs => 1 &>
-% foreach my $box( @boxes ) {
+% foreach my $pane ( @panes ) {
 <&|/Widgets/TitleBox,
-    title => loc('RTIR at a glance') .': '. loc( $box->{Name} ),
+    title => loc('RTIR at a glance') .': '. loc( $pane->{Name} ),
     bodyclass => ""
 &>
-<& /Widgets/SelectionBox:show, self => $box, nojs => 1 &>
+<& /Widgets/SelectionBox:show, self => $pane &>
 </&>
 % }
 
@@ -108,31 +107,21 @@ for my $object (@objs) {
     }
 }
 
+my @panes = $m->comp(
+    '/Admin/Elements/ConfigureMyRT',
+    panes  => ['body', 'sidebar'],
+    Action => 'Home.html',
+    items => \@items,
+    current_portlets => $portlets,
+    OnSave => sub {
+        my ( $conf, $pane ) = @_;
+        my ($ok, $msg) = $user->SetPreferences( 'RTIR_HomepageSettings', $conf );
+        push @results, $ok ? loc('Preferences saved for [_1].', $pane) : $msg;
+        delete $session{'my_rtir_portlets'};
+    }
+);
 
-my @boxes;
-foreach my $pane ( sort keys %$portlets ) {
-    push @boxes,
-        $m->comp(
-            '/Widgets/SelectionBox:new',
-            Action    => 'Home.html',
-            Name      => $pane,
-            Available => \@items,
-            AutoSave  => 1,
-            OnSubmit  => sub {
-                my $self = shift;
-                $portlets->{ $pane } = [
-                    map { m/(\w+)-(.*)$}/; { type => $1, name => $2, }}
-                    @{$self->{Current}}
-                ];
-                $user->SetPreferences('RTIR_HomepageSettings', $portlets);
-                push @results, loc ('Preferences saved for [_1].', $pane);
-                delete $session{'my_rtir_portlets'};
-            },
-            Selected  => [ map { join '-', @{$_}{qw/type name/} } @{ $portlets->{$pane} } ]
-        );
-}
-
-$m->comp ('/Widgets/SelectionBox:process', %ARGS, self => $_, nojs => 1) for @boxes;
+$m->comp ('/Widgets/SelectionBox:process', %ARGS, self => $_ ) for @panes;
 
 MaybeRedirectForResults( Actions => \@results );
 </%INIT>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the rt-commit mailing list