[Rt-commit] rt branch, 4.4/style-custom-field-name, created. rt-4.4.2-30-g45f97e3
Maureen Mirville
maureen at bestpractical.com
Tue Aug 22 14:24:42 EDT 2017
The branch, 4.4/style-custom-field-name has been created
at 45f97e343a0c9188cfa69771350c1584089f3d96 (commit)
- Log -----------------------------------------------------------------
commit 6713f24f603eb6c330641a99dfcf5b702d536268
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Mon Jul 31 14:43:31 2017 -0400
Target style at custom field name
Custom fields may be styled using custom field name as class selector.
diff --git a/share/html/Elements/ShowCustomFields b/share/html/Elements/ShowCustomFields
index 2f7d2ae..2408386 100644
--- a/share/html/Elements/ShowCustomFields
+++ b/share/html/Elements/ShowCustomFields
@@ -54,9 +54,13 @@
% my $Values = $Object->CustomFieldValues( $CustomField->Id );
% my $count = $Values->Count;
% next if $HideEmpty and not $count;
+% my $CustomFieldName = $CustomField->Name;
+%# The following line ensures invalid characters are removed (supports world languages).
+% $CustomFieldName =~ s/\P{ID_Continue}+/-/g;
% my @classes = (
% 'custom-field',
% 'custom-field-'.$CustomField->id,
+% 'custom-field-'.$CustomFieldName
% );
% push @classes, 'unset-field' if not $count;
% $m->callback( CallbackName => 'ModifyFieldClasses', CustomField => $CustomField,
commit 45f97e343a0c9188cfa69771350c1584089f3d96
Author: Maureen E. Mirville <maureen at bestpractical.com>
Date: Thu Aug 17 14:51:18 2017 -0400
Added tests for CF class selector
Tests added to verify that each custom field name has a
corresponding class selector with invalid CSS characters escaped.
diff --git a/t/customfields/api.t b/t/customfields/api.t
index 873503c..47328cc 100644
--- a/t/customfields/api.t
+++ b/t/customfields/api.t
@@ -3,8 +3,9 @@
use strict;
use warnings FATAL => 'all';
-use RT::Test nodata => 1, tests => 157;
+use RT::Test;
use Test::Warn;
+use Mojo::DOM;
# Before we get going, ditch all object_cfs; this will remove
# all custom fields systemwide;
@@ -253,7 +254,7 @@ my $all_classes = RT::Class->new( RT->SystemUser );
is($msg, 'Globally added custom field custom_field_0.', "Adding custom field globally produces appropriate message");
($status, $msg) = $custom_field->RemoveFromObject( $all_queues );
- is($msg, 'Globally removed custom field custom_field_0.', "Rmeoving custom field globally produces appropriate message");
+ is($msg, 'Globally removed custom field custom_field_0.', "Removing custom field globally produces appropriate message");
}
# Ticket CustomField Message Test
@@ -298,3 +299,27 @@ my $all_classes = RT::Class->new( RT->SystemUser );
is($msg, 'Globally removed custom field custom_field_2.', "Removing custom field globally produces appropriate message");
}
+# Each custom field must have a corresponding class selector with invalid characters escaped
+{
+ my($baseurl, $m ) = RT::Test->started_ok;
+ ok($m->login, 'logged in');
+
+ $m->get_ok($baseurl . '/Admin/CustomFields/Modify.html?Create=1');
+ $m->form_name('ModifyCustomField');
+ $m->field('Name' => 'test$class%name');
+ $m->click('Update');
+
+ $m->get_ok($baseurl . '/Admin/CustomFields/Objects.html?id=10');
+ $m->submit_form_ok({
+ with_fields => {
+ 'AddCustomField-10' => 0,
+ },
+ button => 'UpdateObjs',
+ }, 'Added new custom field globally');
+
+ my $res = $m->get($baseurl . '/Ticket/Display.html?id=1');
+ my $dom = Mojo::DOM->new($res->decoded_content);
+ my $class = $dom->at('.custom-field-test-class-name');
+ like($class, qr/test-class-name/, 'Class selector added to custom field, invalid characters have been escaped');
+}
+done_testing();
-----------------------------------------------------------------------
More information about the rt-commit
mailing list