[Bps-public-commit] rt-extension-formtools branch, support-custom-roles, created. 0.50-1-g8d89cdd
Dustin Graves
dustin at bestpractical.com
Tue Mar 1 18:45:11 EST 2016
The branch, support-custom-roles has been created
at 8d89cdd0e619d168269a4d50368e0f009aec6cde (commit)
- Log -----------------------------------------------------------------
commit 8d89cdd0e619d168269a4d50368e0f009aec6cde
Author: Dustin Graves <dustin at bestpractical.com>
Date: Tue Mar 1 23:35:34 2016 +0000
test
diff --git a/html/FormTools/Field b/html/FormTools/Field
index 06608b7..6c051ab 100644
--- a/html/FormTools/Field
+++ b/html/FormTools/Field
@@ -14,6 +14,7 @@ $enabled_by => []
$container_selector => undef
$after_label => ''
$after_input => ''
+$custom_role => 0
</%args>
<%init>
use RT::Extension::FormTools;
@@ -22,6 +23,7 @@ my $ticket = $m->notes('ticket');
my $field_type = 'custom';
my $field_label ||= $label;
my $cf;
+my $role;
my @values;
@@ -29,7 +31,24 @@ $queue = $ticket->QueueObj
if !$queue && $ticket;
my $input_name = '';
-if ( RT::Extension::FormTools::is_core_field($name) ) {
+if ( $custom_role ) {
+ unless ( defined $queue && $queue->id ) {
+ my $msg = "You must specify a queue to use a custom role field";
+ die $msg;
+ }
+
+ $role = RT::CustomRole->new( $session{'CurrentUser'} );
+ $role->Load( $name );
+
+ unless ( $role->id && $role->IsAdded( $queue->id ) ) {
+ my $msg = "Could not find a custom field called $name for the queue ".$queue->Name;
+ die $msg;
+ }
+
+ my $res = $m->notes( custom_roles_on_page => [ @{$m->notes('custom_roles_on_page')||[]}, $name ] );
+ $field_type = 'custom_role';
+ $field_label ||= $name;
+} elsif ( RT::Extension::FormTools::is_core_field($name) ) {
$field_type = 'core';
my $res = $m->notes(
core_fields_on_page => [ @{$m->notes('core_fields_on_page')||[]}, $name ] );
@@ -177,7 +196,7 @@ $default = '' unless defined $default;
<input type="text" name="<%$name%>" size="<% $cols || 20 %>" value="<%$default%>">
% }
-% } else { # CF
+% } elsif ($field_type eq 'custom') {
% unless ($render_as eq 'normal') {
<input type="hidden" class="hidden" name="<% $input_name %>-Magic" value="1" />
@@ -302,6 +321,13 @@ $default = '' unless defined $default;
% die "'$render_as' isn't a valid rendering option for field '$name'";
%}
+% } elsif ($field_type eq 'custom_role') {
+<& /Elements/EmailInput,
+ Name => 'RT::CustomRole-'.$role->id,
+ Default => $default,
+ AutocompleteMultiple => 1,
+ (exists $ARGS{cols} ? (Size => $cols) : ()),
+&>
% }
% if ($render_as ne 'hidden' && $show_label) {
</td><% $after_input |n %></tr></table>
diff --git a/html/FormTools/ShowChoices b/html/FormTools/ShowChoices
index 9dfd6f8..175535d 100644
--- a/html/FormTools/ShowChoices
+++ b/html/FormTools/ShowChoices
@@ -11,6 +11,11 @@ my %all_fields = $m->request_args;
% my $id = $1;
%$cf->Load($id);
<tr><td><b><%$cf->Name%></b></td><td><% ref ($all_fields{$field}) ? join(', ',@{$all_fields{$field}}) : $all_fields{$field}%></td></tr>
+% } elsif ($field =~ /CustomRole-(\d+)/) {
+% my $id = $1;
+% my $role = RT::CustomRole->new($session{'CurrentUser'});
+% $role->Load($id);
+<tr><td><b><%$role->Name%></b></td><td><% ref ($all_fields{$field}) ? join(', ',@{$all_fields{$field}}) : $all_fields{$field}%></td></tr>
% } elsif (RT::Extension::FormTools::is_core_field($field)) {
<tr><td><b><%$field%></b></td><td><% $all_fields{$field} %></td></tr>
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list