Add Call Forward Forms.

agranig/1_0_subfix
Andreas Granig 13 years ago
parent 477a9720a4
commit 818716b2cd

@ -4,6 +4,8 @@ use namespace::sweep;
BEGIN { extends 'Catalyst::Controller'; }
use NGCP::Panel::Utils::Contract;
use NGCP::Panel::Form::Subscriber;
use NGCP::Panel::Form::SubscriberCFSimple;
use NGCP::Panel::Form::SubscriberCFTSimple;
use UUID;
use Data::Printer;
@ -272,6 +274,39 @@ sub preferences_edit :Chained('preferences_base') :PathPart('edit') :Args(0) {
);
}
sub preferences_callforward :Chained('base') :PathPart('preferences/callforward') :Args(1) {
my ($self, $c, $cf_type) = @_;
my $cf_desc;
given($cf_type) {
when("cfu") { $cf_desc = "Unconditional" }
when("cfb") { $cf_desc = "Busy" }
when("cft") { $cf_desc = "Timeout" }
when("cfna") { $cf_desc = "Unavailable" }
default {
$c->flash(messages => [{type => 'error', text => 'Invalid Call Forward type'}]);
$c->response->redirect($c->uri_for_action('/subscriber/preferences', [$c->req->captures->[0]]));
return;
}
}
my $cf_form;
if($cf_type eq "cft") {
$cf_form = NGCP::Panel::Form::SubscriberCFTSimple->new;
} else {
$cf_form = NGCP::Panel::Form::SubscriberCFSimple->new;
}
$self->load_preference_list($c);
$c->stash(template => 'subscriber/preferences.tt');
$c->stash(
edit_cf_flag => 1,
cf_description => $cf_desc,
cf_form => $cf_form,
);
}
sub load_preference_list :Private {
my ($self, $c) = @_;

@ -0,0 +1,27 @@
package NGCP::Panel::Form::SubscriberCFSimple;
use HTML::FormHandler::Moose;
use HTML::FormHandler::Widget::Block::Bootstrap;
use Moose::Util::TypeConstraints;
extends 'HTML::FormHandler';
has '+widget_wrapper' => (default => 'Bootstrap');
has_field 'id' => (type => 'Hidden');
has_field 'destination' => (type => 'Text', required => 1,);
has_field 'save' => (type => 'Submit', element_class => [qw(btn btn-primary)],);
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(destination)],
);
has_block 'actions' => (tag => 'div', class => [qw(modal-footer)], render_list => [qw(save)],);
sub build_render_list {
return [qw(id fields actions)];
}
sub build_form_element_class {
return [qw(form-horizontal)];
}
1;

@ -0,0 +1,18 @@
package NGCP::Panel::Form::SubscriberCFTSimple;
use HTML::FormHandler::Moose;
use HTML::FormHandler::Widget::Block::Bootstrap;
use Moose::Util::TypeConstraints;
extends 'NGCP::Panel::Form::SubscriberCFSimple';
has_field 'ringtimeout' => (
type => 'PosInteger',
required => 1,
label => 'after ring timeout',
);
has_block 'fields' => (
tag => 'div',
class => [qw(modal-body)],
render_list => [qw(destination ringtimeout)],
);
1;

@ -35,7 +35,7 @@
<div class="accordion" id="preference_groups">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_cf">Test</a>
<a class="accordion-toggle" data-toggle="collapse" data-parent="#preference_groups" href="#collapse_cf">Call Forwards</a>
</div>
<div class="accordion-body collapse" id="collapse_cf">
<div class="accordion-inner">
@ -48,11 +48,11 @@
<th>Destinations</th>
<th>Period</th>
[% # one for actions -%]
<th class="span3"></th>
<th class="ngcp-actions-column"></th>
</tr>
</thead>
<tbody>
<tr>
<tr class="sw_action_row">
<td>Call Forward Unconditional</td>
<td></td>
<td>
@ -61,9 +61,14 @@
voicebox
</td>
<td>always</td>
<td class="span3"></td>
<td class="ngcp-actions-column">
<div class="sw_actions pull-right">
<a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0, "cfu"]) %]"><i class="icon-edit"></i> Edit</a>
</div>
</td>
</tr>
<tr>
<tr class="sw_action_row">
<td>Call Forward Busy</td>
<td></td>
<td>
@ -72,9 +77,14 @@
voicebox
</td>
<td>always</td>
<td class="span3"></td>
<td class="ngcp-actions-column">
<div class="sw_actions pull-right">
<a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0, "cfb"]) %]"><i class="icon-edit"></i> Edit</a>
</div>
</td>
</tr>
<tr>
<tr class="sw_action_row">
<td>Call Forward Timeout</td>
<td>15s</td>
<td>
@ -83,9 +93,13 @@
voicebox
</td>
<td>always</td>
<td class="span3"></td>
<td class="ngcp-actions-column">
<div class="sw_actions pull-right">
<a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0, "cft"]) %]"><i class="icon-edit"></i> Edit</a>
</div>
</td>
</tr>
<tr>
<tr class="sw_action_row">
<td>Call Forward Unavailable</td>
<td></td>
<td>
@ -94,7 +108,12 @@
voicebox
</td>
<td>always</td>
<td class="span3"></td>
<td class="ngcp-actions-column">
<div class="sw_actions pull-right">
<a class="btn btn-primary btn-small" href="[% c.uri_for_action("/subscriber/preferences_callforward", [c.req.captures.0, "cfna"]) %]"><i class="icon-edit"></i> Edit</a>
</div>
</td>
</tr>
</tbody>
</table>
@ -108,4 +127,18 @@
PROCESS 'helpers/pref_table.tt';
%]
[% IF edit_cf_flag -%]
[%
PROCESS "helpers/modal.tt";
modal_header(m.name = "Call Forward " _ cf_description);
-%]
[% cf_form.render(); %]
[%
modal_footer();
modal_script(m.close_target = c.uri_for_action('/subscriber/preferences', [c.req.captures.0]));
-%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

Loading…
Cancel
Save