diff --git a/localization/de.php b/localization/de.php index 7097e281..6002de8b 100644 --- a/localization/de.php +++ b/localization/de.php @@ -120,11 +120,13 @@ return array( '#1 habits are due to be done within the next #2 days' => '#1 Gewohnheiten stehen in den nächsten #2 Tagen an', '#1 habits are overdue to be done' => '#1 Gewohnheiten sind überfällig', 'Released on' => 'Veröffentlicht am', - 'Consume 1 #1 of #2' => 'Verbrauche 1 #1 #2', + 'Consume #3 #1 of #2' => 'Verbrauche #3 #1 #2', 'Added #1 #2 of #3 to stock' => '#1 #2 #3 dem Bestand hinzugefügt', 'Stock amount of #1 is now #2 #3' => 'Es sind nun #2 #3 #1 im Bestand', 'Tracked execution of habit #1 on #2' => 'Ausführung von #1 am #2 erfasst', 'Tracked charge cylce of battery #1 on #2' => 'Ladezyklus für Batterie #1 am #2 erfasst', + 'Consume all #1 which are currently in stock' => 'Verbrauche den kompletten Bestand von #1', + 'All' => 'Alle', //Constants 'manually' => 'Manuell', diff --git a/public/viewjs/stockoverview.js b/public/viewjs/stockoverview.js index 54ec210d..3597e769 100644 --- a/public/viewjs/stockoverview.js +++ b/public/viewjs/stockoverview.js @@ -12,22 +12,31 @@ $(document).on('click', '.product-consume-button', function(e) var productId = $(e.currentTarget).attr('data-product-id'); var productName = $(e.currentTarget).attr('data-product-name'); var productQuName = $(e.currentTarget).attr('data-product-qu-name'); + var consumeAmount = $(e.currentTarget).attr('data-consume-amount'); - Grocy.Api.Get('stock/consume-product/' + productId + '/1', + Grocy.Api.Get('stock/consume-product/' + productId + '/' + consumeAmount, function(result) { var oldAmount = parseInt($('#product-' + productId + '-amount').text()); - var newAmount = oldAmount - 1; + var newAmount = oldAmount - consumeAmount; if (newAmount === 0) { - $('#product-' + productId + '-row').remove(); + $('#product-' + productId + '-row').fadeOut(500, function() + { + $(this).remove(); + }); } else { - $('#product-' + productId + '-amount').text(newAmount); + $('#product-' + productId + '-amount').parent().effect('highlight', { }, 500); + $('#product-' + productId + '-amount').fadeOut(500, function() + { + $(this).text(newAmount).fadeIn(500); + }); + $('#product-' + productId + '-consume-all-button').attr('data-consume-amount', newAmount); } - toastr.success(L('Removed #1 #2 of #3 from stock', 1, productQuName, productName)); + toastr.success(L('Removed #1 #2 of #3 from stock', consumeAmount, productQuName, productName)); }, function(xhr) { diff --git a/views/stockoverview.blade.php b/views/stockoverview.blade.php index 2bb5ab59..9b69aa2f 100644 --- a/views/stockoverview.blade.php +++ b/views/stockoverview.blade.php @@ -4,6 +4,10 @@ @section('activeNav', 'stockoverview') @section('viewJsName', 'stockoverview') +@push('pageScripts') + +@endpush + @section('content')