From 31ead75c81bed1ebb1ac65475205e24cded34af5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 30 Jul 2014 16:12:30 +0200 Subject: [PATCH] =?utf8?q?Pflichtenhefte:=20beim=20Kopieren,=20Einf=C3=BCg?= =?utf8?q?en=20zus=C3=A4tzliche=20Artikel=20ber=C3=BCcksichtigen?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- SL/Controller/RequirementSpec.pm | 11 ++++++++++- SL/DB/Manager/RequirementSpec.pm | 7 +++++++ SL/DB/RequirementSpec.pm | 13 +++++++++---- locale/de/all | 1 + .../requirement_spec/select_template_to_paste.html | 11 +++++++++++ 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/SL/Controller/RequirementSpec.pm b/SL/Controller/RequirementSpec.pm index 7e25d7e7d..a29c7cb92 100644 --- a/SL/Controller/RequirementSpec.pm +++ b/SL/Controller/RequirementSpec.pm @@ -234,7 +234,10 @@ sub action_create_pdf { sub action_select_template_to_paste { my ($self) = @_; - my @templates = grep { @{ $_->sections } || @{ $_->text_blocks } } @{ SL::DB::Manager::RequirementSpec->get_all(where => [ is_template => 1 ], sort_by => 'lower(title)') }; + my @templates = @{ SL::DB::Manager::RequirementSpec->get_all( + where => [ is_template => 1, SL::DB::Manager::RequirementSpec->not_empty_filter ], + sort_by => 'lower(requirement_specs.title)', + ) }; $self->render('requirement_spec/select_template_to_paste', { layout => 0 }, TEMPLATES => \@templates); } @@ -253,6 +256,12 @@ sub action_paste_template { $self->render_first_pasted_section_as_list($result{sections}->[0]); } + my $parts_list = $self->render('requirement_spec_part/show', { output => 0 }); + $self->js + ->replaceWith('#additional_parts_list_container', $parts_list) + ->show( '#additional_parts_list_container') + ->remove( '#additional_parts_form_container'); + $self->invalidate_version->render($self); } diff --git a/SL/DB/Manager/RequirementSpec.pm b/SL/DB/Manager/RequirementSpec.pm index 2d54d769a..fecd9d358 100644 --- a/SL/DB/Manager/RequirementSpec.pm +++ b/SL/DB/Manager/RequirementSpec.pm @@ -29,4 +29,11 @@ sub working_copy_filter { return (working_copy_id => undef); } +sub not_empty_filter { + my @tables = qw(requirement_spec_items requirement_spec_text_blocks requirement_spec_parts); + my @filter = map { \"id IN (SELECT nef_${_}.requirement_spec_id FROM ${_} nef_${_})" } @tables; + + return (or => \@filter); +} + 1; diff --git a/SL/DB/RequirementSpec.pm b/SL/DB/RequirementSpec.pm index 235444047..cd603aa6f 100644 --- a/SL/DB/RequirementSpec.pm +++ b/SL/DB/RequirementSpec.pm @@ -171,9 +171,9 @@ sub _copy_from { my %paste_template_result; # Clone text blocks and pictures. - my $clone_picture = sub { - my ($picture) = @_; - my $cloned = Rose::DB::Object::Helpers::clone_and_reset($picture); + my $clone_and_reset_position = sub { + my ($src_obj) = @_; + my $cloned = Rose::DB::Object::Helpers::clone_and_reset($src_obj); $cloned->position(undef); return $cloned; }; @@ -182,7 +182,7 @@ sub _copy_from { my ($text_block) = @_; my $cloned = Rose::DB::Object::Helpers::clone_and_reset($text_block); $cloned->position(undef); - $cloned->pictures([ map { $clone_picture->($_) } @{ $text_block->pictures_sorted } ]); + $cloned->pictures([ map { $clone_and_reset_position->($_) } @{ $text_block->pictures_sorted } ]); return $cloned; }; @@ -194,6 +194,11 @@ sub _copy_from { $self->add_text_blocks($paste_template_result{text_blocks}); } + # Clone additional parts. + $paste_template_result{parts} = [ map { $clone_and_reset_position->($_) } @{ $source->parts } ]; + my $accessor = $params->{paste_template} ? "add_parts" : "parts"; + $self->$accessor($paste_template_result{parts}); + # Save new object -- we need its ID for the items. $self->save; diff --git a/locale/de/all b/locale/de/all index d6664b5fa..b29a899e4 100755 --- a/locale/de/all +++ b/locale/de/all @@ -17,6 +17,7 @@ $self->{texts} = { '#1 (custom variable)' => '#1 (benutzerdefinierte Variable)', '#1 - Account number #2, bank code #3, #4' => '#1 - Kontonummber #2, BLZ #3, #4', '#1 MD' => '#1 PT', + '#1 additional part(s)' => '#1 zusätzliche(r) Artikel', '#1 h' => '#1 h', '#1 of #2 importable objects were imported.' => '#1 von #2 importierbaren Objekten wurden importiert.', '#1 prices were updated.' => '#1 Preise wurden aktualisiert.', diff --git a/templates/webpages/requirement_spec/select_template_to_paste.html b/templates/webpages/requirement_spec/select_template_to_paste.html index 3399d590b..3ddeb2d1c 100644 --- a/templates/webpages/requirement_spec/select_template_to_paste.html +++ b/templates/webpages/requirement_spec/select_template_to_paste.html @@ -44,6 +44,7 @@ [% SET front = template.text_blocks_sorted(output_position=0) %] [% SET sections = template.sections_sorted %] [% SET back = template.text_blocks_sorted(output_position=1) %] + [% SET parts = template.parts_sorted %] [%- LxERP.t8("What this template contains") %]:
-- 2.20.1