[Rt-commit] rt branch, admin_ui, updated. bf0f2b6402b135f3e721d030ce786bf727ac3a58

sunnavy at bestpractical.com sunnavy at bestpractical.com
Tue Dec 22 22:25:40 EST 2009


The branch, admin_ui has been updated
       via  bf0f2b6402b135f3e721d030ce786bf727ac3a58 (commit)
      from  25452bb62b8751c5c2366a6d223005fab2babbf3 (commit)

Summary of changes:
 lib/RT/Action/ConfigMyRT.pm |   57 +++++++++++++++++++++++++++----------------
 1 files changed, 36 insertions(+), 21 deletions(-)

- Log -----------------------------------------------------------------
commit bf0f2b6402b135f3e721d030ce786bf727ac3a58
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Dec 23 11:25:29 2009 +0800

    add reset argument for ConfigMyRT action

diff --git a/lib/RT/Action/ConfigMyRT.pm b/lib/RT/Action/ConfigMyRT.pm
index 45df6fe..12ec315 100644
--- a/lib/RT/Action/ConfigMyRT.pm
+++ b/lib/RT/Action/ConfigMyRT.pm
@@ -23,6 +23,14 @@ sub arguments {
         default_value => ref $self->object,
     };
 
+    if ( ref $self->object ne 'RT::System' ) {
+        $args->{'reset'} = {
+            render_as     => 'InlineButton',
+            default_value => 1,
+            label => 'Reset',
+        };
+    }
+
     for my $type ( qw/body summary/ ) {
         $args->{$type} = {
             available_values => defer { $self->available_values },
@@ -60,31 +68,38 @@ sub take_action {
         return;
     }
 
-    my $content = $self->default_value || {};
-    for my $arg ( $self->argument_names ) {
-        next unless ( $arg =~ /^body|summary$/ );
-        my $value = $self->argument_value($arg);
+    if ( $self->argument_value('reset') && $object_type ne 'RT::System' ) {
+        $self->object->set_preferences('HomepageSettings', {});
+    }
+    else {
+
+        my $content = $self->default_value || {};
+        for my $arg ( $self->argument_names ) {
+            next unless ( $arg =~ /^body|summary$/ );
+            my $value = $self->argument_value($arg);
+
+            my @panes;
+            if ( UNIVERSAL::isa( $self->argument_value($arg), 'ARRAY' ) ) {
+                @panes = @$value;
+            }
+            else {
+                @panes = $value;
+            }
+
+            @panes =
+              map { /(\w+)-(.*)/ ? { type => $1, name => $2 } : () }
+              grep { $_ } @panes;
+            $content->{$arg} = \@panes;
+        }
 
-        my @panes;
-        if ( UNIVERSAL::isa( $self->argument_value($arg), 'ARRAY' ) ) {
-            @panes = @$value;
+        if ( ref $self->object eq 'RT::System' ) {
+            my ($settings) =
+              $self->object->attributes->named('HomepageSettings');
+            $settings->set_content($content);
         }
         else {
-            @panes = $value;
+            $self->object->set_preferences( 'HomepageSettings' => $content );
         }
-
-        @panes =
-          map { /(\w+)-(.*)/ ? { type => $1, name => $2 } : () }
-          grep { $_ } @panes;
-        $content->{$arg} = \@panes;
-    }
-
-    if ( ref $self->object eq 'RT::System' ) {
-        my ($settings) = $self->object->attributes->named('HomepageSettings');
-        $settings->set_content($content);
-    }
-    else {
-        $self->object->set_preferences( 'HomepageSettings' => $content );
     }
     $self->report_success;
     return 1;

-----------------------------------------------------------------------


More information about the Rt-commit mailing list