diff options
author | Jesse Vincent <jesse@bestpractical.com> | 2003-02-09 09:31:21 +0300 |
---|---|---|
committer | Jesse Vincent <jesse@bestpractical.com> | 2003-02-09 09:31:21 +0300 |
commit | d411ed13dcc970f081398d6c4ac864c33ca240bb (patch) | |
tree | b6e2ae2c355432ba2299e11572317b1c8e58cc64 | |
parent | 9afab5dd75df209c225210a0f29638ef7f8b1bd7 (diff) |
A number of small customfield fixes and API enhancementsrt-2.1.70
-rwxr-xr-x | Makefile | 2 | ||||
-rwxr-xr-x | html/Elements/ListActions | 3 | ||||
-rw-r--r-- | html/Ticket/DetailedCreate.html | 129 | ||||
-rwxr-xr-x[-rw-r--r--] | html/Ticket/Elements/EditCustomField (renamed from html/Ticket/Elements/EditCustomFieldValues) | 69 | ||||
-rwxr-xr-x | html/Ticket/Elements/EditCustomFields | 37 | ||||
-rwxr-xr-x | html/Ticket/Elements/ShowCustomFields | 7 | ||||
-rwxr-xr-x | lib/RT/CustomField_Overlay.pm | 9 | ||||
-rwxr-xr-x | lib/RT/Interface/Web.pm | 17 | ||||
-rwxr-xr-x | lib/RT/Queue_Overlay.pm | 17 | ||||
-rwxr-xr-x | lib/RT/Ticket_Overlay.pm | 33 |
10 files changed, 105 insertions, 218 deletions
@@ -39,7 +39,7 @@ SITE_CONFIG_FILE = $(CONFIG_FILE_PATH)/RT_SiteConfig.pm RT_VERSION_MAJOR = 2 RT_VERSION_MINOR = 1 -RT_VERSION_PATCH = 69 +RT_VERSION_PATCH = 70 RT_VERSION = $(RT_VERSION_MAJOR).$(RT_VERSION_MINOR).$(RT_VERSION_PATCH) TAG = rt-$(RT_VERSION_MAJOR)-$(RT_VERSION_MINOR)-$(RT_VERSION_PATCH) diff --git a/html/Elements/ListActions b/html/Elements/ListActions index cb8590361d..bb455a5529 100755 --- a/html/Elements/ListActions +++ b/html/Elements/ListActions @@ -33,6 +33,9 @@ <& /Elements/TitleBoxEnd &> <BR> % } +<%init> +@actions = grep (/./,@actions); +</%init> <%ARGS> @actions => undef </%ARGS> diff --git a/html/Ticket/DetailedCreate.html b/html/Ticket/DetailedCreate.html deleted file mode 100644 index 3557a2cd2f..0000000000 --- a/html/Ticket/DetailedCreate.html +++ /dev/null @@ -1,129 +0,0 @@ -%# BEGIN LICENSE BLOCK -%# -%# Copyright (c) 1996-2002 Jesse Vincent <jesse@bestpractical.com> -%# -%# (Except where explictly superceded by other copyright notices) -%# -%# This work is made available to you under the terms of Version 2 of -%# the GNU General Public License. A copy of that license should have -%# been provided with this software, but in any event can be snarfed -%# from www.gnu.org -%# -%# This work is distributed in the hope that it will be useful, but -%# WITHOUT ANY WARRANTY; without even the implied warranty of -%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -%# General Public License for more details. -%# -%# -%# Unless otherwise specified, all modifications, corrections or -%# extensions to this work which alter its source code become the -%# property of Best Practical Solutions, LLC when submitted for -%# inclusion in the work. -%# -%# -%# END LICENSE BLOCK -<& /Elements/Header, Title => loc("Create a new ticket") &> -<& /Elements/Tabs, - current_toptab => "Ticket/Create.html", - Title => loc("Create a new ticket") &> -<FORM ACTION="Display.html" METHOD="POST" ENCTYPE="multipart/form-data"> -<INPUT TYPE=HIDDEN NAME=Queue Value="<%$QueueObj->Name%>"> -<INPUT TYPE=HIDDEN Name="id" VALUE="new"> -<A NAME="top"> - - -<& /Elements/TitleBoxStart, contentbg => "#cccccc", title => loc("Create a new ticket") &> -<TABLE border=0> -%# {{{ Basics -<TR><TD ALIGN=RIGHT><h2><&|/l&>The Basics</&></h2></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Queue</&>:</TD> -<TD><b><% $QueueObj->Name %></b></TD> -<TR> -<TD ALIGN="RIGHT"> <&|/l&>Subject</&>: </TD> -<TD COLSPAN=5> <INPUT Name="Subject" SIZE=60 MAXSIZE=100 value=""> </TD> -</TR> -<TR><TD ALIGN=RIGHT><&|/l&>Status</&>:</TD> -<TD><& /Elements/SelectStatus, Name => "Status", Default=> 'new' &> </TD> -</TR> -<TR><TD ALIGN=RIGHT><&|/l&>Priority</&>:</TD><TD><input size=3 name="InitialPriority" value="<%$QueueObj->InitialPriority%>"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Final Priority</&>:</TD><TD><input size=3 name="FinalPriority" value="<%$QueueObj->FinalPriority%>"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Time Worked</&>:</TD><TD><input size=3 name="TimeWorked"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Time Left</&>:</TD><TD><input size=3 name="TimeLeft"></TD></TR> -%# }}} -%# {{{ Custom Fields -<TR><TD ALIGN=RIGHT><h2><&|/l&>Custom Fields</&></h2></TD></TR> -% while( my $cf = $CFs->Next() ) { -<TR><TD ALIGN=RIGHT VALIGN="top"><%$cf->Name%>:</TD> -<TD><% $cf->Description && '<i>'.$cf->Description . '</i><br>'%> <& /Ticket/Elements/EditCustomFieldValues, Name => 'CustomField-'.$cf->Id, CustomField => $cf &> -</TD> -</TR> -% } -%# }}} -%# {{{ people -<TR><TD ALIGN=RIGHT><h2><&|/l&>People</&></h2></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Owner</&>:</TD> -<TD> <& /Elements/SelectOwner, Name => "Owner", QueueObj => $QueueObj &> </TD> </TR> -<TR><TD ALIGN="RIGHT"> <&|/l&>Requestors</&>: </TD> -<TD COLSPAN=5> <INPUT Name="Requestors" Value="<%$session{CurrentUser}->EmailAddress%>" SIZE=40> </TD> -</TR> -<TR><TD ALIGN="RIGHT"> <&|/l&>Cc</&>: </TD> -<TD COLSPAN=5> <INPUT NAME="Cc" SIZE=40> </TD> -</TR> -<TR><TD ALIGN="RIGHT"><&|/l&>Admin Cc</&>: </TD> -<TD COLSPAN=5> <INPUT NAME="AdminCc" SIZE=40> </TD> -</TR> -<TR><TD ALIGN=RIGHT COLSPAN=2> -</TD> -</TR> -%# }}} -%# {{{ Dates -<TR><TD ALIGN=RIGHT><h2><&|/l&>Dates</&></h2></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Starts</&>:</TD><TD><input size=10 name="Starts"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Due</&>:</TD><TD><input size=10 name="Due"></TD></TR> -%# }}} -%# {{{ Relationships -<TR><TD ALIGN=RIGHT><h2><&|/l&>Relationships</&></h2></TD></TR> -<TR><TD></TD><TD colspan=3><i><&|/l&>(Enter ticket ids or URLs, seperated with spaces)</&></i></TD></TR> - -<TR><TD ALIGN=RIGHT><&|/l&>Depends on</&>:</TD><TD><input size=10 name="new-DependsOn"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Depended on by</&>:</TD><TD><input size=10 name="DependsOn-new"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Parents</&>:</TD><TD><input size=10 name="new-MemberOf"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Children</&>:</TD><TD><input size=10 name="MemberOf-new"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Refers to</&>:</TD><TD><input size=10 name="new-RefersTo"></TD></TR> -<TR><TD ALIGN=RIGHT><&|/l&>Referred to by</&>:</TD><TD><input size=10 name="RefersTo-new"></TD></TR> -%# }}} -%# {{{ Body -<TR><TD ALIGN=RIGHT><h2><&|/l&>Ticket content</&></h2></TD></TR> -<TR><TD ALIGN=RIGHT> <&|/l&>Attach file</&>: </TD> -<TD COLSPAN=5> -<INPUT TYPE=FILE NAME="Attach"> -</TD> -</TR> -<TR> -<TD COLSPAN=6> -<&|/l&>Describe the issue below</&>:<br> -<& /Elements/MessageBox, QuoteTransaction => $QuoteTransaction &> -</TD> -</TR> - -%# }}} -</TABLE> -<& /Elements/TitleBoxEnd&> -<& /Elements/Submit, Label => loc("Create") &> -</FORM> - -<%INIT> -my $QueueObj = new RT::Queue($session{'CurrentUser'}); -$QueueObj->Load($Queue) || Abort(loc("Queue could not be loaded.")); - -my $CFs = $QueueObj->CustomFields(); - -</%INIT> - -<%ARGS> -$DependsOn => undef -$DependedOnBy => undef -$MemberOf => undef -$QuoteTransaction => undef -$Queue => undef -</%ARGS> diff --git a/html/Ticket/Elements/EditCustomFieldValues b/html/Ticket/Elements/EditCustomField index e25af3a38d..7ab08571c3 100644..100755 --- a/html/Ticket/Elements/EditCustomFieldValues +++ b/html/Ticket/Elements/EditCustomField @@ -22,50 +22,47 @@ %# %# %# END LICENSE BLOCK -<& /Elements/Callback, _CallbackName => $Name, Values => $Values, %ARGS &> - +% my $Values; +% if ($TicketObj) { +% $Values = $TicketObj->CustomFieldValues($CustomField->id); +% } % if ($CustomField->Type eq 'FreeformSingle') { -<input name="<%$Name%>" -% if ($Values) { -value="<%$Values->First->Content%>" -% } + <input name="<%$NamePrefix%><%$CustomField->Id%>-Value" + size="<%$Cols%>" +% if ($TicketObj) { + value="<%$Values->Count ? $Values->First->Content : ''%>" +% } > % } elsif ($CustomField->Type eq 'FreeformMultiple') { -% my ($content); -% if ($Values) { -% while (my $value = $Values->Next ) { -% $content .= $value->Content; -% } -% } -<textarea name="<%$Name%>"><%$content%></textarea> +% my $content; +% if ($TicketObj) { +% while (my $value = $Values->Next ) { +% $content .= $value->Content; +% } +% } +<input type="hidden" name="<%$NamePrefix%><%$CustomField->Id%>-Values-Magic" value="1"> +<textarea cols=<%$Cols%> rows=<%$Rows%> name="<%$NamePrefix%><%$CustomField->Id%>-Values"><%$content%></textarea> % } elsif ($CustomField->Type =~ /^Select/) { -<select name="<%$Name%>" - size="5" - <%$CustomField->Type eq 'SelectMultiple' && 'MULTIPLE'%> - > + <input type="hidden" name="<%$NamePrefix%><%$CustomField->Id%>-Values-Magic" value="1"> + <select name="<%$NamePrefix%><%$CustomField->Id%>-Values" + size="<%$Rows%>" + <%$CustomField->Type eq 'SelectMultiple' && 'MULTIPLE'%>> % my $CustomFieldValues = $CustomField->Values(); +% my $selected; % while (my $value = $CustomFieldValues->Next) { -<option value="<%$value->Name%>" - <% $Values && $Values->HasEntry($value->Name) && 'SELECTED' %> - ><% $value->Description || $value->Name %></option> + <option value="<%$value->Name%>" +% if ($TicketObj) { + <% $Values->HasEntry($value->Name) && ($selected = 1) && 'SELECTED' %> +% } + ><% $value->Name%></option> % } -<option value="" <%(!$Values || $Values->Count == 0) && 'SELECTED' %>><&|/l&>(no value)</&></option> -</select> + <option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no value)</&></option> + </select> % } -<%INIT> -my $Values; - -if ($TicketObj ){ - $Values = $TicketObj->CustomFieldValues($CustomField->id); -} - -unless ($Name) { - $Name="Ticket-".$TicketObj->Id."-CustomField-".$CustomField->Id."-Values"; -} - -</%INIT> <%ARGS> -$Name => undef -$CustomField => undef $TicketObj => undef +$CustomField => undef +$NamePrefix => undef +$Rows => 5 +$Cols=> 15 </%ARGS> diff --git a/html/Ticket/Elements/EditCustomFields b/html/Ticket/Elements/EditCustomFields index 9cdb09d131..45c18a1a87 100755 --- a/html/Ticket/Elements/EditCustomFields +++ b/html/Ticket/Elements/EditCustomFields @@ -45,42 +45,7 @@ <b><%$CustomField->Name%></b><br> <i><%$CustomField->FriendlyType%></i> </td> - <td class="entry"> -% my $Values; -% if ($TicketObj) { -% $Values = $TicketObj->CustomFieldValues($CustomField->id); -% } -% if ($CustomField->Type eq 'FreeformSingle') { - <input name="<%$NamePrefix%><%$CustomField->Id%>-Value" -% if ($TicketObj) { - value="<%$Values->Count ? $Values->First->Content : ''%>" -% } -> -% } elsif ($CustomField->Type eq 'FreeformMultiple') { -% my $content; -% if ($TicketObj) { -% while (my $value = $Values->Next ) { -% $content .= $value->Content; -% } -% } -<textarea name="<%$NamePrefix%><%$CustomField->Id%>-Values"><%$content%></textarea> -% } elsif ($CustomField->Type =~ /^Select/) { - <select name="<%$NamePrefix%><%$CustomField->Id%>-Values" - size="5" - <%$CustomField->Type eq 'SelectMultiple' && 'MULTIPLE'%>> -% my $CustomFieldValues = $CustomField->Values(); -% my $selected; -% while (my $value = $CustomFieldValues->Next) { - <option value="<%$value->Name%>" -% if ($TicketObj) { - <% $Values->HasEntry($value->Name) && ($selected = 1) && 'SELECTED' %> -% } - ><% $value->Name%></option> -% } - <option value="" <% !$selected && 'SELECTED' %>><&|/l&>(no value)</&></option> - </select> -% } - </td> + <td class="entry"><& EditCustomField, TicketObj => $TicketObj, CustomField => $CustomField, NamePrefix => $NamePrefix &></td> </tr> % } </table> diff --git a/html/Ticket/Elements/ShowCustomFields b/html/Ticket/Elements/ShowCustomFields index 583590d12d..e3a785f1d7 100755 --- a/html/Ticket/Elements/ShowCustomFields +++ b/html/Ticket/Elements/ShowCustomFields @@ -25,10 +25,6 @@ <table> % my @entry_fields; % while (my $CustomField = $CustomFields->Next()) { -% if ($CustomField->Type =~ /Entry$/) { -% push @entry_fields, $CustomField; -% next; -% } % my $Values = $Ticket->CustomFieldValues($CustomField->Id); <tr> <td class="label"><%$CustomField->Name%>:</td> @@ -43,9 +39,6 @@ </tr> % } </table> -% if (@entry_fields) { -<& /Ticket/Elements/EditCustomFieldEntries, ReadOnly => 1, CustomFields => \@entry_fields, TicketObj => $Ticket &> -% } <%INIT> my $CustomFields = $Ticket->QueueObj->CustomFields(); </%INIT> diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm index e8efb041bf..04b71a2655 100755 --- a/lib/RT/CustomField_Overlay.pm +++ b/lib/RT/CustomField_Overlay.pm @@ -55,16 +55,19 @@ for (@TYPES) { $TYPES{$_} = 1}; =cut -# {{{ sub LoadNameAndQueue +# {{{ sub LoadByNameAndQueue -=head2 LoadNameAndQueue (Queue => QUEUEID, Name => NAME) +=head2 LoadByNameAndQueue (Queue => QUEUEID, Name => NAME) Loads the Custom field named NAME for Queue QUEUE. If QUEUE is 0, loads a global custom field =cut -sub LoadNameAndQueue { +# Compatibility for API change after 3.0 beta 1 +*LoadNameAndQueue = \&LoadByNameAndQueue; + +sub LoadByNameAndQueue { my $self = shift; my %args = ( Queue => undef, diff --git a/lib/RT/Interface/Web.pm b/lib/RT/Interface/Web.pm index 17abbc4964..4e4a9fc908 100755 --- a/lib/RT/Interface/Web.pm +++ b/lib/RT/Interface/Web.pm @@ -245,7 +245,8 @@ sub CreateTicket { ); foreach my $arg (%ARGS) { if ($arg =~ /^CustomField-(\d+)(.*?)$/) { - $create_args{"CustomField-".$1} = $ARGS{"$arg"}; + next if ($arg =~ /-Magic$/); + $create_args{"CustomField-".$1} = $ARGS{"$arg"}; } } my ( $id, $Trans, $ErrMsg ) = $Ticket->Create(%create_args); @@ -1020,6 +1021,16 @@ sub ProcessTicketCustomFieldUpdates { foreach my $cf ( keys %{ $custom_fields_to_mod{$tick} } ) { foreach my $arg ( keys %{$ARGSRef} ) { + # since http won't pass in a form element with a null value, we need + # to fake it + if ($arg =~ /^(.*?)-Values-Magic$/ ) { + # We don't care about the magic, if there's really a values element; + next if (exists $ARGSRef->{$1.'-Values'}) ; + + $arg = $1."-Values"; + $ARGSRef->{$1."-Values"} = undef; + + } next unless ( $arg =~ /^Ticket-$tick-CustomField-$cf-/ ); my @values = ( ref( $ARGSRef->{$arg} ) eq 'ARRAY' ) @@ -1045,7 +1056,7 @@ sub ProcessTicketCustomFieldUpdates { push ( @results, $msg ); } } - elsif ( $arg =~ /-Values$/ ) { + elsif ( $arg =~ /-Values/ ) { my $cf_values = $Ticket->CustomFieldValues($cf); my %values_hash; @@ -1070,7 +1081,7 @@ sub ProcessTicketCustomFieldUpdates { Field => $cf, Value => $cf_value->Content ); - push ( @results, $msg ); + push ( @results, $msg); } diff --git a/lib/RT/Queue_Overlay.pm b/lib/RT/Queue_Overlay.pm index 6ed6bcc349..ec71616efa 100755 --- a/lib/RT/Queue_Overlay.pm +++ b/lib/RT/Queue_Overlay.pm @@ -395,6 +395,23 @@ sub Templates { # {{{ Dealing with custom fields +# {{{ CustomField + +=item CustomField NAME + +Load the queue-specific custom field named NAME + +=cut + +sub CustomField { + my $self = shift; + my $name = shift; + my $cf = RT::CustomField->new($self->CurrentUser); + $cf->LoadByNameAndQueue(Name => $name, Queue => $self->Id); + return ($cf); +} + + # {{{ CustomFields =item CustomFields diff --git a/lib/RT/Ticket_Overlay.pm b/lib/RT/Ticket_Overlay.pm index 956ab6427f..cf2f0238a3 100755 --- a/lib/RT/Ticket_Overlay.pm +++ b/lib/RT/Ticket_Overlay.pm @@ -3317,12 +3317,36 @@ sub Resolve { # {{{ Routines dealing with custom fields + +# {{{ FirstCustomFieldValue + +=item FirstCustomFieldValue FIELD + +Return the content of the first value of CustomField FIELD for this ticket +Takes a field id or name + +=cut + +sub FirstCustomFieldValue { + my $self = shift; + my $field = shift; + my $values = $self->CustomFieldValues($field); + if ($values->First) { + return $values->First->Content; + } else { + return undef; + } + +} + + + # {{{ CustomFieldValues =item CustomFieldValues FIELD Return a TicketCustomFieldValues object of all values of CustomField FIELD for this ticket. -Takes a field id +Takes a field id or name. =cut @@ -3332,9 +3356,12 @@ sub CustomFieldValues { my $field = shift; my $cf = RT::CustomField->new($self->CurrentUser); - - $cf->LoadById($field); + if ($field =~ /^\d+$/) { + $cf->LoadById($field); + } else { + $cf->LoadByNameAndQueue(Name => $field, Queue => $self->QueueObj->Id); + } my $cf_values = RT::TicketCustomFieldValues->new( $self->CurrentUser ); $cf_values->LimitToCustomField($cf->id); $cf_values->LimitToTicket($self->Id()); |