TT#41629 time sets to peering

time sets can now be added to peering groups (as per discussion with core)

Change-Id: Ia98061eb79b5e84e03190f348ec87d9e3b91bf57
changes/96/22896/6
Gerhard Jungwirth 7 years ago
parent 25efe6622e
commit 542b9f9cf3

@ -28,6 +28,7 @@ sub group_list :Chained('/') :PathPart('peering') :CaptureArgs(0) {
{ name => 'name', search => 1, title => $c->loc('Name') },
{ name => 'priority', search => 1, title => $c->loc('Priority') },
{ name => 'description', search => 1, title => $c->loc('Description') },
{ name => 'time_set.name', search => 0, title => $c->loc('Time Set') },
]);
$c->stash(template => 'peering/list.tt');
@ -120,6 +121,7 @@ sub edit :Chained('base') :PathPart('edit') {
my $form = NGCP::Panel::Form::get("NGCP::Panel::Form::Peering::Group", $c);
my $params = { $c->stash->{group_result}->get_inflated_columns };
$params->{contract}{id} = delete $params->{peering_contract_id};
$params->{time_set}{id} = delete $params->{time_set_id};
$params = merge($params, $c->session->{created_objects});
$form->process(
posted => $posted,
@ -563,6 +565,24 @@ sub servers_preferences_edit :Chained('servers_preferences_base') :PathPart('edi
return;
}
######## tmp until we have a TimeSet controller
sub tmp_timesets_ajax :Chained('group_list') :PathPart('timesetsajax') :Args(0) {
my ($self, $c) = @_;
$c->stash->{time_set_dt_columns} = NGCP::Panel::Utils::Datatables::set_columns($c, [
{ name => 'id', search => 1, title => $c->loc('#') },
{ name => 'reseller_id', search => 1, title => $c->loc('Reseller #') },
{ name => 'name', search => 1, title => $c->loc('Name') },
]);
my $resultset = $c->model('DB')->resultset('voip_time_sets');
NGCP::Panel::Utils::Datatables::process($c, $resultset, $c->stash->{time_set_dt_columns});
$c->detach( $c->view("JSON") );
return;
}
########
sub rules_list :Chained('base') :PathPart('rules') :CaptureArgs(0) {
my ($self, $c) = @_;
@ -673,6 +693,8 @@ sub rules_edit :Chained('rules_base') :PathPart('edit') :Args(0) {
);
if($posted && $form->validated) {
try {
$form->values->{time_set_id} = $form->values->{time_set}{id} // undef;
delete $form->values->{time_set};
$form->values->{callee_prefix} //= '';
$form->values->{group_id} = $form->values->{group}{id};
$c->stash->{rule_result}->update($form->values);

@ -0,0 +1,25 @@
package NGCP::Panel::Field::TimeSet;
use HTML::FormHandler::Moose;
extends 'HTML::FormHandler::Field::Compound';
has_field 'id' => (
type => '+NGCP::Panel::Field::DataTable',
label => 'TimeSet',
do_label => 0,
do_wrapper => 0,
required => 1,
template => 'helpers/datatables_field.tt',
ajax_src => '/peering/timesetsajax',
table_titles => ['#', 'Name', 'Reseller #'],
table_fields => ['id', 'name', 'reseller_id'],
);
has_field 'create' => (
type => 'Button',
do_label => 0,
value => 'Create Reseller',
element_class => [qw/btn btn-tertiary pull-right/],
);
no Moose;
1;

@ -32,6 +32,15 @@ has_field 'priority' => (
range_end => '9',
);
has_field 'time_set' => (
type => '+NGCP::Panel::Field::TimeSet',
#validate_when_empty => 1,
element_attr => {
rel => ['tooltip'],
title => ['By specifying a TimeSet the periods during which this group is active can be restricted.']
},
);
has_field 'description' => (
type => 'Text',
#not mandatory at the moment
@ -47,7 +56,7 @@ has_field 'save' => (
has_block 'fields' => (
tag => 'div',
class => [qw/modal-body/],
render_list => [qw/id contract name priority description/],
render_list => [qw/id contract name priority time_set description/],
);
has_block 'actions' => (
@ -64,6 +73,7 @@ sub custom_get_values {
priority => $fif->{priority},
description => $fif->{description},
peering_contract_id => $fif->{'contract.id'},
time_set_id => $fif->{'time_set.id'} || undef,
};
return $hashvalues;
}

Loading…
Cancel
Save