From 45d9fb34b5dce8ba250669e6e8ab04a4cab918d7 Mon Sep 17 00:00:00 2001 From: Kirill Solomko Date: Fri, 23 Dec 2022 17:41:04 +0100 Subject: [PATCH] MT#56286 fix subscriber profiles form and api update * subscriber profile form is fixed so that the attributes list is now correctly shown in the old UI * /api/subscriberprofiles update, attribute values are now correctly transformed for the validation and processing Change-Id: I4418250d4a0e702d75524ab5999eb47429be5a04 --- .../Panel/Form/SubscriberProfile/Profile.pm | 21 +++++++------------ lib/NGCP/Panel/Role/API/SubscriberProfiles.pm | 6 +++--- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/NGCP/Panel/Form/SubscriberProfile/Profile.pm b/lib/NGCP/Panel/Form/SubscriberProfile/Profile.pm index b6556e61c5..55227fb5ee 100644 --- a/lib/NGCP/Panel/Form/SubscriberProfile/Profile.pm +++ b/lib/NGCP/Panel/Form/SubscriberProfile/Profile.pm @@ -84,22 +84,17 @@ sub field_list { } ], }); - + my $fields = []; foreach my $pref($pref_rs->all) { my $desc = $pref->description; - push @{ $fields }, 'attribute.'.$pref->attribute => { - name => $pref->attribute, - type => 'Checkbox', - label => $pref->attribute, - checkbox_value => $pref->id, - element_attr => { - # rel => ['tooltip'], - # title => [$pref->description], - # checked => 'checked', - }, - disabled => $c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit} ? 1 : 0, - }; + push @{ $fields }, 'field_'.$pref->attribute => { + name => 'attribute.'.$pref->attribute, + type => 'Checkbox', + label => $pref->attribute, + checkbox_value => $pref->id, + disabled => $c->user->roles eq "reseller" && !$c->config->{profile_sets}->{reseller_edit} ? 1 : 0, + }; } return $fields; diff --git a/lib/NGCP/Panel/Role/API/SubscriberProfiles.pm b/lib/NGCP/Panel/Role/API/SubscriberProfiles.pm index 916279221e..ebf70bb679 100644 --- a/lib/NGCP/Panel/Role/API/SubscriberProfiles.pm +++ b/lib/NGCP/Panel/Role/API/SubscriberProfiles.pm @@ -99,7 +99,7 @@ sub update_item { return; } - $resource->{attribute} = delete $resource->{attributes}; + %{$resource->{attribute}} = map { $_ => 1 } @{ delete $resource->{attributes} }; $form //= $self->get_form($c); return unless $self->validate_form( c => $c, @@ -169,8 +169,8 @@ sub update_item { }, ], }); - foreach my $a(@{ $attributes }) { - my $meta = $meta_rs->find({ attribute => $a }); + foreach my $attr (keys %{$attributes}) { + my $meta = $meta_rs->find({ attribute => $attr }); next unless $meta; # mark as seen, so later we can unprovision the remaining ones, # which are the ones not set here: