TT#96652 Add suffix for emergency number.

Change-Id: I358c3dc3ec17a272cbab029d3893cf9d762dd1ef
mr11.0
Fabricio Santolin da Silva 3 years ago
parent cd4fb65b00
commit adbd256423

@ -47,6 +47,7 @@ sub list :Chained('/') :PathPart('emergencymapping') :CaptureArgs(0) {
{ name => "emergency_container.reseller.name", "search" => 1, "title" => $c->loc("Reseller") },
{ name => "code", "search" => 1, "title" => $c->loc("Emergency Number") },
{ name => "prefix", "search" => 1, "title" => $c->loc("Emergency Prefix") },
{ name => "suffix", "search" => 1, "title" => $c->loc("Emergency Suffix") },
]);
$c->stash(template => 'emergencymapping/list.tt');
@ -361,6 +362,7 @@ sub emergency_mapping_edit :Chained('emergency_mapping_base') :PathPart('edit')
my $schema = $c->model('DB');
$schema->txn_do(sub {
$form->values->{prefix} = undef unless(length $form->values->{prefix});
$form->values->{suffix} = undef unless(length $form->values->{suffix});
$c->stash->{emergency_mapping_result}->update($form->values);
});

@ -40,6 +40,16 @@ has_field 'prefix' => (
},
);
has_field 'suffix' => (
type => 'Text',
required => 0,
maxlength => 31,
element_attr => {
rel => ['tooltip'],
title => ['An optional emergency suffix the emergency code is mapped to.']
},
);
has_field 'save' => (
type => 'Submit',
@ -51,7 +61,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/emergency_container code prefix/],
render_list => [qw/emergency_container code prefix suffix/],
);
has_block 'actions' => (

@ -12,7 +12,7 @@ sub _insert_batch {
c => $c,
schema => $schema,
do_transaction => 0,
query => "REPLACE INTO provisioning.emergency_mappings(emergency_container_id, code, prefix)",
query => "REPLACE INTO provisioning.emergency_mappings(emergency_container_id, code, prefix, suffix)",
data => $mappings,
chunk_size => $chunk_size
);
@ -42,7 +42,7 @@ sub upload_csv {
});
#my @cols = @{ $c->config->{lnp_csv}->{element_order} };
my @cols = qw/name code prefix/;
my @cols = qw/name code prefix suffix/;
my @fields ;
my @fails = ();
@ -71,7 +71,10 @@ sub upload_csv {
unless(length $row->{prefix}) {
$row->{prefix} = undef;
}
push @mappings, [$containers{$k}, $row->{code}, $row->{prefix}];
unless(length $row->{suffix}) {
$row->{suffix} = undef;
}
push @mappings, [$containers{$k}, $row->{code}, $row->{prefix}, $row->{suffix}];
if($linenum % $chunk_size == 0) {
_insert_batch($c, $schema, \@mappings, $chunk_size);
@ -99,7 +102,7 @@ sub create_csv {
$emergency_mapping_rs //= $c->stash->{emergency_mapping_rs} // $c->model('DB')->resultset('emergency_mappings');
#my @cols = @{ $c->config->{emergency_mapping_csv}->{element_order} };
my @cols = qw/name code prefix/;
my @cols = qw/name code prefix suffix/;
my $mapping_rs = $emergency_mapping_rs->search_rs({

@ -24,6 +24,7 @@ $fake_data->set_data_from_script({
emergency_container_id => sub { return shift->get_id('emergencymappingcontainers', @_); },
code => "112",
prefix => "000",
suffix => "321",
},
file => [ (tempfile())[1] ],
},

Loading…
Cancel
Save