1 package SL::Controller::Helper::RequirementSpec;
5 use Exporter qw(import);
6 our @EXPORT = qw(init_visible_section set_function_blocks_tab_menu_class);
8 use SL::DB::Manager::RequirementSpecItem;
10 sub init_visible_section {
13 my $content_id = $::form->{current_content_id};
14 my $content_type = $::form->{current_content_type};
16 return undef unless $content_id;
17 return undef unless $content_type =~ m/section|function-block/;
19 $self->visible_item(SL::DB::Manager::RequirementSpecItem->find_by(id => $content_id));
20 return undef unless $self->visible_item;
22 return $self->visible_section($self->visible_item->section);
25 sub set_function_blocks_tab_menu_class {
27 my %params = Params::Validate::validate(@_, { class => 1 });
29 my $id = '#function-blocks-tab';
30 my @other_classes = grep { $_ ne $params{class} } qw(section-context-menu text-block-context-menu);
32 $self->js->removeClass($id, $_) for @other_classes;
33 $self->js->addClass($id, $params{class});