Skip to content

Commit

Permalink
Varianten: Ausprägung löschen
Browse files Browse the repository at this point in the history
  • Loading branch information
z4m1n0 committed Nov 4, 2024
1 parent ea15eb7 commit 978a5f2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
32 changes: 32 additions & 0 deletions SL/Controller/VariantProperty.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,38 @@ sub action_save_variant_property_value {
);
}

sub action_delete_variant_property_value {
my ($self) = @_;

die "'variant_property_value.id' is needed" unless $::form->{variant_property_value}->{id};

my $variant_property_value = SL::DB::Manager::VariantPropertyValue->find_by(
id => $::form->{variant_property_value}->{id}
) or die t8("Could not find Variant Property Value");

SL::DB->client->with_transaction(sub {
$variant_property_value->delete;
flash_later('info',
t8(
'The Variant Property Value \'#1\' has been deleted.',
$variant_property_value->displayable_name
)
);
1;
}
) or flash_later('error',
t8(
'The Variant Property Value \'#1\' is in use and cannot be deleted.',
$variant_property_value->displayable_name
)
);

$self->redirect_to(
action => 'edit_variant_property',
id => $variant_property_value->variant_property_id,
);
}

sub action_add_variant_property_value {
my ($self) = @_;

Expand Down
6 changes: 6 additions & 0 deletions js/kivi.VariantProperty.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ namespace('kivi.VariantProperty', function(ns) {
$.post('controller.pl', data, kivi.eval_json_result);
};

ns.delete_variant_property_value = function() {
var data = $('#variant_property_value_form').serializeArray();
data.push({ name: 'action', value: 'VariantProperty/delete_variant_property_value' });
$.post('controller.pl', data, kivi.eval_json_result);
};

ns.add_variant_property_value = function() {
var data = $('#variant_property_value_list_form').serializeArray();
data.push({ name: 'action', value: 'VariantProperty/add_variant_property_value' });
Expand Down
2 changes: 2 additions & 0 deletions locale/de/all
Original file line number Diff line number Diff line change
Expand Up @@ -4014,6 +4014,8 @@ $ ./scripts/installation_check.pl',
'The VAT ID number \'#1\' is invalid.' => 'Die UStID-Nummer »#1« ist ungültig.',
'The VAT ID number in the client configuration is invalid.' => 'Die UStID-Nummer in der Mandantenkonfiguraiton ist ungültig.',
'The VAT registration number is missing in the client configuration.' => 'Die Umsatzsteuer-ID-Nummer fehlt in der Mandantenkonfiguration.',
'The Variant Property Value \'#1\' has been deleted.' => 'Die Ausprägung \'#1\' würde gelöscht.',
'The Variant Property Value \'#1\' is in use and cannot be deleted.' => 'Die Ausprägung \'#1\' is in Verwendung und kann nicht gelöscht werden.',
'The Variant Property Value has been saved.' => 'Die Ausprägung wurde gespeichert.',
'The Variant Property has been created.' => 'Die Varianteneigenschaft wurde erfasst.',
'The Variant Property has been deleted.' => 'Die Varianteneigenschaft wurde gelöscht.',
Expand Down
2 changes: 2 additions & 0 deletions locale/en/all
Original file line number Diff line number Diff line change
Expand Up @@ -4012,6 +4012,8 @@ $self->{texts} = {
'The VAT ID number \'#1\' is invalid.' => '',
'The VAT ID number in the client configuration is invalid.' => '',
'The VAT registration number is missing in the client configuration.' => '',
'The Variant Property Value \'#1\' has been deleted.' => '',
'The Variant Property Value \'#1\' is in use and cannot be deleted.' => '',
'The Variant Property Value has been saved.' => '',
'The Variant Property has been created.' => '',
'The Variant Property has been deleted.' => '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,6 @@ <h1>[% FORM.title %]</h1>

<div class="buttons">
[% L.button_tag("kivi.VariantProperty.save_variant_property_value()", LxERP.t8("Save")) %]
[% L.button_tag("kivi.VariantProperty.delete_variant_property_value()", LxERP.t8("Delete")) %]
</div>

0 comments on commit 978a5f2

Please sign in to comment.