TT#76751 - Fix CF creation when not sending 'enabled' param

* Default to 1 if no 'enabled' param is sent
	 * Send mapping's 'enabled' value to UI Form
	   to stop defaulting to 1 when trying to edit

Change-Id: Iec22f878bd87999c85a0cc99eabcda68fd7f2985
changes/03/38303/2
Flaviu Mates 6 years ago
parent fac975fef7
commit a51a7560bc

@ -913,7 +913,7 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
my $ringtimeout_preference = NGCP::Panel::Utils::Preferences::get_usr_preference_rs( my $ringtimeout_preference = NGCP::Panel::Utils::Preferences::get_usr_preference_rs(
c => $c, prov_subscriber => $prov_subscriber, attribute => 'ringtimeout'); c => $c, prov_subscriber => $prov_subscriber, attribute => 'ringtimeout');
my $cf_mapping = $prov_subscriber->voip_cf_mappings->search_rs({ type => $cf_type }); my $cf_mapping = $prov_subscriber->voip_cf_mappings->search_rs({ type => $cf_type });
my $destination; my ($destination, $enabled);
if($cf_mapping->count > 1) { if($cf_mapping->count > 1) {
# there is more than one mapping, # there is more than one mapping,
@ -943,6 +943,7 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
return; return;
} }
$destination = $cf_mapping->first->destination_set->voip_cf_destinations->first; $destination = $cf_mapping->first->destination_set->voip_cf_destinations->first;
$enabled = $cf_mapping->first->enabled;
} }
my $params = {}; my $params = {};
@ -983,6 +984,7 @@ sub preferences_callforward :Chained('base') :PathPart('preferences/callforward'
$params->{destination}{destination} = $d; $params->{destination}{destination} = $d;
$params->{ringtimeout} = $ringtimeout; $params->{ringtimeout} = $ringtimeout;
$params->{destination}->{announcement_id} = $destination ? $destination->announcement_id : ''; $params->{destination}->{announcement_id} = $destination ? $destination->announcement_id : '';
$params->{enabled} = $enabled // 0;
} }
my $cf_form; my $cf_form;

@ -248,7 +248,7 @@ sub update_item {
source_set_id => $sset ? $sset->id : undef, source_set_id => $sset ? $sset->id : undef,
bnumber_set_id => $bset ? $bset->id : undef, bnumber_set_id => $bset ? $bset->id : undef,
type => $type, type => $type,
enabled => $mapping->{enabled}, enabled => defined $mapping->{enabled} ? $mapping->{enabled} : 1,
}); });
} }
} }

Loading…
Cancel
Save