[Rt-commit] r2895 - in rt/branches/CHALDEA-EXPERIMENTAL:
html/Elements html/Ticket html/Ticket/Elements lib/RT
autrijus at bestpractical.com
autrijus at bestpractical.com
Wed May 18 13:32:21 EDT 2005
Author: autrijus
Date: Wed May 18 13:32:21 2005
New Revision: 2895
Added:
rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields
Modified:
rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Create.html
rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Elements/EditCustomFields
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm
Log:
* feedback for invalid CFs.
Added: rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields
==============================================================================
--- (empty file)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields Wed May 18 13:32:21 2005
@@ -0,0 +1,22 @@
+<%INIT>
+my $valid = 1;
+$CustomFields->GotoFirstItem;
+while (my $CF = $CustomFields->Next) {
+ my $pattern = $CF->Pattern;
+ my $field = $NamePrefix . $CF->Id . "-Value";
+ $m->notes(('Field-' . $CF->Id) => $ARGSRef->{$field});
+ next if $CF->MatchPattern($ARGSRef->{$field});
+ $m->notes(
+ ('InvalidField-' . $CF->Id)
+ => (loc("Input must match [_1]", $pattern))
+ );
+ $valid = 0;
+}
+$m->notes('ValidFields', $valid);
+return $valid;
+</%INIT>
+<%ARGS>
+$CustomFields
+$ARGSRef
+$NamePrefix => "Object-RT::Ticket--CustomField-"
+</%ARGS>
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Create.html
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Create.html (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Create.html Wed May 18 13:32:21 2005
@@ -240,6 +240,12 @@
my $CFs = $QueueObj->TicketCustomFields();
my $TxnCFs = $QueueObj->TicketTransactionCustomFields();
+my $ValidCFs = $m->comp(
+ '/Elements/ValidateCustomFields',
+ CustomFields => $CFs,
+ ARGSRef => \%ARGS
+);
+
# if no due date has been set explicitly, then use the
# queue's default if it exists
if ($QueueObj->DefaultDueIn && !$ARGS{'Due'}) {
@@ -285,7 +291,7 @@
# }}}
-if ((!exists $ARGS{'AddMoreAttach'}) && ($ARGS{'id'} eq 'new')) { # new ticket?
+if ((!exists $ARGS{'AddMoreAttach'}) and ($ARGS{'id'} eq 'new') and $ValidCFs) { # new ticket?
$m->comp('Display.html', %ARGS);
$m->comp('/Elements/Footer');
$m->abort();
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Elements/EditCustomFields
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Elements/EditCustomFields (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Ticket/Elements/EditCustomFields Wed May 18 13:32:21 2005
@@ -69,8 +69,13 @@
<td class="entry"><& /Elements/EditCustomField,
Object => $TicketObj,
CustomField => $CustomField,
- NamePrefix => $NamePrefix
- &></td>
+ NamePrefix => $NamePrefix ,
+ Default => $m->notes('Field-' . $CustomField->Id),
+ &>
+% if (my $msg = $m->notes('InvalidField-' . $CustomField->Id)) {
+ <br>
+ <em style="color: red"><% $msg %></em></td>
+% }
</tr>
% }
</table>
Modified: rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm Wed May 18 13:32:21 2005
@@ -1001,8 +1001,8 @@
return ( 0, $self->loc('Permission Denied') );
}
- unless ( $self->_MatchPattern($args{Content}) ) {
- return ( 0, $self->loc('Invalid input') );
+ unless ( $self->MatchPattern($args{Content}) ) {
+ return ( 0, $self->loc('Input must match [_1]', $self->Pattern) );
}
$RT::Handle->BeginTransaction;
@@ -1053,7 +1053,18 @@
}
-sub _MatchPattern {
+# }}}
+
+# {{{ MatchPattern
+
+=head2 MatchPattern STRING
+
+Tests the incoming string against the Pattern of this custom field object
+and returns a boolean; returns true if the Pattern is empty.
+
+=cut
+
+sub MatchPattern {
my $self = shift;
my $regex = $self->Pattern;
More information about the Rt-commit
mailing list