Pflichtenhefte: Kontextmenüs für Items/Textblöcke auf größerer Fläche anzeigen
[kivitendo-erp.git] / SL / Controller / Helper / RequirementSpec.pm
1 package SL::Controller::Helper::RequirementSpec;
2
3 use strict;
4
5 use Exporter qw(import);
6 our @EXPORT = qw(init_visible_section set_function_blocks_tab_menu_class);
7
8 use SL::DB::Manager::RequirementSpecItem;
9
10 sub init_visible_section {
11   my ($self)       = @_;
12
13   my $content_id   = $::form->{current_content_id};
14   my $content_type = $::form->{current_content_type};
15
16   return undef unless $content_id;
17   return undef unless $content_type =~ m/section|function-block/;
18
19   $self->visible_item(SL::DB::Manager::RequirementSpecItem->find_by(id => $content_id));
20   return undef unless $self->visible_item;
21
22   return $self->visible_section($self->visible_item->section);
23 }
24
25 sub set_function_blocks_tab_menu_class {
26   my $self          = shift;
27   my %params        = Params::Validate::validate(@_, { class => 1 });
28
29   my $id            = '#function-blocks-tab';
30   my @other_classes = grep { $_ ne $params{class} } qw(section-context-menu text-block-context-menu);
31
32   $self->js->removeClass($id, $_) for @other_classes;
33   $self->js->addClass($id, $params{class});
34 }
35
36 1;