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);
}
$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);
}
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;
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;
};
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;
};
$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;
'#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.',
[% 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 %]
<td colspan="4">
[%- LxERP.t8("What this template contains") %]:<br>
<ul>
[%- END %]
[% PROCESS text_blocks blocks=back title=LxERP.t8("#1 text block(s) back", back.size) %]
+
+ [%- IF parts.size %]
+ <li>[%- LxERP.t8("#1 additional part(s)", parts.size) %]:
+ <ol>
+ [%- FOREACH part = parts %]
+ <li>[%- HTML.escape(part.part.description) %]: [%- HTML.escape(part.qty_as_number) %] [% HTML.escape(part.unit.name) %]</li>
+ [%- END %]
+ </ol>
+ </li>
+ [%- END %]
</ul>
</td>
</tr>