Pflichtenhefte: Druckvorlagendateinamen bei Pflicthenhefttypen festlegen können
[kivitendo-erp.git] / SL / Controller / RequirementSpec.pm
index 58a0374..6afe997 100644 (file)
@@ -86,26 +86,27 @@ sub action_new {
   $self->render('requirement_spec/new', title => $self->requirement_spec->is_template ? t8('Create a new requirement spec template') : t8('Create a new requirement spec'));
 }
 
-sub action_ajax_edit {
+sub action_ajax_show_basic_settings {
   my ($self) = @_;
 
-  $self->render('requirement_spec/_form', { layout => 0 }, submit_as => 'ajax');
+  $self->render('requirement_spec/_show_basic_settings', { layout => 0 });
 }
 
-sub action_ajax_show_time_and_cost_estimate {
+sub action_ajax_edit {
   my ($self) = @_;
 
-  $self->render('requirement_spec/_show_time_and_cost_estimate', { layout => 0 });
+  my $html   = $self->render('requirement_spec/_form', { output => 0 }, submit_as => 'ajax');
+
+  $self->js
+    ->hide('#basic_settings')
+    ->after('#basic_settings', $html)
+    ->render($self);
 }
 
-sub action_ajax_cancel_time_and_cost_estimate {
+sub action_ajax_show_time_and_cost_estimate {
   my ($self) = @_;
 
-  my $html   = $self->render('requirement_spec/_show_time_and_cost_estimate', { output => 0 });
-
-  $self->js
-   ->replaceWith('#time_cost_estimate', $html)
-   ->render($self);
+  $self->render('requirement_spec/_show_time_and_cost_estimate', { layout => 0 });
 }
 
 sub action_ajax_edit_time_and_cost_estimate {
@@ -114,7 +115,8 @@ sub action_ajax_edit_time_and_cost_estimate {
   my $html   = $self->render('requirement_spec/_edit_time_and_cost_estimate', { output => 0 });
 
   $self->js
-   ->replaceWith('#time_cost_estimate', $html)
+   ->hide('#time_cost_estimate')
+   ->after('#time_cost_estimate', $html)
    ->on('#time_cost_estimate INPUT[type=text]', 'keydown', 'kivi.requirement_spec.time_cost_estimate_input_key_down')
    ->render($self);
 }
@@ -138,7 +140,8 @@ sub action_ajax_save_time_and_cost_estimate {
   $self->requirement_spec(SL::DB::RequirementSpec->new(id => $self->requirement_spec->id)->load);
 
   my $html = $self->render('requirement_spec/_show_time_and_cost_estimate', { output => 0 });
-  $self->js->replaceWith('#time_cost_estimate', $html);
+  $self->js->replaceWith('#time_cost_estimate', $html)
+           ->remove('#time_cost_estimate_form_container');
 
   if ($self->visible_section) {
     $html = $self->render('requirement_spec_item/_section', { output => 0 }, requirement_spec_item => $self->visible_section);
@@ -201,7 +204,8 @@ sub action_revert_to {
 sub action_create_pdf {
   my ($self, %params) = @_;
 
-  my %result = SL::Template::LaTeX->parse_and_create_pdf('requirement_spec.tex', SELF => $self, rspec => $self->requirement_spec);
+  my $base_name       = $self->requirement_spec->type->template_file_name || 'requirement_spec';
+  my %result          = SL::Template::LaTeX->parse_and_create_pdf("${base_name}.tex", SELF => $self, rspec => $self->requirement_spec);
 
   $::form->error(t8('Conversion to PDF failed: #1', $result{error})) if $result{error};
 
@@ -346,9 +350,12 @@ sub create_or_update {
   my $info = $self->requirement_spec->is_template ? t8('The requirement spec template has been saved.') : t8('The requirement spec has been saved.');
 
   if ($::request->is_ajax) {
-    my $html = $self->render('requirement_spec/_header', { output => 0 });
+    my $header_html = $self->render('requirement_spec/_header', { output => 0 });
+    my $basics_html = $self->render('requirement_spec/_show_basic_settings', { output => 0 });
     return $self->invalidate_version
-      ->replaceWith('#requirement-spec-header', $html)
+      ->replaceWith('#requirement-spec-header', $header_html)
+      ->replaceWith('#basic_settings',          $basics_html)
+      ->remove('#basic_settings_form')
       ->flash('info', $info)
       ->render($self);
   }