From a7467ebbb5ceff48fd79f1979c34ad9144321523 Mon Sep 17 00:00:00 2001 From: Andreas Granig Date: Tue, 16 Jul 2013 10:57:56 +0200 Subject: [PATCH] Properly set close target for correct work-flow. --- lib/NGCP/Panel/Controller/Subscriber.pm | 28 +++++++++++++++-------- share/templates/subscriber/preferences.tt | 10 ++++---- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/lib/NGCP/Panel/Controller/Subscriber.pm b/lib/NGCP/Panel/Controller/Subscriber.pm index 70b1ce06de..e84aaa0165 100644 --- a/lib/NGCP/Panel/Controller/Subscriber.pm +++ b/lib/NGCP/Panel/Controller/Subscriber.pm @@ -333,6 +333,7 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward' if($cf_mapping->count > 1) { # there is more than one mapping, # which can only be handled in advanced mode + $c->response->redirect( $c->uri_for_action('/subscriber/preferences_callforward_advanced', [$c->req->captures->[0]], $cf_type, 'advanced' @@ -551,7 +552,7 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal ), 'cf_actions.edit_destination_sets' => $c->uri_for_action('/subscriber/preferences_callforward_destinationset', - [$c->req->captures->[0]], + [$c->req->captures->[0]], $cf_type, ), # 'cf_actions.edit_time_sets' => # $c->uri_for_action('/subscriber/preferences_callforward_timeset', @@ -613,8 +614,8 @@ sub preferences_callforward_advanced :Chained('base') :PathPart('preferences/cal ); } -sub preferences_callforward_destinationset :Chained('base') :PathPart('preferences/destinationset') :Args(0) { - my ($self, $c, $type) = @_; +sub preferences_callforward_destinationset :Chained('base') :PathPart('preferences/destinationset') :Args(1) { + my ($self, $c, $cf_type) = @_; my $prov_subscriber = $c->stash->{subscriber}->provisioning_voip_subscriber; @@ -636,11 +637,15 @@ sub preferences_callforward_destinationset :Chained('base') :PathPart('preferenc my $cf_form = undef; + $self->load_preference_list($c); $c->stash(template => 'subscriber/preferences.tt'); $c->stash( edit_cfset_flag => 1, cf_description => "Destination Sets", cf_form => $cf_form, + close_target => $c->uri_for_action('/subscriber/preferences_callforward_advanced', + [$c->req->captures->[0]], $cf_type, 'advanced'), + cf_type => $cf_type, ); } @@ -652,11 +657,12 @@ sub preferences_callforward_destinationset_base :Chained('base') :PathPart('pref ->voip_cf_destination_sets ->find($set_id)); + $self->load_preference_list($c); $c->stash(template => 'subscriber/preferences.tt'); } -sub preferences_callforward_destinationset_edit :Chained('preferences_callforward_destinationset_base') :PathPart('edit') :Args(0) { - my ($self, $c) = @_; +sub preferences_callforward_destinationset_edit :Chained('preferences_callforward_destinationset_base') :PathPart('edit') :Args(1) { + my ($self, $c, $cf_type) = @_; my $form = NGCP::Panel::Form::DestinationSet->new; @@ -698,7 +704,7 @@ sub preferences_callforward_destinationset_edit :Chained('preferences_callforwar $c->response->redirect( $c->uri_for_action('/subscriber/preferences_callforward_destinationset', - [$c->req->captures->[0]]) + [$c->req->captures->[0]], $cf_type) ); return; } @@ -724,7 +730,7 @@ sub preferences_callforward_destinationset_edit :Chained('preferences_callforwar } $c->response->redirect( $c->uri_for_action('/subscriber/preferences_callforward_destinationset', - [$c->req->captures->[0]]) + [$c->req->captures->[0]], $cf_type) ); return; }); @@ -732,7 +738,7 @@ sub preferences_callforward_destinationset_edit :Chained('preferences_callforwar $c->log->error("failed to update destination set: $e"); $c->response->redirect( $c->uri_for_action('/subscriber/preferences_callforward_destinationset', - [$c->req->captures->[0]]) + [$c->req->captures->[0]], $cf_type) ); return; } @@ -742,12 +748,14 @@ sub preferences_callforward_destinationset_edit :Chained('preferences_callforwar edit_cf_flag => 1, cf_description => "Destination Set", cf_form => $form, + close_target => $c->uri_for_action('/subscriber/preferences_callforward_destinationset', + [$c->req->captures->[0]], $cf_type), ); } -sub preferences_callforward_destinationset_delete :Chained('preferences_callforward_destinationset_base') :PathPart('delete') :Args(0) { - my ($self, $c) = @_; +sub preferences_callforward_destinationset_delete :Chained('preferences_callforward_destinationset_base') :PathPart('delete') :Args(1) { + my ($self, $c, $cf_type) = @_; # TODO: also delete/update voip_usr_preference! diff --git a/share/templates/subscriber/preferences.tt b/share/templates/subscriber/preferences.tt index 5a628c7a3d..01022aea96 100644 --- a/share/templates/subscriber/preferences.tt +++ b/share/templates/subscriber/preferences.tt @@ -108,7 +108,7 @@
Edit [% IF cf_mappings.${cf.type}.id -%] - Delete + Delete [% END -%]
@@ -140,7 +140,7 @@ [% modal_footer(); - modal_script(m.close_target = c.uri_for_action('/subscriber/preferences', [c.req.captures.0])); + modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0])); -%] [% ELSIF edit_cfset_flag -%] [% @@ -169,10 +169,10 @@
- + Edit - + Delete
@@ -186,7 +186,7 @@ [% modal_footer(); - modal_script(m.close_target = c.uri_for_action('/subscriber/preferences', [c.req.captures.0])); + modal_script(m.close_target = close_target ? close_target : c.uri_for_action('/subscriber/preferences', [c.req.captures.0])); -%] [% END -%]