Add new Quick Actions

This commit is contained in:
derlohlgianer@gmail.com 2024-04-15 23:21:09 +02:00
parent 2047d38c6e
commit febf5471d7
No known key found for this signature in database
GPG Key ID: 7254C91F18E97D80
4 changed files with 71 additions and 39 deletions

View File

@ -51,3 +51,8 @@ $("#stock_default_consume_amount_use_quick_consume_amount").on("click", function
$("#stock_default_consume_amount").removeAttr("disabled");
}
});
if (BoolVal(Grocy.UserSettings.use_alternative_actions_on_stock_overview_page))
{
$("#use_alternative_actions_on_stock_overview_page").prop("checked", true);
}

View File

@ -0,0 +1,50 @@
@if(boolval($userSettings['use_alternative_actions_on_stock_overview_page']))
<a id="product-{{ $currentStockEntry->product_id }}-consume-button"
class="permission-STOCK_CONSUME btn btn-success btn-sm product-consume-button show-as-dialog-link @if($currentStockEntry->amount_aggregated == 0) disabled @endif"
href="{{ $U('/consume?embedded&product=' . $currentStockEntry->product_id ) }}">
<i class="fa-solid fa-utensils"></i> {{ $__t('Consume') }}
</a>
<a id="product-{{ $currentStockEntry->product_id }}-consume-button"
class="permission-STOCK_TRANSFER btn btn-info btn-sm show-as-dialog-link @if($currentStockEntry->amount <= 0) disabled @endif"
href="{{ $U('/transfer?embedded&product=' . $currentStockEntry->product_id ) }}">
<i class="fa-solid fa-exchange-alt"></i>
</a>
@else
<a class="permission-STOCK_CONSUME btn btn-success btn-sm product-consume-button @if($currentStockEntry->amount_aggregated < $currentStockEntry->quick_consume_amount || $currentStockEntry->enable_tare_weight_handling == 1) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="left"
title="{{ $__t('Consume %1$s of %2$s', $currentStockEntry->quick_consume_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-consume-amount="{{ $currentStockEntry->quick_consume_amount }}">
<i class="fa-solid fa-utensils"></i> <span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->quick_consume_amount_qu_consume }}</span>
</a>
<a id="product-{{ $currentStockEntry->product_id }}-consume-all-button"
class="permission-STOCK_CONSUME btn btn-danger btn-sm product-consume-button @if($currentStockEntry->amount_aggregated == 0) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="right"
title="{{ $__t('Consume all %s which are currently in stock', $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-consume-amount="@if($currentStockEntry->enable_tare_weight_handling == 1){{$currentStockEntry->tare_weight}}@else{{$currentStockEntry->amount}}@endif"
data-original-total-stock-amount="{{$currentStockEntry->amount}}">
<i class="fa-solid fa-utensils"></i> {{ $__t('All') }}
</a>
@if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING)
<a class="btn btn-success btn-sm product-open-button @if($currentStockEntry->amount_aggregated < $currentStockEntry->quick_open_amount || $currentStockEntry->amount_aggregated == $currentStockEntry->amount_opened_aggregated || $currentStockEntry->enable_tare_weight_handling == 1) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="left"
title="{{ $__t('Mark %1$s of %2$s as open', $currentStockEntry->quick_open_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-open-amount="{{ $currentStockEntry->quick_open_amount }}">
<i class="fa-solid fa-box-open"></i> <span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->quick_open_amount_qu_consume }}</span>
</a>
@endif
@endif

View File

@ -196,43 +196,7 @@
<tr id="product-{{ $currentStockEntry->product_id }}-row"
class="@if(GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING && $currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime('-1 days')) && $currentStockEntry->amount > 0) @if($currentStockEntry->due_type == 1) table-secondary @else table-danger @endif @elseif(GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING && $currentStockEntry->best_before_date < date('Y-m-d 23:59:59', strtotime('+' . $nextXDays . ' days')) && $currentStockEntry->amount > 0) table-warning @elseif ($currentStockEntry->product_missing) table-info @endif">
<td class="fit-content border-right">
<a class="permission-STOCK_CONSUME btn btn-success btn-sm product-consume-button @if($currentStockEntry->amount_aggregated < $currentStockEntry->quick_consume_amount || $currentStockEntry->enable_tare_weight_handling == 1) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="left"
title="{{ $__t('Consume %1$s of %2$s', $currentStockEntry->quick_consume_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-consume-amount="{{ $currentStockEntry->quick_consume_amount }}">
<i class="fa-solid fa-utensils"></i> <span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->quick_consume_amount_qu_consume }}</span>
</a>
<a id="product-{{ $currentStockEntry->product_id }}-consume-all-button"
class="permission-STOCK_CONSUME btn btn-danger btn-sm product-consume-button @if($currentStockEntry->amount_aggregated == 0) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="right"
title="{{ $__t('Consume all %s which are currently in stock', $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-consume-amount="@if($currentStockEntry->enable_tare_weight_handling == 1){{$currentStockEntry->tare_weight}}@else{{$currentStockEntry->amount}}@endif"
data-original-total-stock-amount="{{$currentStockEntry->amount}}">
<i class="fa-solid fa-utensils"></i> {{ $__t('All') }}
</a>
@if(GROCY_FEATURE_FLAG_STOCK_PRODUCT_OPENED_TRACKING)
<a class="btn btn-success btn-sm product-open-button @if($currentStockEntry->amount_aggregated < $currentStockEntry->quick_open_amount || $currentStockEntry->amount_aggregated == $currentStockEntry->amount_opened_aggregated || $currentStockEntry->enable_tare_weight_handling == 1) disabled @endif"
href="#"
data-toggle="tooltip"
data-placement="left"
title="{{ $__t('Mark %1$s of %2$s as open', $currentStockEntry->quick_open_amount_qu_consume . ' ' . $currentStockEntry->qu_consume_name, $currentStockEntry->product_name) }}"
data-product-id="{{ $currentStockEntry->product_id }}"
data-product-name="{{ $currentStockEntry->product_name }}"
data-product-qu-name="{{ $currentStockEntry->qu_stock_name }}"
data-open-amount="{{ $currentStockEntry->quick_open_amount }}">
<i class="fa-solid fa-box-open"></i> <span class="locale-number locale-number-quantity-amount">{{ $currentStockEntry->quick_open_amount_qu_consume }}</span>
</a>
@endif
@include('components.quickactions')
<div class="dropdown d-inline-block">
<button class="btn btn-sm btn-light text-secondary"
type="button"
@ -468,4 +432,4 @@
@include('components.productcard', [
'asModal' => true
])
@stop
@stop

View File

@ -207,8 +207,21 @@
@endif
<div class="form-group">
<div class="custom-control custom-checkbox">
<input type="checkbox"
class="form-check-input custom-control-input user-setting-control"
id="use_alternative_actions_on_stock_overview_page"
data-setting-key="use_alternative_actions_on_stock_overview_page">
<label class="form-check-label custom-control-label"
for="use_alternative_actions_on_stock_overview_page">
{{ $__t('Use alternative quick actions') }}
</label>
</div>
</div>
<a href="{{ $U('/stockoverview') }}"
class="btn btn-success">{{ $__t('OK') }}</a>
</div>
</div>
@stop
@stop