[Rt-commit] r2951 - in rt/branches/CHALDEA-EXPERIMENTAL:
html/Admin/CustomFields html/Elements html/Widgets lib/RT
autrijus at bestpractical.com
autrijus at bestpractical.com
Tue May 24 17:28:14 EDT 2005
Author: autrijus
Date: Tue May 24 17:28:14 2005
New Revision: 2951
Modified:
rt/branches/CHALDEA-EXPERIMENTAL/html/Admin/CustomFields/Modify.html
rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields
rt/branches/CHALDEA-EXPERIMENTAL/html/Widgets/ComboBox
rt/branches/CHALDEA-EXPERIMENTAL/lib/RT/CustomField_Overlay.pm
Log:
* add combo box as friendly pattern hints.
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Admin/CustomFields/Modify.html
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Admin/CustomFields/Modify.html (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Admin/CustomFields/Modify.html Tue May 24 17:28:14 2005
@@ -78,7 +78,18 @@
</tr>
<tr>
<td class="label"><&|/l&>Pattern</&></td>
-<td><input name="Pattern" VALUE="<%$CustomFieldObj->Pattern%>" SIZE=20></td></tr>
+<td>
+<& /Widgets/ComboBox,
+ Name => 'Pattern',
+ Default => $CustomFieldObj->Pattern,
+ Size => 20,
+ Values => [
+ '(?#Mandatory).',
+ '(?#Digits)^[\d.]+$',
+ '(?#Year)^[12]\d{3}$',
+ ],
+&>
+</td></tr>
</tr>
<tr>
<td class="label"> </td>
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Elements/ValidateCustomFields Tue May 24 17:28:14 2005
@@ -20,7 +20,7 @@
next if $CF->MatchPattern($value);
$m->notes(
('InvalidField-' . $CF->Id)
- => (loc("Input must match [_1]", $pattern))
+ => (loc("Input must match [_1]", $CF->FriendlyPattern))
);
$valid = 0;
}
Modified: rt/branches/CHALDEA-EXPERIMENTAL/html/Widgets/ComboBox
==============================================================================
--- rt/branches/CHALDEA-EXPERIMENTAL/html/Widgets/ComboBox (original)
+++ rt/branches/CHALDEA-EXPERIMENTAL/html/Widgets/ComboBox Tue May 24 17:28:14 2005
@@ -47,7 +47,7 @@
<script type="text/javascript" src="<%$RT::WebPath%>/NoAuth/combobox.js"></script>
<span id="<% $Name %>_Container">
-<input name="<% $Name %>" id="<% $Name %>" value="<% $Default %>" type="text" autocomplete="off" />
+<input name="<% $Name %>" id="<% $Name %>" value="<% $Default %>" type="text" <% $Size ? "size='$Size'" : '' |n %> autocomplete="off" />
<br style="display: none"><span id="<% $Name %>_Button"></span></span><select name="List-<% $Name %>" id="<% $Name %>_List" onchange="ComboBox_SimpleAttach(this, this.form['<% $Name %>']); " rows="<% $Rows %>">
<option style="display: none" value="">-</option>
% foreach my $value (@Values) {
@@ -60,6 +60,7 @@
</nobr>
<%ARGS>
$Name
+$Size => undef
$Rows => 5
$Default => ''
@Values => ()
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 Tue May 24 17:28:14 2005
@@ -1002,7 +1002,7 @@
}
unless ( $self->MatchPattern($args{Content}) ) {
- return ( 0, $self->loc('Input must match [_1]', $self->Pattern) );
+ return ( 0, $self->loc('Input must match [_1]', $self->FriendlyPattern) );
}
$RT::Handle->BeginTransaction;
@@ -1075,6 +1075,31 @@
# }}}
+# {{{ FriendlyPattern
+
+=head2 FriendlyPattern
+
+Prettify the pattern of this custom field, by taking the text in C<(?#text)>
+and localizing it.
+
+=cut
+
+sub FriendlyPattern {
+ my $self = shift;
+ my $regex = $self->Pattern;
+
+ return '' if !length($regex);
+ if ($regex =~ /\(\?#([^)]*)\)/) {
+ return '[' . $self->loc($1) . ']';
+ }
+ else {
+ return $regex;
+ }
+}
+
+
+# }}}
+
# {{{ DeleteValueForObject
=head2 DeleteValueForObject HASH
More information about the Rt-commit
mailing list