diff --git a/lib/NGCP/Panel/Controller/API/Root.pm b/lib/NGCP/Panel/Controller/API/Root.pm index ff4529ccc6..97d10fe1c1 100644 --- a/lib/NGCP/Panel/Controller/API/Root.pm +++ b/lib/NGCP/Panel/Controller/API/Root.pm @@ -364,6 +364,8 @@ sub field_to_json : Private { return "Object"; /\+NGCP::Panel::Field::DatePicker/ && return "String"; + /\+NGCP::Panel::Field::NumRangeAPI/ && + return "String"; # usually {xxx}{id} /\+NGCP::Panel::Field::/ && return "Number"; @@ -396,6 +398,8 @@ sub get_field_poperties :Private{ $field->type eq "Hidden" || $field->type eq "Button" || $field->type eq "Submit" || + $field->type eq "AddElement" || + $field->type eq "RmElement" || 0); my @types = (); push @types, 'null' unless ($field->required || $field->validate_when_empty); @@ -411,7 +415,7 @@ sub get_field_poperties :Private{ $name = 'country'; } elsif($field->type =~ /LnpCarrier$/) { $name = 'carrier_id'; - } elsif($field->type !~ /Regex|EmailList|Identifier|PosInteger|Interval|Select|DateTime|URI|IPAddress|DatePicker|ProfileNetwork|CFSimpleAPICompound/) { # ...? + } elsif($field->type !~ /Regex|EmailList|Identifier|PosInteger|Interval|Select|DateTime|URI|IPAddress|DatePicker|ProfileNetwork|CFSimpleAPICompound|NumRangeAPI|IntegerList/) { # ...? $name .= '_id'; } } @@ -430,14 +434,36 @@ sub get_field_poperties :Private{ unless (defined $desc && length($desc) > 0) { $desc = 'to be described ...'; } + + my $subfields; + if ($field->has_fields && scalar ($field->fields)) { + my ($firstsub) = $field->fields; + if ($field->isa('HTML::FormHandler::Field::Repeatable') && $firstsub) { + ($subfields) = $self->get_collection_properties($firstsub, 1); + } elsif ($firstsub->type eq '+NGCP::Panel::Field::DataTable' && $name =~ /_id$/) { + # don't render subfields (only DataTable Field with Button) + } elsif ($firstsub->type eq '+NGCP::Panel::Field::DataTable' && $name =~ /^(country|timezone)$/) { + # also don't render subfields of country and timezone (they have no _id ending) + } elsif ($field->type eq 'String' && $name =~ /^(domain)$/) { + # another special case, special syntax of domain in subscribers + } else { + ($subfields) = $self->get_collection_properties($field, 1); + } + } + return { name => $name, description => $desc, types => \@types, type_original => $field->type, - readonly => $field->readonly, ($enum ? (enum => $enum) : ()) }; + readonly => $field->readonly, + ($enum ? (enum => $enum) : ()), + ($subfields ? (subfields => $subfields) : ()), + }; } sub get_collection_properties { - my ($self, $form) = @_; + my ($self, $form, $is_nested) = @_; - my $renderlist = $form->form->blocks->{fields}->{render_list}; + my $renderlist = $form->form && !$is_nested + ? $form->form->blocks->{fields}->{render_list} + : undef; my %renderlist = defined $renderlist ? map { $_ => 1 } @{$renderlist} : (); my @props = (); @@ -458,6 +484,7 @@ sub get_collection_properties { } } @props = sort{$a->{name} cmp $b->{name}} @props; + return (\@props,\@uploads); } diff --git a/lib/NGCP/Panel/Form/Rtc/AppsReseller.pm b/lib/NGCP/Panel/Form/Rtc/AppsReseller.pm index 9813336fa3..23072232f5 100644 --- a/lib/NGCP/Panel/Form/Rtc/AppsReseller.pm +++ b/lib/NGCP/Panel/Form/Rtc/AppsReseller.pm @@ -18,12 +18,13 @@ has_field 'rtc_user_id' => ( rel => ['tooltip'], title => ['ID in the backend RTC API (readonly).'], }, + readonly => 1, ); has_field 'apps' => ( type => 'Repeatable', required => 0, #1, - setup_for_js => 1, + #setup_for_js => 1, do_wrapper => 1, do_label => 0, tags => { @@ -34,6 +35,8 @@ has_field 'apps' => ( rel => ['tooltip'], title => ['An array of objects with keys "name", "domain", "secret" and "api_key" to create RTC apps for this reseller'], }, + num_when_empty => 1, + add_extra => 1, ); has_field 'apps.domain' => ( @@ -58,6 +61,7 @@ has_field 'apps.secret' => ( rel => ['tooltip'], title => ['The secret (readonly).'], }, + readonly => 1, ); has_field 'apps.api_key' => ( @@ -66,6 +70,7 @@ has_field 'apps.api_key' => ( rel => ['tooltip'], title => ['The API key (readonly).'], }, + readonly => 1, ); has_field 'save' => ( diff --git a/lib/NGCP/Panel/Form/Rtc/NetworksReseller.pm b/lib/NGCP/Panel/Form/Rtc/NetworksReseller.pm index a5bbb6d197..15ca3bded7 100644 --- a/lib/NGCP/Panel/Form/Rtc/NetworksReseller.pm +++ b/lib/NGCP/Panel/Form/Rtc/NetworksReseller.pm @@ -18,6 +18,7 @@ has_field 'rtc_user_id' => ( rel => ['tooltip'], title => ['ID in the backend RTC API (readonly).'], }, + readonly => 1, ); has_field 'networks' => ( diff --git a/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm b/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm index 71cd6949a5..d87075dfdb 100644 --- a/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm +++ b/lib/NGCP/Panel/Form/Subscriber/SubscriberAPI.pm @@ -27,13 +27,9 @@ has_field 'display_name' => ( ); has_field 'alias_numbers' => ( - type => '+NGCP::Panel::Field::AliasNumber', - setup_for_js => 1, + type => 'Repeatable', do_wrapper => 1, do_label => 0, - tags => { - controls_div => 1, - }, wrapper_class => [qw/hfh-rep/], element_attr => { rel => ['tooltip'], @@ -41,6 +37,10 @@ has_field 'alias_numbers' => ( }, ); +has_field 'alias_numbers.contains' => ( + type => '+NGCP::Panel::Field::E164', +); + has_field 'lock' => ( type => '+NGCP::Panel::Field::SubscriberLockSelect', label => 'Lock Level', diff --git a/lib/NGCP/Panel/Form/Voicemail/Meta.pm b/lib/NGCP/Panel/Form/Voicemail/Meta.pm index 816cfd115c..25043b6dd4 100644 --- a/lib/NGCP/Panel/Form/Voicemail/Meta.pm +++ b/lib/NGCP/Panel/Form/Voicemail/Meta.pm @@ -3,13 +3,6 @@ package NGCP::Panel::Form::Voicemail::Meta; use HTML::FormHandler::Moose; extends 'HTML::FormHandler'; -use HTML::FormHandler::Widget::Block::Bootstrap; - -has '+widget_wrapper' => ( default => 'Bootstrap' ); -has_field 'submitid' => ( type => 'Hidden' ); -sub build_render_list {[qw/submitid fields actions/]} -sub build_form_element_class { [qw/form-horizontal/] } - has_field 'subscriber_id' => ( type => 'PosInteger', label => 'Subscriber ID', @@ -73,24 +66,5 @@ has_field 'folder' => ( ] ); -has_field 'save' => ( - type => 'Submit', - value => 'Save', - element_class => [qw/btn btn-primary/], - label => '', -); - -has_block 'fields' => ( - tag => 'div', - class => [qw/modal-body/], - render_list => [qw/folder/], -); - -has_block 'actions' => ( - tag => 'div', - class => [qw/modal-footer/], - render_list => [qw/save/], -); - 1; # vim: set tabstop=4 expandtab: diff --git a/share/templates/api/root/collection.tt b/share/templates/api/root/collection.tt index 8ffc9a2527..011a9ce9fd 100644 --- a/share/templates/api/root/collection.tt +++ b/share/templates/api/root/collection.tt @@ -92,7 +92,15 @@ See description how to obtain properties, if any. [% ELSE -%]