Revision 31ead75c
Von Moritz Bunkus vor mehr als 10 Jahren hinzugefügt
SL/Controller/RequirementSpec.pm | ||
---|---|---|
234 | 234 |
sub action_select_template_to_paste { |
235 | 235 |
my ($self) = @_; |
236 | 236 |
|
237 |
my @templates = grep { @{ $_->sections } || @{ $_->text_blocks } } @{ SL::DB::Manager::RequirementSpec->get_all(where => [ is_template => 1 ], sort_by => 'lower(title)') }; |
|
237 |
my @templates = @{ SL::DB::Manager::RequirementSpec->get_all( |
|
238 |
where => [ is_template => 1, SL::DB::Manager::RequirementSpec->not_empty_filter ], |
|
239 |
sort_by => 'lower(requirement_specs.title)', |
|
240 |
) }; |
|
238 | 241 |
$self->render('requirement_spec/select_template_to_paste', { layout => 0 }, TEMPLATES => \@templates); |
239 | 242 |
} |
240 | 243 |
|
... | ... | |
253 | 256 |
$self->render_first_pasted_section_as_list($result{sections}->[0]); |
254 | 257 |
} |
255 | 258 |
|
259 |
my $parts_list = $self->render('requirement_spec_part/show', { output => 0 }); |
|
260 |
$self->js |
|
261 |
->replaceWith('#additional_parts_list_container', $parts_list) |
|
262 |
->show( '#additional_parts_list_container') |
|
263 |
->remove( '#additional_parts_form_container'); |
|
264 |
|
|
256 | 265 |
$self->invalidate_version->render($self); |
257 | 266 |
} |
258 | 267 |
|
SL/DB/Manager/RequirementSpec.pm | ||
---|---|---|
29 | 29 |
return (working_copy_id => undef); |
30 | 30 |
} |
31 | 31 |
|
32 |
sub not_empty_filter { |
|
33 |
my @tables = qw(requirement_spec_items requirement_spec_text_blocks requirement_spec_parts); |
|
34 |
my @filter = map { \"id IN (SELECT nef_${_}.requirement_spec_id FROM ${_} nef_${_})" } @tables; |
|
35 |
|
|
36 |
return (or => \@filter); |
|
37 |
} |
|
38 |
|
|
32 | 39 |
1; |
SL/DB/RequirementSpec.pm | ||
---|---|---|
171 | 171 |
my %paste_template_result; |
172 | 172 |
|
173 | 173 |
# Clone text blocks and pictures. |
174 |
my $clone_picture = sub {
|
|
175 |
my ($picture) = @_;
|
|
176 |
my $cloned = Rose::DB::Object::Helpers::clone_and_reset($picture);
|
|
174 |
my $clone_and_reset_position = sub {
|
|
175 |
my ($src_obj) = @_;
|
|
176 |
my $cloned = Rose::DB::Object::Helpers::clone_and_reset($src_obj);
|
|
177 | 177 |
$cloned->position(undef); |
178 | 178 |
return $cloned; |
179 | 179 |
}; |
... | ... | |
182 | 182 |
my ($text_block) = @_; |
183 | 183 |
my $cloned = Rose::DB::Object::Helpers::clone_and_reset($text_block); |
184 | 184 |
$cloned->position(undef); |
185 |
$cloned->pictures([ map { $clone_picture->($_) } @{ $text_block->pictures_sorted } ]);
|
|
185 |
$cloned->pictures([ map { $clone_and_reset_position->($_) } @{ $text_block->pictures_sorted } ]);
|
|
186 | 186 |
return $cloned; |
187 | 187 |
}; |
188 | 188 |
|
... | ... | |
194 | 194 |
$self->add_text_blocks($paste_template_result{text_blocks}); |
195 | 195 |
} |
196 | 196 |
|
197 |
# Clone additional parts. |
|
198 |
$paste_template_result{parts} = [ map { $clone_and_reset_position->($_) } @{ $source->parts } ]; |
|
199 |
my $accessor = $params->{paste_template} ? "add_parts" : "parts"; |
|
200 |
$self->$accessor($paste_template_result{parts}); |
|
201 |
|
|
197 | 202 |
# Save new object -- we need its ID for the items. |
198 | 203 |
$self->save; |
199 | 204 |
|
locale/de/all | ||
---|---|---|
17 | 17 |
'#1 (custom variable)' => '#1 (benutzerdefinierte Variable)', |
18 | 18 |
'#1 - Account number #2, bank code #3, #4' => '#1 - Kontonummber #2, BLZ #3, #4', |
19 | 19 |
'#1 MD' => '#1 PT', |
20 |
'#1 additional part(s)' => '#1 zusätzliche(r) Artikel', |
|
20 | 21 |
'#1 h' => '#1 h', |
21 | 22 |
'#1 of #2 importable objects were imported.' => '#1 von #2 importierbaren Objekten wurden importiert.', |
22 | 23 |
'#1 prices were updated.' => '#1 Preise wurden aktualisiert.', |
templates/webpages/requirement_spec/select_template_to_paste.html | ||
---|---|---|
44 | 44 |
[% SET front = template.text_blocks_sorted(output_position=0) %] |
45 | 45 |
[% SET sections = template.sections_sorted %] |
46 | 46 |
[% SET back = template.text_blocks_sorted(output_position=1) %] |
47 |
[% SET parts = template.parts_sorted %] |
|
47 | 48 |
<td colspan="4"> |
48 | 49 |
[%- LxERP.t8("What this template contains") %]:<br> |
49 | 50 |
<ul> |
... | ... | |
60 | 61 |
[%- END %] |
61 | 62 |
|
62 | 63 |
[% PROCESS text_blocks blocks=back title=LxERP.t8("#1 text block(s) back", back.size) %] |
64 |
|
|
65 |
[%- IF parts.size %] |
|
66 |
<li>[%- LxERP.t8("#1 additional part(s)", parts.size) %]: |
|
67 |
<ol> |
|
68 |
[%- FOREACH part = parts %] |
|
69 |
<li>[%- HTML.escape(part.part.description) %]: [%- HTML.escape(part.qty_as_number) %] [% HTML.escape(part.unit.name) %]</li> |
|
70 |
[%- END %] |
|
71 |
</ol> |
|
72 |
</li> |
|
73 |
[%- END %] |
|
63 | 74 |
</ul> |
64 | 75 |
</td> |
65 | 76 |
</tr> |
Auch abrufbar als: Unified diff
Pflichtenhefte: beim Kopieren, Einfügen zusätzliche Artikel berücksichtigen