X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FController%2FCustomVariableConfig.pm;h=456fe7176141c6a42043100cad45443af7b3678e;hb=c0158b6b111fa98fbde66a300237133c999bfb9f;hp=744d58aca0d3a2428b84c27bf97dfb0ee11cd794;hpb=28f6dabe8291ed96238eaa7f48556c6915ddad1d;p=kivitendo-erp.git diff --git a/SL/Controller/CustomVariableConfig.pm b/SL/Controller/CustomVariableConfig.pm index 744d58aca..456fe7176 100644 --- a/SL/Controller/CustomVariableConfig.pm +++ b/SL/Controller/CustomVariableConfig.pm @@ -8,6 +8,7 @@ use List::Util qw(first); use SL::DB::CustomVariableConfig; use SL::DB::CustomVariableValidity; +use SL::DB::PartsGroup; use SL::Helper::Flash; use SL::Locale::String; use Data::Dumper; @@ -66,6 +67,9 @@ sub show_form { split m/:/, ($self->config->flags || '') }); + $params{all_partsgroups} = SL::DB::Manager::PartsGroup->get_all(); + + $::request->layout->use_javascript("${_}.js") for qw(jquery.selectboxes jquery.multiselect2side); $self->render('custom_variable_config/form', %params); } @@ -90,6 +94,9 @@ sub action_update { sub action_destroy { my ($self) = @_; + # delete relationship to partsgroups (for filter) before cvar can be deleted + $self->config->update_attributes(partsgroups => []); + if (eval { $self->config->delete; 1; }) { flash_later('info', t8('The custom variable has been deleted.')); } else { @@ -151,12 +158,13 @@ sub init_translated_types { sub init_modules { my ($self, %params) = @_; - return [ - { module => 'CT', description => t8('Customers and vendors') }, - { module => 'Contacts', description => t8('Contact persons') }, - { module => 'IC', description => t8('Parts, services and assemblies') }, - { module => 'Projects', description => t8('Projects') }, - ]; + return [ sort { $a->{description}->translated cmp $b->{description}->translated } ( + { module => 'CT', description => t8('Customers and vendors') }, + { module => 'Contacts', description => t8('Contact persons') }, + { module => 'IC', description => t8('Parts, services and assemblies') }, + { module => 'Projects', description => t8('Projects') }, + { module => 'RequirementSpecs', description => t8('Requirement Specs') }, + )]; } sub create_or_update { @@ -166,6 +174,14 @@ sub create_or_update { my $params = delete($::form->{config}) || { }; delete $params->{id}; + if ($self->module eq 'IC') { + $params->{partsgroups} = [] if !$params->{flag_partsgroup_filter}; + } else { + delete $params->{flag_partsgroup_filter}; + $params->{partsgroups} = []; + } + + $params->{partsgroups} ||= []; # The list is empty, if control is not send by the browser. $params->{default_value} = $::form->parse_amount(\%::myconfig, $params->{default_value}) if $params->{type} eq 'number'; $params->{included_by_default} = 0 if !$params->{includeable}; $params->{flags} = join ':', map { m/^flag_(.*)/; "${1}=" . delete($params->{$_}) } grep { m/^flag_/ } keys %{ $params };