Revision 2e19b5c0
Von Tamino Steinert vor 10 Monaten hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
244 | 244 |
$select_tag_options{empty_title} = t8("Select Variant Property First"); |
245 | 245 |
} |
246 | 246 |
|
247 |
foreach my $variant (@{$self->part->variants}) { |
|
248 |
my $select_tag_name = "add_variant_property_value_" . $variant->id; |
|
249 |
my $new_select_tag = select_tag( |
|
250 |
$select_tag_name, \@options, |
|
251 |
%select_tag_options |
|
252 |
); |
|
253 |
$self->js->replaceWith("#$select_tag_name", $new_select_tag); |
|
254 |
} |
|
247 |
my $new_select_tag = select_tag( |
|
248 |
"variants[].add_variant_property_value", \@options, |
|
249 |
%select_tag_options |
|
250 |
); |
|
251 |
$self->js->replaceWith('[name^="variants[].add_variant_property_value"]', $new_select_tag); |
|
252 |
|
|
253 |
my $new_select_tag_multible = select_tag( |
|
254 |
"add_variant_property_value_for_selected_variants", \@options, |
|
255 |
%select_tag_options |
|
256 |
); |
|
257 |
$self->js->replaceWith("#add_variant_property_value_for_selected_variants", $new_select_tag_multible); |
|
255 | 258 |
|
256 | 259 |
$self->js->render(); |
257 | 260 |
} |
... | ... | |
261 | 264 |
|
262 | 265 |
my $variant_property_id = $::form->{add_variant_property}; |
263 | 266 |
die t8("Please select a variant property") unless ($variant_property_id); |
267 |
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}}; |
|
264 | 268 |
foreach my $variant (@{$self->part->variants}) { |
265 | 269 |
die t8("Please select a new variant property value for all variants") |
266 |
unless $::form->{"add_variant_property_value_" . $variant->id};
|
|
270 |
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
|
|
267 | 271 |
} |
268 | 272 |
|
269 | 273 |
SL::DB->client->with_transaction(sub { |
... | ... | |
274 | 278 |
foreach my $variant (@{$self->part->variants}) { |
275 | 279 |
SL::DB::VariantPropertyValuePart->new( |
276 | 280 |
part_id => $variant->id, |
277 |
variant_property_value_id => $::form->{"add_variant_property_value_" . $variant->id},
|
|
281 |
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
|
|
278 | 282 |
)->save; |
279 | 283 |
} |
280 | 284 |
1; |
js/kivi.Part.js | ||
---|---|---|
137 | 137 |
$(new_rows).appendTo($('#parent_variant_table')); |
138 | 138 |
}; |
139 | 139 |
|
140 |
ns.get_selected_variants = function() { |
|
141 |
let selected_rows = []; |
|
142 |
$('[name^="variant_multi_id_"]').each( function() { |
|
143 |
if (this.checked) { |
|
144 |
selected_rows.push($(this).parents("tr").first()); |
|
145 |
} |
|
146 |
}); |
|
147 |
return selected_rows; |
|
148 |
} |
|
149 |
|
|
150 |
ns.variant_rows_toggle_selected = function() { |
|
151 |
$('[name^="variant_multi_id_"]').each( function() { |
|
152 |
this.checked = !this.checked; |
|
153 |
}); |
|
154 |
} |
|
155 |
|
|
156 |
ns.set_selected_variants_to_value = function(value_name) { |
|
157 |
let value = $('[name="' + value_name + '_for_selected_variants"]').val(); |
|
158 |
let selected_rows = ns.get_selected_variants(); |
|
159 |
selected_rows.forEach(function(row) { |
|
160 |
$(row).find( |
|
161 |
'[name="variants[].' + value_name + '"]' |
|
162 |
).val( |
|
163 |
value |
|
164 |
); |
|
165 |
}); |
|
166 |
}; |
|
167 |
|
|
140 | 168 |
ns.assortment_recalc = function() { |
141 | 169 |
var data = $('#assortment :input').serializeArray(); |
142 | 170 |
data.push( |
... | ... | |
915 | 943 |
|
916 | 944 |
$('#part_warehouse_id').change(kivi.Part.reload_bin_selection); |
917 | 945 |
|
946 |
$('#variant_select_all').click( function() { |
|
947 |
var checked = this.checked; |
|
948 |
$('[name^="variant_multi_id_"]').each(function() { |
|
949 |
this.checked = checked; |
|
950 |
}); |
|
951 |
}); |
|
952 |
|
|
918 | 953 |
ns.init(); |
919 | 954 |
}); |
920 | 955 |
}); |
templates/design40_webpages/part/_parent_variant.html | ||
---|---|---|
12 | 12 |
[% LxERP.t8("Variants") %] |
13 | 13 |
</caption> |
14 | 14 |
<thead> |
15 |
<th></th> |
|
15 |
<tr> |
|
16 |
<th> |
|
17 |
[% L.checkbox_tag("varaint_select_all_multi_id", |
|
18 |
checked=0, id='variant_select_all' |
|
19 |
alt=LxERP.t8('Select/Deselect all'), title=LxERP.t8('Select/Deselect all'), |
|
20 |
) %] |
|
21 |
</th> |
|
16 | 22 |
<th id="variant_partnumber_header_id"> |
17 | 23 |
<a href='#' onClick='javascript:kivi.Part.reorder_variants("partnumber")'> |
18 | 24 |
[% 'Partnumber' | $T8 %] |
... | ... | |
43 | 49 |
)%] |
44 | 50 |
[% L.button_tag('kivi.Part.add_variant_property();', LxERP.t8("Insert new")) %] |
45 | 51 |
</th> |
52 |
</tr> |
|
53 |
<tr> |
|
54 |
<th class="center"> |
|
55 |
[%- L.button_tag('kivi.Part.variant_rows_toggle_selected();', "🔄", |
|
56 |
title=LxERP.t8("Toggle selection"), |
|
57 |
alt=LxERP.t8("Toggle selection"), |
|
58 |
) %] |
|
59 |
</th> |
|
60 |
<th></th> |
|
61 |
<th> |
|
62 |
[% L.input_tag("description_for_selected_variants", SELF.part.description, |
|
63 |
class="wi-medium", |
|
64 |
) %] |
|
65 |
[%- L.button_tag( |
|
66 |
'kivi.Part.set_selected_variants_to_value("description")', |
|
67 |
"↓", |
|
68 |
alt=LxERP.t8('Apply to selected rows'), |
|
69 |
title=LxERP.t8('Apply to selected rows'), |
|
70 |
) %] |
|
71 |
</th> |
|
72 |
<th colspan="[% SELF.part.variant_properties.size + 1 %]"></th> |
|
73 |
<th> |
|
74 |
[% L.select_tag("add_variant_property_value_for_selected_variants", [] |
|
75 |
title_key='displayable_name', value_key='id', |
|
76 |
with_empty=1, empty_title=LxERP.t8("Select Variant Property First"), |
|
77 |
) %] |
|
78 |
[%- L.button_tag( |
|
79 |
'kivi.Part.set_selected_variants_to_value("add_variant_property_value")', |
|
80 |
"↓", |
|
81 |
alt=LxERP.t8('Apply to selected rows'), |
|
82 |
title=LxERP.t8('Apply to selected rows'), |
|
83 |
) %] |
|
84 |
</th> |
|
85 |
</tr> |
|
46 | 86 |
</thead> |
47 | 87 |
<tbody class="listrow"> |
48 | 88 |
[% FOREACH variant = SELF.part.variants %] |
49 | 89 |
<tr class="variant_row_entry"> |
90 |
[% L.hidden_tag("variants[+].id", variant.id, id='variant_' _ variant.id) %] |
|
91 |
[% L.hidden_tag("variants[].position", loop.count) %] |
|
50 | 92 |
<td> |
51 |
[% L.hidden_tag("variants[+].id", variant.id) %] |
|
52 |
[% L.hidden_tag("variants[].position", loop.count) %] |
|
93 |
[% L.checkbox_tag('variant_multi_id_' _ loop.count, value=variant.id, checked=0) %] |
|
53 | 94 |
</td> |
54 | 95 |
<td>[% variant.presenter.part %]</td> |
55 |
<td>[% variant.description | html %]</td> |
|
96 |
<td> |
|
97 |
[% L.input_tag("variants[].description", variant.description, class="wi-medium") %] |
|
98 |
</td> |
|
56 | 99 |
<td>[% variant.variant_values | html %]</td> |
57 | 100 |
[% FOREACH variant_property = SELF.part.variant_properties %] |
58 | 101 |
<td> [% variant.variant_value(variant_property) %] </td> |
59 | 102 |
[% END %] |
60 | 103 |
<td> |
61 |
[% L.select_tag("add_variant_property_value_" _ variant.id, []
|
|
104 |
[% L.select_tag("variants[].add_variant_property_value", []
|
|
62 | 105 |
title_key='displayable_name', value_key='id', |
63 | 106 |
with_empty=1, empty_title=LxERP.t8("Select Variant Property First"), |
64 | 107 |
) %] |
Auch abrufbar als: Unified diff
Varianten: Schnellbearbeitung von Varianten