Implement CF deletion and visual cleanups.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent 6937ac595f
commit 0573234779

@ -231,17 +231,19 @@ sub preferences :Chained('base') :PathPart('preferences') :Args(0) {
my $prov_subscriber = $c->stash->{subscriber}->provisioning_voip_subscriber;
my $cfs = {};
my $mappings = {};
for my $type(qw/cfu cfna cft cfb/) {
$c->stash('cf_mappings_'.$type => $prov_subscriber->voip_cf_mappings
->find({ type => $type }));
if(defined $c->stash->{'cf_mappings_'.$type}) {
$cfs->{$type} = [ $c->stash->{'cf_mappings_'.$type}
$mappings->{$type} = $prov_subscriber->voip_cf_mappings
->find({ type => $type });
if(defined $mappings->{$type}) {
$cfs->{$type} = [ $mappings->{$type}
->destination_set
->voip_cf_destinations->search({},
{ order_by => { -asc => 'priority' }}
)->all ];
}
}
$c->stash(cf_mappings => $mappings);
$c->stash(cf_destinations => $cfs);
my $ringtimeout_preference = $c->model('DB')->resultset('voip_preferences')->search({
attribute => 'ringtimeout', 'usr_pref' => 1,
@ -446,18 +448,22 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
cf_description => $cf_desc,
cf_form => $cf_form,
);
}
sub preferences_callforward_delete :Chained('base') :PathPart('preferences/callforward/delete') :Args(1) {
my ($self, $c, $cfmap_id) = @_;
try {
$c->model('DB')->resultset('voip_cf_mappings')->find($cfmap_id)->delete;
$c->flash(messages => [{type => 'success', text => 'Successfully deleted Call Forward'}]);
} catch($e) {
$c->log->error("failed to delete call forward mapping: $e");
$c->flash(messages => [{type => 'error', text => 'Failed to deleted Call Forward'}]);
}
$c->response->redirect($c->uri_for_action('/subscriber/preferences', [$c->req->captures->[0]]));
}
sub load_preference_list :Private {
my ($self, $c) = @_;

@ -7,7 +7,15 @@ extends 'HTML::FormHandler';
has '+widget_wrapper' => (default => 'Bootstrap');
has_field 'id' => (type => 'Hidden');
has_field 'destination' => (type => 'Text', required => 1,);
has_field 'destination' => (
type => 'Text',
required => 1,
element_attr => {
rel => ['tooltip'],
title => ['Either a number (e.g. “431234”), a SIP user (e.g. “peter” or a full SIP URI (e.g. “sip:peter@example.org”)']
},
);
has_field 'save' => (type => 'Submit', element_class => [qw(btn btn-primary)],);
has_block 'fields' => (
tag => 'div',

@ -8,6 +8,10 @@ has_field 'ringtimeout' => (
type => 'PosInteger',
required => 1,
label => 'after ring timeout',
element_attr => {
rel => ['tooltip'],
title => ['Seconds to wait for pick-up until engaging Call Forward (e.g. “10”)']
},
);
has_block 'fields' => (
tag => 'div',

@ -58,7 +58,7 @@
{ type = "cfna", desc = "Unavailable" } ] -%]
<tr class="sw_action_row">
<td>Call Forward [% cf.desc %]</td>
<td>[% cf_ringtimeout IF cf.type == "cft" && cf_destinations.${cf.type}.size %]</td>
<td>[% cf_ringtimeout _ 's' IF cf.type == "cft" && cf_destinations.${cf.type}.size %]</td>
<td>
[% FOR d IN cf_destinations.${cf.type} -%]
[% d.destination %] <span class="pull-right">for [% d.timeout %]s</span><br/>
@ -66,8 +66,11 @@
</td>
<td>[% 'always' IF cf_destinations.${cf.type}.size %]</td>
<td class="ngcp-actions-column">
<div class="sw_actions pull-right">
<div class="sw_actions">
<a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0, cf.type]) %]"><i class="icon-edit"></i> Edit</a>
[% IF cf_mappings.${cf.type}.id -%]
<a class="btn btn-secondary btn-small" data-confirm="Delete" href="[% c.uri_for_action("/subscriber/preferences_callforward_delete", [c.req.captures.0, cf_mappings.${cf.type}.id]) %]"><i class="icon-edit"></i> Delete</a>
[% END -%]
</div>
</td>

Loading…
Cancel
Save