diff --git a/lib/NGCP/Panel/Controller/Device.pm b/lib/NGCP/Panel/Controller/Device.pm index 92a563f8fa..5417f04daa 100644 --- a/lib/NGCP/Panel/Controller/Device.pm +++ b/lib/NGCP/Panel/Controller/Device.pm @@ -759,6 +759,23 @@ sub devprof_base :Chained('base') :PathPart('profile') :CaptureArgs(1) :Does(ACL } } +sub devprof_get_lines :Chained('devprof_base') :PathPart('lines/ajax') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) :AllowedRole(subscriberadmin) { + my ($self, $c) = @_; + + # fooooo + my $resultset = $c->stash->{devprof}->config->device->autoprov_device_line_ranges; + my $cols = NGCP::Panel::Utils::Datatables::set_columns($c, [ + { name => 'name', search => 1, title => 'Name' }, + { name => 'num_lines', search => 1, title => 'Number of Lines/Keys' }, + { name => 'can_private', search => 1, title => 'Private Line' }, + { name => 'can_shared', search => 1, title => 'Shared Line' }, + { name => 'can_blf', search => 1, title => 'BLF Key' }, + ]); + NGCP::Panel::Utils::Datatables::process($c, $resultset, $cols); + $c->detach( $c->view("JSON") ); +} + + sub devprof_delete :Chained('devprof_base') :PathPart('delete') :Args(0) { my ($self, $c) = @_; diff --git a/lib/NGCP/Panel/Form/Customer/PbxFieldDevice.pm b/lib/NGCP/Panel/Form/Customer/PbxFieldDevice.pm index 1481815513..53687fe060 100644 --- a/lib/NGCP/Panel/Form/Customer/PbxFieldDevice.pm +++ b/lib/NGCP/Panel/Form/Customer/PbxFieldDevice.pm @@ -6,6 +6,8 @@ use Moose::Util::TypeConstraints; use HTML::FormHandler::Widget::Block::Bootstrap; +with 'NGCP::Panel::Render::RepeatableJs'; + has '+widget_wrapper' => ( default => 'Bootstrap' ); has_field 'submitid' => ( type => 'Hidden' ); sub build_render_list {[qw/submitid fields actions/]} @@ -22,6 +24,7 @@ sub build_profiles { my $c = $self->form->ctx; my $profile_rs = $c->stash->{autoprov_profile_rs}; my @options = (); + push @options, { label => '', value => undef }; foreach my $p($profile_rs->all) { push @options, { label => $p->name, value => $p->id }; } @@ -34,12 +37,58 @@ has_field 'identifier' => ( label => 'MAC Address / Identifier', ); -has_field 'subscriber_id' => ( +has_field 'line' => ( + type => 'Repeatable', + label => 'Lines/Keys', + setup_for_js => 1, + do_wrapper => 1, + do_label => 1, + required => 1, + tags => { + controls_div => 1, + }, + wrapper_class => [qw/hfh-rep-block/], +); + +has_field 'line.id' => ( + type => 'Hidden', +); + +has_field 'line.subscriber_id' => ( type => 'Select', required => 1, label => 'Subscriber', options_method => \&build_subscribers, + element_attr => { + rel => ['tooltip'], + title => ['The subscriber to use on this line/key'], + }, +); + +has_field 'line.line' => ( + type => 'Select', + required => 1, + label => 'Line/Key', + options => [], + element_attr => { + rel => ['tooltip'], + title => ['The line/key to use'], + }, +); + + +has_field 'line.type' => ( + type => 'Select', + required => 1, + label => 'Line/Key Type', + options => [], + element_attr => { + rel => ['tooltip'], + title => ['The type of feature to use on this line/key'], + }, ); + + sub build_subscribers { my ($self) = @_; my $c = $self->form->ctx; @@ -55,6 +104,21 @@ sub build_subscribers { return \@options; } +has_field 'line.rm' => ( + type => 'RmElement', + value => 'Remove', + order => 100, + element_class => [qw/btn btn-primary pull-right/], +); + +has_field 'line_add' => ( + type => 'AddElement', + repeatable => 'line', + value => 'Add another Line/Key', + element_class => [qw/btn btn-primary pull-right/], +); + + has_field 'save' => ( type => 'Submit', value => 'Save', @@ -65,7 +129,7 @@ has_field 'save' => ( has_block 'fields' => ( tag => 'div', class => [qw/modal-body/], - render_list => [qw/profile_id identifier subscriber_id/], + render_list => [qw/profile_id identifier line line_add/], ); has_block 'actions' => ( diff --git a/share/templates/customer/details.tt b/share/templates/customer/details.tt index afe7b6d53d..7cf46defc7 100644 --- a/share/templates/customer/details.tt +++ b/share/templates/customer/details.tt @@ -415,6 +415,9 @@ [% IF create_flag == 1 -%] [% + IF form.has_for_js; + form.render_repeatable_js; + END; PROCESS "helpers/modal.tt"; modal_header(m.create_flag = create_flag, m.name = description.defined ? description : "Subscriber"); @@ -424,6 +427,9 @@ -%] [% ELSIF edit_flag == 1 -%] [% + IF form.has_for_js; + form.render_repeatable_js; + END; PROCESS "helpers/modal.tt"; modal_header(m.create_flag=0, m.name = "Settings"); @@ -508,5 +514,61 @@ }); [% END -%] +[% IF c.config.features.cloudpbx -%] + +[% END -%] [% # vim: set tabstop=4 syntax=html expandtab: -%]