Skip to content

Commit

Permalink
Merge pull request #2786 from RotherOSS/issue-#205-cldr_customeruser
Browse files Browse the repository at this point in the history
Issue #205 cldr customeruser
  • Loading branch information
bschmalhofer authored Dec 25, 2023
2 parents 7850343 + eb86938 commit a755e4d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
11 changes: 9 additions & 2 deletions Kernel/Modules/AdminCustomerCompany.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
Expand All @@ -674,20 +674,27 @@ 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,
Sort => 'AlphanumericValue',
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 ) {
Expand Down
43 changes: 39 additions & 4 deletions Kernel/Modules/AdminCustomerUser.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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';

Expand All @@ -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} ) {
Expand All @@ -1232,7 +1267,7 @@ sub _Edit {
);
}
elsif (
$Entry->[0] =~ /^UserCustomerID$/i
$Entry->[0] =~ m/^UserCustomerID$/i
&& $ConfigObject->Get( $Param{Source} )->{CustomerCompanySupport}
)
{
Expand Down
6 changes: 6 additions & 0 deletions Kernel/System/ReferenceData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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{$_} }
Expand Down

0 comments on commit a755e4d

Please sign in to comment.