TT#177851 BillingNetworks close button (back) target selection

* target selection for chained routes in BillingNetworks is now
  performed based on the account that $c->stash->{close_target}
  can be already set, and it's used if defined instead of the
  explicit target
* add NGCP::Panel::Utils::Navigation::select_back_target()
* NGCP::Panel::Utils::Navigation::back_or() now uses internally
  select_back_target()

Change-Id: If6ca47a776896db48955a04f544731dc87c59aa1
mr11.0
Kirill Solomko 4 years ago committed by Oleksandr Lutai
parent 35edfb92e6
commit dcae99bc65

@ -182,7 +182,8 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) {
params => $c->request->params,
item => $params,
);
if($posted && $form->validated) {
if ($posted && $form->validated) {
try {
$c->model('DB')->schema->txn_do( sub {
@ -212,8 +213,13 @@ sub edit :Chained('base') :PathPart('edit') :Args(0) {
}
my $target =
NGCP::Panel::Utils::Navigation::select_back_target(
$c, $c->uri_for('/network')
);
$c->stash(
close_target => $c->uri_for,
close_target => $target,
edit_flag => 1,
form => $form
);

@ -81,9 +81,14 @@ sub check_form_buttons {
delete $form->values->{back} if $posted;
}
sub select_back_target {
my ($c, $alternative_target) = @_;
return $c->stash->{close_target} || $alternative_target || $c->req->uri;
}
sub back_or {
my ($c, $alternative_target, $nodetach) = @_;
my $target = $c->stash->{close_target} || $alternative_target || $c->req->uri;
my $target = select_back_target($c, $alternative_target);
$c->response->redirect($target);
$c->detach unless($nodetach);
}

Loading…
Cancel
Save