Textblöcke bearbeiten, verschieben: verschiedene Fixes
[kivitendo-erp.git] / SL / Controller / RequirementSpec.pm
index b865d29..2c1139e 100644 (file)
@@ -19,11 +19,11 @@ use SL::Locale::String;
 
 use Rose::Object::MakeMethods::Generic
 (
- scalar => [ qw(requirement_spec customers projects types statuses db_args flat_filter is_template) ],
+ scalar => [ qw(requirement_spec requirement_spec_item customers projects types statuses db_args flat_filter is_template) ],
 );
 
 __PACKAGE__->run_before('setup');
-__PACKAGE__->run_before('load_requirement_spec',      only => [ qw(    edit        update destroy) ]);
+__PACKAGE__->run_before('load_requirement_spec',      only => [ qw(    edit        update show destroy) ]);
 __PACKAGE__->run_before('load_select_options',        only => [ qw(new edit create update list) ]);
 __PACKAGE__->run_before('load_search_select_options', only => [ qw(                       list) ]);
 
@@ -77,6 +77,15 @@ sub action_edit {
   $self->render('requirement_spec/form', title => t8('Edit requirement spec'));
 }
 
+sub action_show {
+  my ($self) = @_;
+
+  my $item = $::form->{requirement_spec_item_id} ? SL::DB::RequirementSpecItem->new(id => $::form->{requirement_spec_item_id})->load : @{ $self->requirement_spec->sections }[0];
+  $self->requirement_spec_item($item);
+
+  $self->render('requirement_spec/show', title => t8('Show requirement spec'));
+}
+
 sub action_create {
   my ($self) = @_;
 
@@ -117,12 +126,37 @@ sub setup {
   my ($self) = @_;
 
   $::auth->assert('config');
-  $::request->{layout}->use_stylesheet("requirement_spec.css");
+  $::request->{layout}->use_stylesheet("${_}.css") for qw(jquery.contextMenu requirement_spec);
+  $::request->{layout}->use_javascript("${_}.js") for qw(jquery.jstree jquery/jquery.contextMenu client_js requirement_spec);
   $self->is_template($::form->{is_template} ? 1 : 0);
 
   return 1;
 }
 
+sub load_requirement_spec {
+  my ($self) = @_;
+  $self->{requirement_spec} = SL::DB::RequirementSpec->new(id => $::form->{id})->load || die "No such requirement spec";
+}
+
+sub load_select_options {
+  my ($self) = @_;
+
+  my @filter = ('!obsolete' => 1);
+  if ($self->requirement_spec && $self->requirement_spec->customer_id) {
+    @filter = ( or => [ @filter, id => $self->requirement_spec->customer_id ] );
+  }
+
+  $self->customers(SL::DB::Manager::Customer->get_all_sorted(where => \@filter));
+  $self->statuses( SL::DB::Manager::RequirementSpecStatus->get_all_sorted);
+  $self->types(    SL::DB::Manager::RequirementSpecType->get_all_sorted);
+}
+
+sub load_search_select_options {
+  my ($self) = @_;
+
+  $self->projects(SL::DB::Manager::Project->get_all_sorted);
+}
+
 #
 # helpers
 #
@@ -149,30 +183,6 @@ sub create_or_update {
   $self->redirect_to(action => 'list');
 }
 
-sub load_requirement_spec {
-  my ($self) = @_;
-  $self->{requirement_spec} = SL::DB::RequirementSpec->new(id => $::form->{id})->load;
-}
-
-sub load_select_options {
-  my ($self) = @_;
-
-  my @filter = ('!obsolete' => 1);
-  if ($self->requirement_spec && $self->requirement_spec->customer_id) {
-    @filter = ( or => [ @filter, id => $self->requirement_spec->customer_id ] );
-  }
-
-  $self->customers(SL::DB::Manager::Customer->get_all_sorted(where => \@filter));
-  $self->statuses( SL::DB::Manager::RequirementSpecStatus->get_all_sorted);
-  $self->types(    SL::DB::Manager::RequirementSpecType->get_all_sorted);
-}
-
-sub load_search_select_options {
-  my ($self) = @_;
-
-  $self->projects(SL::DB::Manager::Project->get_all_sorted);
-}
-
 sub setup_db_args_from_filter {
   my ($self) = @_;