[Rt-commit] rt branch, 4.6/fix-selectize-default-values, created. rt-4.4.4-878-g165ca6923
? sunnavy
sunnavy at bestpractical.com
Fri Feb 14 10:07:49 EST 2020
The branch, 4.6/fix-selectize-default-values has been created
at 165ca692356e9d8fb758846c364ead7774a890cd (commit)
- Log -----------------------------------------------------------------
commit 165ca692356e9d8fb758846c364ead7774a890cd
Author: sunnavy <sunnavy at bestpractical.com>
Date: Fri Feb 14 22:47:00 2020 +0800
Don't set all the options as default values for selectize email inputs
Options are not always consistent with default values: it could contain
more. E.g. we add all the suggested one-time-cc addresses in options on
ticket update page.
Thus we need to split items from options. See also 51a17eb01a
diff --git a/share/html/Elements/EmailInput b/share/html/Elements/EmailInput
index c312db266..3ecd7bd35 100644
--- a/share/html/Elements/EmailInput
+++ b/share/html/Elements/EmailInput
@@ -83,7 +83,10 @@
% if (@options) {
data-options="<% JSON(\@options) %>"
- data-items="<% JSON([ map { $_->{value} } @options ]) %>"
+% }
+
+% if (@items) {
+ data-items="<% JSON(\@items) %>"
% }
/>
@@ -96,21 +99,38 @@
<%INIT>
my @options;
+my @items;
if ($AutocompleteMultiple) {
- for my $email ( @$Options, ( split '\s*,\s*', $Default || '' ) ) {
- next unless $email =~ /\S/;
+
+ my $get_autocomplete_option = sub {
+ my $term = shift;
+ return unless $term =~ /\S/;
my $json = $m->scomp(
'/Helpers/Autocomplete/Users',
- term => $email,
+ term => $term,
max => 1,
$AutocompleteReturn ? ( return => $AutocompleteReturn ) : (),
abort => 0,
);
if ($json) {
if ( my $parsed = JSON::from_json($json) ) {
- push @options, $parsed->[0] || ();
+ return $parsed->[0] || ();
}
}
+ return;
+ };
+
+ for my $email ( @$Options ) {
+ if ( my $option = $get_autocomplete_option->($email) ) {
+ push @options, $option;
+ }
+ }
+
+ for my $email ( split '\s*,\s*', $Default || '' ) {
+ if ( my $option = $get_autocomplete_option->($email) ) {
+ push @options, $option;
+ push @items, $option->{value};
+ }
}
}
</%INIT>
-----------------------------------------------------------------------
More information about the rt-commit
mailing list