Pflichtenhefte: Kontextmenüs für Items/Textblöcke auf größerer Fläche anzeigen
authorMoritz Bunkus <m.bunkus@linet-services.de>
Thu, 18 Jul 2013 13:36:37 +0000 (15:36 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 1 Apr 2014 11:09:07 +0000 (13:09 +0200)
SL/Controller/Helper/RequirementSpec.pm
SL/Controller/RequirementSpecItem.pm
SL/Controller/RequirementSpecTextBlock.pm
templates/webpages/requirement_spec/show.html

index b24c4aa..3ba23fb 100644 (file)
@@ -3,7 +3,7 @@ package SL::Controller::Helper::RequirementSpec;
 use strict;
 
 use Exporter qw(import);
-our @EXPORT = qw(init_visible_section);
+our @EXPORT = qw(init_visible_section set_function_blocks_tab_menu_class);
 
 use SL::DB::Manager::RequirementSpecItem;
 
@@ -22,4 +22,15 @@ sub init_visible_section {
   return $self->visible_section($self->visible_item->section);
 }
 
+sub set_function_blocks_tab_menu_class {
+  my $self          = shift;
+  my %params        = Params::Validate::validate(@_, { class => 1 });
+
+  my $id            = '#function-blocks-tab';
+  my @other_classes = grep { $_ ne $params{class} } qw(section-context-menu text-block-context-menu);
+
+  $self->js->removeClass($id, $_) for @other_classes;
+  $self->js->addClass($id, $params{class});
+}
+
 1;
index 6b833f7..ce24e31 100644 (file)
@@ -226,7 +226,8 @@ sub action_ajax_edit {
     # Show section/item to edit if it is not visible.
 
     my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item->section);
-    $self->js->html('#column-content', $html);
+    $self->set_function_blocks_tab_menu_class(class => 'section-context-menu')
+      ->html('#column-content', $html);
   }
 
   if ($self->item->item_type =~ m/section/) {
@@ -329,7 +330,7 @@ sub action_ajax_delete {
 
     } else {
       my $html = $self->render('requirement_spec_item/_no_section', { output => 0 });
-      $self->js
+      $self->set_function_blocks_tab_menu_class(class => 'section-context-menu')
         ->html('#column-content',      $html)
         ->val('#current_content_type', '')
         ->val('#current_content_id',   '')
@@ -466,8 +467,9 @@ sub action_ajax_paste {
   # Pasting the very first section?
   if (!@{ $self->sections }) {
     my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->item);
-    $self->js->html('#column-content', $html)
-             ->jstree->select_node('#tree', '#fb-' . $self->item->id)
+    $self->set_function_blocks_tab_menu_class(class => 'section-context-menu')
+         ->html('#column-content', $html)
+         ->jstree->select_node('#tree', '#fb-' . $self->item->id)
   }
 
   # Update the current view if required.
@@ -532,7 +534,8 @@ sub render_list {
   my ($self, $item, $item_to_select) = @_;
 
   my $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $item);
-  $self->js->html('#column-content', $html);
+  $self->set_function_blocks_tab_menu_class(class => 'section-context-menu')
+       ->html('#column-content', $html);
   $self->select_node($item_to_select || $item);
 }
 
@@ -569,7 +572,7 @@ sub ensure_section_is_shown {
   my $new_section = $self->item->section;
   my $html        = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $new_section);
 
-  return $self->js
+  return $self->set_function_blocks_tab_menu_class(class => 'section-context-menu')
     ->html('#column-content', $html)
     ->val('#current_content_type', 'section')
     ->val('#current_content_id',   $new_section->id)
index 9be5a29..7faf16d 100644 (file)
@@ -10,6 +10,7 @@ use Time::HiRes ();
 
 use SL::ClientJS;
 use SL::Clipboard;
+use SL::Controller::Helper::RequirementSpec;
 use SL::DB::RequirementSpec;
 use SL::DB::RequirementSpecPredefinedText;
 use SL::DB::RequirementSpecTextBlock;
@@ -337,7 +338,7 @@ sub show_list {
      ->val('#current_content_id',   $params{id});
   }
 
-  return $self->js;
+  return $self->set_function_blocks_tab_menu_class(class => 'text-block-context-menu');
 }
 
 1;
index f532118..9a173a5 100644 (file)
@@ -17,7 +17,7 @@
   [%- END %]
  </ul>
 
- <div id="function-blocks-tab">
+ <div id="function-blocks-tab" class="section-context-menu">
   [%- UNLESS SELF.requirement_spec.is_template %]
    <div id="requirement_spec_version">
     [%- INCLUDE 'requirement_spec/_version.html' requirement_spec=SELF.requirement_spec -%]