TT#68752 - Implement translation handling of 'Select' form field

* Create new 'Select' field type that includes
	  'translate' attribute which shows is a field
	   should be translated

	 * Change fields that should not be translated
	   to the new field type

Change-Id: I723e82e609a7b4fc879e4fe708227c012cba1923
changes/74/34274/2
Flaviu Mates 6 years ago
parent db8a2306f6
commit 2052c466e9

@ -0,0 +1,9 @@
package NGCP::Panel::Field::Select;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Select';
has 'translate' => (isa => 'Bool', is => 'rw', default => 1 );
no Moose;
1;

@ -11,7 +11,7 @@ sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class {[qw(form-horizontal)]}
has_field 'profile_id' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
required => 1,
label => 'Device',
options_method => \&build_profiles,
@ -19,6 +19,7 @@ has_field 'profile_id' => (
rel => ['tooltip'],
title => ['The PBX device.']
},
translate => 0,
);
sub build_profiles {
my ($self) = @_;

@ -105,12 +105,13 @@ has_field 'destination.priority' => (
);
has_field 'destination.announcement_id' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
#widget => 'RadioGroup',
label => 'Custom announcement',
options_method => \&build_announcements,
wrapper_class => [qw/hfh-rep-field ngcp-destination ngcp-destination-customhours/],
required => 0,
translate => 0,
);

@ -4,10 +4,11 @@ use HTML::FormHandler::Moose;
extends 'NGCP::Panel::Form::Domain::Reseller';
has_field 'rwr_set' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Rewrite Rule Set',
options_method => \&build_rwr_sets,
default => undef,
translate => 0,
);
sub build_rwr_sets {

@ -53,9 +53,10 @@ has_field 'weight' => (
);
has_field 'via_route' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Via Route',
options_method => \&build_via_routes,
translate => 0,
);
sub build_via_routes {

@ -48,8 +48,9 @@ sub field_list {
unshift @options, {label => '', value => ''};
$field = {
name => $meta->attribute,
type => 'Select',
type => '+NGCP::Panel::Field::Select',
options => \@options,
translate => 0,
};
} elsif($meta->attribute eq "cdr_export_sclidui_rwrs") {
my @options = map {{label => $_->name, value => $_->id}}
@ -66,8 +67,9 @@ sub field_list {
unshift @options, {label => '', value => ''};
$field = {
name => $meta->attribute,
type => 'Select',
type => '+NGCP::Panel::Field::Select',
options => \@options,
translate => 0,
};
} elsif ($meta->attribute eq "ncos" ||
$meta->attribute eq "adm_ncos" ||
@ -95,7 +97,7 @@ sub field_list {
unshift @options, {label => '', value => ''};
$field = {
name => $meta->attribute,
type => 'Select',
type => '+NGCP::Panel::Field::Select',
options => \@options,
};
} elsif ($meta->attribute eq "contract_sound_set") {

@ -11,10 +11,11 @@ sub build_render_list {[qw/submitid host folder select/]}
sub build_form_element_class {[qw(form-horizontal)]}
has_field 'host' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Host:',
options_method => \&set_hosts,
required => 1,
translate => 0,
);
sub set_hosts {
@ -31,10 +32,11 @@ sub set_hosts {
}
has_field 'folder' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Category:',
options_method => \&set_folders,
required => 1,
translate => 0,
);
sub set_folders {

@ -44,7 +44,7 @@ has_field 'q' => (
);
has_field 'socket' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Outbound socket',
required => 0,
options_method => \&build_socket_options,
@ -52,6 +52,7 @@ has_field 'socket' => (
rel => ['tooltip'],
title => ['Points to the LB interface from which the incoming calls to this registration should be sent out.']
},
translate => 0
);
sub build_socket_options {

@ -14,11 +14,12 @@ sub build_render_list {[qw/submitid fields actions/]}
sub build_form_element_class { [qw/form-horizontal/] }
has_field 'slot' => (
type => 'Select',
type => '+NGCP::Panel::Field::Select',
label => 'Slot',
options_method => \&set_slots,
required => 1,
wrapper_class => [qw/hfh-rep-field/],
translate => 0,
);
sub set_slots {

@ -29,7 +29,7 @@ sub _translate_fields_recursive {
if ($field->isa('HTML::FormHandler::Field::Select')) {
for my $option (@{ $field->options }) {
push @strings, $option->{label} if $extract_strings;
$option->{label} = $c->loc($option->{label}) if $option->{label};
$option->{label} = $c->loc($option->{label}) if ( $option->{label} && (($field->can('translate') && $field->translate) || !$field->can('translate')) );
}
}
if ($field->element_attr->{title}[0]) {

Loading…
Cancel
Save