[Rt-commit] rt branch, create-action, updated. ea09a684b385331e5100120364f88c13c36c3e40

sartak at bestpractical.com sartak at bestpractical.com
Tue Sep 29 17:27:41 EDT 2009


The branch, create-action has been updated
       via  ea09a684b385331e5100120364f88c13c36c3e40 (commit)
      from  0a58c10f34e1a107ee168287cd02b0a0f1d73c92 (commit)

Summary of changes:
 lib/RT/Action/CreateTicket.pm     |   37 +-------------------------------
 lib/RT/Action/CustomFieldBased.pm |   42 +++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 36 deletions(-)
 create mode 100644 lib/RT/Action/CustomFieldBased.pm

- Log -----------------------------------------------------------------
commit ea09a684b385331e5100120364f88c13c36c3e40
Author: Shawn M Moore <sartak at bestpractical.com>
Date:   Tue Sep 29 17:27:28 2009 -0400

    Move CF-specific logic into CustomFieldBased action "role"

diff --git a/lib/RT/Action/CreateTicket.pm b/lib/RT/Action/CreateTicket.pm
index d16216b..538970b 100644
--- a/lib/RT/Action/CreateTicket.pm
+++ b/lib/RT/Action/CreateTicket.pm
@@ -1,7 +1,7 @@
 package RT::Action::CreateTicket;
 use strict;
 use warnings;
-use base 'RT::Action::QueueBased', 'Jifty::Action::Record::Create';
+use base 'RT::Action::CustomFieldBased', 'RT::Action::QueueBased', 'Jifty::Action::Record::Create';
 
 use constant record_class => 'RT::Model::Ticket';
 use constant report_detailed_messages => 1;
@@ -202,41 +202,6 @@ sub take_action {
     HTML::Mason::Commands::create_ticket(%{ $self->argument_values });
 }
 
-sub _add_custom_fields {
-    my $self = shift;
-    my %args = @_;
-
-    my $cfs    = $args{cfs};
-    my $method = $args{method};
-
-    while (my $cf = $cfs->next) {
-        my $render_as = $cf->type_for_rendering;
-        my %args = (
-            name => $cf->name,
-            render_as => $render_as,
-        );
-
-        if ($render_as =~ /Select/i) {
-            $args{valid_values} = [ {
-                collection   => $cf->values,
-                display_from => 'name',
-                value_from   => 'name',
-            } ];
-        }
-        elsif ($render_as =~ /Combobox/i) {
-            $args{available_values} = [ {
-                collection   => $cf->values,
-                display_from => 'name',
-                value_from   => 'name',
-            } ];
-        }
-
-        $self->$method(
-            %args,
-        );
-    }
-}
-
 sub add_ticket_custom_fields {
     my $self  = shift;
     my $queue = shift;
diff --git a/lib/RT/Action/CustomFieldBased.pm b/lib/RT/Action/CustomFieldBased.pm
new file mode 100644
index 0000000..bc5d21b
--- /dev/null
+++ b/lib/RT/Action/CustomFieldBased.pm
@@ -0,0 +1,42 @@
+package RT::Action::CustomFieldBased;
+use strict;
+use warnings;
+use base 'Jifty::Action';
+
+sub _add_custom_fields {
+    my $self = shift;
+    my %args = @_;
+
+    my $cfs    = $args{cfs};
+    my $method = $args{method};
+
+    while (my $cf = $cfs->next) {
+        my $render_as = $cf->type_for_rendering;
+        my %args = (
+            name => $cf->name,
+            render_as => $render_as,
+        );
+
+        if ($render_as =~ /Select/i) {
+            $args{valid_values} = [ {
+                collection   => $cf->values,
+                display_from => 'name',
+                value_from   => 'name',
+            } ];
+        }
+        elsif ($render_as =~ /Combobox/i) {
+            $args{available_values} = [ {
+                collection   => $cf->values,
+                display_from => 'name',
+                value_from   => 'name',
+            } ];
+        }
+
+        $self->$method(
+            %args,
+        );
+    }
+}
+
+1;
+

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


More information about the Rt-commit mailing list