TT#48855 fix UI billing zones

* fix relative path use in billing zones ajax
      causing an error when rendering the datatable
    * fix BillingFee form field to correctly
      capture ajax datatable billing profile id
    * fix typo when stashing billing_zone_id
    * move billing zone datatable fields
      from base to zones_list

Change-Id: Ibbeb776a3bc6bfb26798fc13c1183ddb68a9d2fd
(cherry picked from commit b364746d1a)
changes/89/27689/1
Kirill Solomko 7 years ago committed by Irina Peshinskaya
parent adde2fe4d8
commit c07d64dc22

@ -98,12 +98,6 @@ sub base :Chained('profile_list') :PathPart('') :CaptureArgs(1) {
return;
}
$c->stash->{zone_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => 'id', search => 1, title => $c->loc('#') },
{ name => 'zone', search => 1, title => $c->loc('Zone') },
{ name => 'detail', search => 1, title => $c->loc('Zone Details') },
]);
my $res = $c->stash->{profiles_rs}->find($profile_id);
unless(defined($res)) {
NGCP::Panel::Utils::Message::error(
@ -386,7 +380,7 @@ sub fees_base :Chained('fees_list') :PathPart('') :CaptureArgs(1) {
return;
}
$c->stash(fee => {$res->get_columns}); #get_columns should not be used
$c->stash->{fee}->{'billing_zone.id'} = $res->billing_zone->id
$c->stash->{fee}->{'billing_zone_id'} = $res->billing_zone->id
if (defined $res->billing_zone);
$c->stash(fee_result => $res);
}
@ -532,7 +526,6 @@ sub fees_edit :Chained('fees_base') :PathPart('edit') :Args(0) {
$params->{billing_zone}{id} = delete $params->{billing_zone_id};
$params = merge($params, $c->session->{created_objects});
my $form = NGCP::Panel::Form::get("NGCP::Panel::Form::BillingFee", $c);
$form->field('billing_zone')->field('id')->ajax_src('../../zones/ajax');
$form->process(
posted => $posted,
params => $c->request->params,
@ -593,9 +586,16 @@ sub fees_delete :Chained('fees_base') :PathPart('delete') :Args(0) {
sub zones_list :Chained('base') :PathPart('zones') :CaptureArgs(0) {
my ($self, $c) = @_;
$c->stash->{zone_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => 'id', search => 1, title => $c->loc('#') },
{ name => 'zone', search => 1, title => $c->loc('Zone') },
{ name => 'detail', search => 1, title => $c->loc('Zone Details') },
]);
$c->stash( zones_root_uri =>
$c->uri_for_action('/billing/zones', [$c->req->captures->[0]])
);
$c->stash(template => 'billing/zones.tt');
}

@ -9,7 +9,8 @@ has_field 'id' => (
do_wrapper => 0,
required => 1,
template => 'helpers/datatables_field.tt',
ajax_src => '../zones/ajax', # /billing/<id>/zones/ajax
ajax_src => '/billing/zones/ajax',
adjust_datatable_vars => \&adjust_datatable_vars,
table_titles => ['#', 'Zone', 'Zone Detail'],
table_fields => ['id', 'zone', 'detail'],
);
@ -21,6 +22,17 @@ has_field 'create' => (
element_class => [qw/btn btn-tertiary pull-right/],
);
sub adjust_datatable_vars {
my ($self, $vars) = @_;
my $form = $self->form;
my $ctx = $form->ctx;
return unless $ctx;
my $billing_profile_id = $ctx->stash->{profile}->{id};
$vars->{ajax_src} = (
$ctx->uri_for_action('/billing/zones_ajax', [$billing_profile_id])->as_string
);
}
no Moose;
1;

Loading…
Cancel
Save