Revision b00c1e17
Von Tamino Steinert vor 6 Tagen hinzugefügt
SL/Controller/Part.pm | ||
---|---|---|
245 | 245 |
$select_tag_options{empty_title} = t8("Select Variant Property First"); |
246 | 246 |
} |
247 | 247 |
|
248 |
foreach my $variant (@{$self->part->variants}) { |
|
249 |
my $select_tag_name = "add_variant_property_value_" . $variant->id; |
|
250 |
my $new_select_tag = select_tag( |
|
251 |
$select_tag_name, \@options, |
|
252 |
%select_tag_options |
|
253 |
); |
|
254 |
$self->js->replaceWith("#$select_tag_name", $new_select_tag); |
|
255 |
} |
|
248 |
my $new_select_tag = select_tag( |
|
249 |
"variants[].add_variant_property_value", \@options, |
|
250 |
%select_tag_options |
|
251 |
); |
|
252 |
$self->js->replaceWith('[name^="variants[].add_variant_property_value"]', $new_select_tag); |
|
253 |
|
|
254 |
my $new_select_tag_multible = select_tag( |
|
255 |
"add_variant_property_value_for_selected_variants", \@options, |
|
256 |
%select_tag_options |
|
257 |
); |
|
258 |
$self->js->replaceWith("#add_variant_property_value_for_selected_variants", $new_select_tag_multible); |
|
256 | 259 |
|
257 | 260 |
$self->js->render(); |
258 | 261 |
} |
... | ... | |
262 | 265 |
|
263 | 266 |
my $variant_property_id = $::form->{add_variant_property}; |
264 | 267 |
die t8("Please select a variant property") unless ($variant_property_id); |
268 |
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}}; |
|
265 | 269 |
foreach my $variant (@{$self->part->variants}) { |
266 | 270 |
die t8("Please select a new variant property value for all variants") |
267 |
unless $::form->{"add_variant_property_value_" . $variant->id};
|
|
271 |
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
|
|
268 | 272 |
} |
269 | 273 |
|
270 | 274 |
SL::DB->client->with_transaction(sub { |
... | ... | |
275 | 279 |
foreach my $variant (@{$self->part->variants}) { |
276 | 280 |
SL::DB::VariantPropertyValuePart->new( |
277 | 281 |
part_id => $variant->id, |
278 |
variant_property_value_id => $::form->{"add_variant_property_value_" . $variant->id},
|
|
282 |
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
|
|
279 | 283 |
)->save; |
280 | 284 |
} |
281 | 285 |
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