Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 2e19b5c0

Von Tamino Steinert vor etwa 1 Jahr hinzugefügt

  • ID 2e19b5c00190067c491b149ff88458e887c25cb5
  • Vorgänger 4ebee618
  • Nachfolger 6a5a4049

Varianten: Schnellbearbeitung von Varianten

Unterschiede anzeigen:

SL/Controller/Part.pm
$select_tag_options{empty_title} = t8("Select Variant Property First");
}
foreach my $variant (@{$self->part->variants}) {
my $select_tag_name = "add_variant_property_value_" . $variant->id;
my $new_select_tag = select_tag(
$select_tag_name, \@options,
%select_tag_options
);
$self->js->replaceWith("#$select_tag_name", $new_select_tag);
}
my $new_select_tag = select_tag(
"variants[].add_variant_property_value", \@options,
%select_tag_options
);
$self->js->replaceWith('[name^="variants[].add_variant_property_value"]', $new_select_tag);
my $new_select_tag_multible = select_tag(
"add_variant_property_value_for_selected_variants", \@options,
%select_tag_options
);
$self->js->replaceWith("#add_variant_property_value_for_selected_variants", $new_select_tag_multible);
$self->js->render();
}
......
my $variant_property_id = $::form->{add_variant_property};
die t8("Please select a variant property") unless ($variant_property_id);
my %variant_id_to_values = map {$_->{id} => $_} @{$::form->{variants}};
foreach my $variant (@{$self->part->variants}) {
die t8("Please select a new variant property value for all variants")
unless $::form->{"add_variant_property_value_" . $variant->id};
unless $variant_id_to_values{$variant->id}->{"add_variant_property_value"};
}
SL::DB->client->with_transaction(sub {
......
foreach my $variant (@{$self->part->variants}) {
SL::DB::VariantPropertyValuePart->new(
part_id => $variant->id,
variant_property_value_id => $::form->{"add_variant_property_value_" . $variant->id},
variant_property_value_id => $variant_id_to_values{$variant->id}->{"add_variant_property_value"},
)->save;
}
1;
js/kivi.Part.js
$(new_rows).appendTo($('#parent_variant_table'));
};
ns.get_selected_variants = function() {
let selected_rows = [];
$('[name^="variant_multi_id_"]').each( function() {
if (this.checked) {
selected_rows.push($(this).parents("tr").first());
}
});
return selected_rows;
}
ns.variant_rows_toggle_selected = function() {
$('[name^="variant_multi_id_"]').each( function() {
this.checked = !this.checked;
});
}
ns.set_selected_variants_to_value = function(value_name) {
let value = $('[name="' + value_name + '_for_selected_variants"]').val();
let selected_rows = ns.get_selected_variants();
selected_rows.forEach(function(row) {
$(row).find(
'[name="variants[].' + value_name + '"]'
).val(
value
);
});
};
ns.assortment_recalc = function() {
var data = $('#assortment :input').serializeArray();
data.push(
......
$('#part_warehouse_id').change(kivi.Part.reload_bin_selection);
$('#variant_select_all').click( function() {
var checked = this.checked;
$('[name^="variant_multi_id_"]').each(function() {
this.checked = checked;
});
});
ns.init();
});
});
templates/design40_webpages/part/_parent_variant.html
[% LxERP.t8("Variants") %]
</caption>
<thead>
<th></th>
<tr>
<th>
[% L.checkbox_tag("varaint_select_all_multi_id",
checked=0, id='variant_select_all'
alt=LxERP.t8('Select/Deselect all'), title=LxERP.t8('Select/Deselect all'),
) %]
</th>
<th id="variant_partnumber_header_id">
<a href='#' onClick='javascript:kivi.Part.reorder_variants("partnumber")'>
[% 'Partnumber' | $T8 %]
......
)%]
[% L.button_tag('kivi.Part.add_variant_property();', LxERP.t8("Insert new")) %]
</th>
</tr>
<tr>
<th class="center">
[%- L.button_tag('kivi.Part.variant_rows_toggle_selected();', "🔄",
title=LxERP.t8("Toggle selection"),
alt=LxERP.t8("Toggle selection"),
) %]
</th>
<th></th>
<th>
[% L.input_tag("description_for_selected_variants", SELF.part.description,
class="wi-medium",
) %]
[%- L.button_tag(
'kivi.Part.set_selected_variants_to_value("description")',
"↓",
alt=LxERP.t8('Apply to selected rows'),
title=LxERP.t8('Apply to selected rows'),
) %]
</th>
<th colspan="[% SELF.part.variant_properties.size + 1 %]"></th>
<th>
[% L.select_tag("add_variant_property_value_for_selected_variants", []
title_key='displayable_name', value_key='id',
with_empty=1, empty_title=LxERP.t8("Select Variant Property First"),
) %]
[%- L.button_tag(
'kivi.Part.set_selected_variants_to_value("add_variant_property_value")',
"↓",
alt=LxERP.t8('Apply to selected rows'),
title=LxERP.t8('Apply to selected rows'),
) %]
</th>
</tr>
</thead>
<tbody class="listrow">
[% FOREACH variant = SELF.part.variants %]
<tr class="variant_row_entry">
[% L.hidden_tag("variants[+].id", variant.id, id='variant_' _ variant.id) %]
[% L.hidden_tag("variants[].position", loop.count) %]
<td>
[% L.hidden_tag("variants[+].id", variant.id) %]
[% L.hidden_tag("variants[].position", loop.count) %]
[% L.checkbox_tag('variant_multi_id_' _ loop.count, value=variant.id, checked=0) %]
</td>
<td>[% variant.presenter.part %]</td>
<td>[% variant.description | html %]</td>
<td>
[% L.input_tag("variants[].description", variant.description, class="wi-medium") %]
</td>
<td>[% variant.variant_values | html %]</td>
[% FOREACH variant_property = SELF.part.variant_properties %]
<td> [% variant.variant_value(variant_property) %] </td>
[% END %]
<td>
[% L.select_tag("add_variant_property_value_" _ variant.id, []
[% L.select_tag("variants[].add_variant_property_value", []
title_key='displayable_name', value_key='id',
with_empty=1, empty_title=LxERP.t8("Select Variant Property First"),
) %]

Auch abrufbar als: Unified diff