From 4db83cde7263cd2e268db37c5d841df99967592a Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 25 Dec 2023 16:13:39 +0100 Subject: [PATCH 1/3] Issue #205: remove special codes XA and XB from the selection --- Kernel/System/ReferenceData.pm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Kernel/System/ReferenceData.pm b/Kernel/System/ReferenceData.pm index 37cfa6edd1..43d060a3e4 100644 --- a/Kernel/System/ReferenceData.pm +++ b/Kernel/System/ReferenceData.pm @@ -187,7 +187,13 @@ sub TranslatedCountryList { my $AllRegions = $Locale->all_regions(); # includes regions like '001' => World my %Code2Name; + CODE: for my $Code ( grep { length $_ == 2 } keys $AllRegions->%* ) { + + # Skip the country codes that are only meant for testing and development. + next CODE if $Code eq 'XA'; # Pseudo-Accents + next CODE if $Code eq 'XB'; # Pseudo-Bidi + my $Flag = join '', map { $Letter2Indicator{$_} } From 513c84fd86f62d9ed405fdd6b6d6176a6b6e0c89 Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 25 Dec 2023 16:17:18 +0100 Subject: [PATCH 2/3] Issue #205: add prev. country to the selection list --- Kernel/Modules/AdminCustomerCompany.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Kernel/Modules/AdminCustomerCompany.pm b/Kernel/Modules/AdminCustomerCompany.pm index 808f2c1147..92ac7408dc 100644 --- a/Kernel/Modules/AdminCustomerCompany.pm +++ b/Kernel/Modules/AdminCustomerCompany.pm @@ -656,7 +656,7 @@ sub _Edit { Class => "$OptionRequired Modernize " . ( $Param{Errors}->{ $Entry->[0] . 'Invalid' } || '' ), Translation => 1, - Sort => 'AlphanumericKey', + Sort => 'AlphanumericKey', SelectedID => $Param{ $Entry->[0] }, Max => 35, ); @@ -674,12 +674,19 @@ sub _Edit { $CountryList = $Kernel::OM->Get('Kernel::System::ReferenceData')->TranslatedCountryList( Language => $LayoutObject->{UserLanguage}, ); + + # Make sure that the previous value exists in the selection list even if it isn't a country code. + my $PreviousCountry = $Param{ $Entry->[0] }; + if ($PreviousCountry) { + $CountryList->{$PreviousCountry} //= $PreviousCountry; + } } else { # English name => English name $CountryList = $Kernel::OM->Get('Kernel::System::ReferenceData')->CountryList; } + $Param{Option} = $LayoutObject->BuildSelection( Data => $CountryList, PossibleNone => 1, @@ -687,7 +694,7 @@ sub _Edit { Name => $Entry->[0], Class => "$OptionRequired Modernize " . ( $Param{Errors}->{ $Entry->[0] . 'Invalid' } || '' ), - SelectedID => defined( $Param{ $Entry->[0] } ) ? $Param{ $Entry->[0] } : 1, + SelectedID => ( $Param{ $Entry->[0] } // 1 ), ); } elsif ( $Entry->[0] =~ m/^ValidID/i ) { From eb869389ceff1f88a6b3fbd7df50923468c3f0e0 Mon Sep 17 00:00:00 2001 From: bernhard Date: Mon, 25 Dec 2023 16:18:13 +0100 Subject: [PATCH 3/3] Issue #205: show CLDR country list also in AdminCustomerUser --- Kernel/Modules/AdminCustomerUser.pm | 43 ++++++++++++++++++++++++++--- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/Kernel/Modules/AdminCustomerUser.pm b/Kernel/Modules/AdminCustomerUser.pm index ad80a79204..e887de9882 100644 --- a/Kernel/Modules/AdminCustomerUser.pm +++ b/Kernel/Modules/AdminCustomerUser.pm @@ -16,12 +16,19 @@ package Kernel::Modules::AdminCustomerUser; +use v5.24; use strict; use warnings; +use namespace::autoclean; +# core modules + +# CPAN modules + +# OTOBO modules +use Kernel::Language qw(Translatable); use Kernel::System::CheckItem; use Kernel::System::VariableCheck qw(:all); -use Kernel::Language qw(Translatable); our $ObjectManagerDisabled = 1; @@ -1187,7 +1194,8 @@ sub _Edit { $Param{RequiredClass} .= ' Validate_Email'; } - # build selections or input fields + # Build selections or input fields. + # An explicit selection has the highest priority. if ( $ConfigObject->Get( $Param{Source} )->{Selections}->{ $Entry->[0] } ) { $Block = 'Option'; @@ -1214,7 +1222,34 @@ sub _Edit { Disabled => $UpdateOnlyPreferences ? 1 : 0, ); } - elsif ( $Entry->[0] =~ /^ValidID/i ) { + elsif ( + $Entry->[0] =~ m/^UserCountry/i + && + $ConfigObject->Get('ReferenceData::TranslatedCountryNames') + ) + { + $Block = 'Option'; + + my $CountryList = $Kernel::OM->Get('Kernel::System::ReferenceData')->TranslatedCountryList( + Language => $LayoutObject->{UserLanguage}, + ); + + # Make sure that the previous value exists in the selection list even if isn't a countr code. + my $PreviousCountry = $Param{ $Entry->[0] }; + if ($PreviousCountry) { + $CountryList->{$PreviousCountry} //= $PreviousCountry; + } + + $Param{Option} = $LayoutObject->BuildSelection( + Data => $CountryList, + PossibleNone => 1, + Sort => 'AlphanumericValue', + Name => $Entry->[0], + Class => "$Param{RequiredClass} Modernize " . $Param{Errors}->{ $Entry->[0] . 'Invalid' }, + SelectedID => ( $Param{ $Entry->[0] } // 1 ), + ); + } + elsif ( $Entry->[0] =~ m/^ValidID/i ) { # Change the validation class if ( $Param{RequiredClass} ) { @@ -1232,7 +1267,7 @@ sub _Edit { ); } elsif ( - $Entry->[0] =~ /^UserCustomerID$/i + $Entry->[0] =~ m/^UserCustomerID$/i && $ConfigObject->Get( $Param{Source} )->{CustomerCompanySupport} ) {