Some bug fixes. (#1000)

* Fix #997. Remove datetimepicker if FEATURE_FLAG_STOCK_BEST_BEFORE_DATE is not set.

* datetimepicker: Fix that SetValue did not set the value if "shortcut-checkbox" (e.g. "never expires") was checked.

* Use parent div as clickable area for checkboxes in dropdowns

* Fix nightmode-enable

* Fix possibly undefined variables in CalendarService.php

* Fix undefined variable in GenericEntityApiController.php

* Fix "Trying to access property barcodes on non-object" in productpicker

* Fix undefined "hintId" in shoppinglocationpicker

* Fix undefined variables in locationpicker.blade.php
This commit is contained in:
fipwmaqzufheoxq92ebc 2020-09-14 11:15:11 +02:00 committed by GitHub
parent 0624b0df59
commit 5056ca9397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 50 additions and 35 deletions

View File

@ -64,7 +64,7 @@ class GenericEntityApiController extends BaseApiController
}
else
{
return $this->GenericErrorResponse($response, $ex->getMessage());
return $this->GenericErrorResponse($response, "Invalid entity");
}
}

View File

@ -696,3 +696,10 @@ $(document).on("click", "a.btn.link-return", function(e)
location.href = U(link);
}
});
$('.dropdown-item').has('.form-check input[type=checkbox]').on('click', function (e) {
if($(e.target).is('div.form-check') || $(e.target).is('div.dropdown-item'))
{
$(e.target).find('input[type=checkbox]').click();
}
})

View File

@ -3,11 +3,11 @@
var value = $(this).is(":checked");
if (value)
{
$("body").addClass("night-mode");
// Force disable auto night mode when night mode is enabled
$("#auto-night-mode-enabled").prop("checked", false);
$("#auto-night-mode-enabled").trigger("change");
$("body").addClass("night-mode");
}
else
{

View File

@ -12,9 +12,6 @@ Grocy.Components.DateTimePicker.GetValue = function()
Grocy.Components.DateTimePicker.SetValue = function(value)
{
Grocy.Components.DateTimePicker.GetInputElement().val(value);
Grocy.Components.DateTimePicker.GetInputElement().trigger('change');
// "Click" the shortcut checkbox when the desired value is
// not the shortcut value and it is currently set
var shortcutValue = $("#datetimepicker-shortcut").data("datetimepicker-shortcut-value");
@ -22,6 +19,8 @@ Grocy.Components.DateTimePicker.SetValue = function(value)
{
$("#datetimepicker-shortcut").click();
}
Grocy.Components.DateTimePicker.GetInputElement().val(value);
Grocy.Components.DateTimePicker.GetInputElement().trigger('change');
Grocy.Components.DateTimePicker.GetInputElement().keyup();
}

View File

@ -29,7 +29,14 @@
var jsonData = {};
jsonData.amount = amount;
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
if (Grocy.Components.DateTimePicker)
{
jsonData.best_before_date = Grocy.Components.DateTimePicker.GetValue();
}
else {
jsonData.best_before_date = null;
}
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
jsonData.shopping_location_id = Grocy.Components.ShoppingLocationPicker.GetValue();
@ -99,7 +106,10 @@
{
Grocy.Components.LocationPicker.Clear();
}
Grocy.Components.DateTimePicker.Clear();
if(Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
Grocy.Components.DateTimePicker.Clear();
}
Grocy.Components.ProductPicker.SetValue('');
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
{
@ -265,23 +275,21 @@ if (Grocy.Components.ProductPicker !== undefined)
$("#tare-weight-handling-info").addClass("d-none");
}
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
Grocy.Components.DateTimePicker.SetValue('2999-12-31');
}
if (productDetails.product.default_best_before_days.toString() !== '0')
{
if (productDetails.product.default_best_before_days == -1)
if (productDetails.product.default_best_before_days.toString() !== '0')
{
if (!$("#datetimepicker-shortcut").is(":checked"))
if (productDetails.product.default_best_before_days == -1)
{
$("#datetimepicker-shortcut").click();
if (!$("#datetimepicker-shortcut").is(":checked"))
{
$("#datetimepicker-shortcut").click();
}
}
else
{
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
}
}
else
{
Grocy.Components.DateTimePicker.SetValue(moment().add(productDetails.product.default_best_before_days, 'days').format('YYYY-MM-DD'));
}
}

View File

@ -95,6 +95,8 @@ class CalendarService extends BaseService
}
$mealPlanRecipeEvents = [];
$mealPlanNotesEvents = [];
$mealPlanProductEvents = [];
if (GROCY_FEATURE_FLAG_RECIPES)
{
@ -120,7 +122,7 @@ class CalendarService extends BaseService
$mealPlanDayNotes = $this->getDatabase()->meal_plan()->where('type', 'note');
$titlePrefix = $this->getLocalizationService()->__t('Meal plan note') . ': ';
$mealPlanNotesEvents = [];
foreach ($mealPlanDayNotes as $mealPlanDayNote)
{
@ -134,7 +136,7 @@ class CalendarService extends BaseService
$products = $this->getDatabase()->products();
$mealPlanDayProducts = $this->getDatabase()->meal_plan()->where('type', 'product');
$titlePrefix = $this->getLocalizationService()->__t('Meal plan product') . ': ';
$mealPlanProductEvents = [];
foreach ($mealPlanDayProducts as $mealPlanDayProduct)
{

View File

@ -8,10 +8,10 @@
@php if(empty($hint)) { $hint = ''; } @endphp
<div class="form-group"
data-next-input-selector="{{ $nextInputSelector }}"
@if(isset($nextInputSelector))data-next-input-selector="{{ $nextInputSelector }}" @endif
data-prefill-by-name="{{ $prefillByName }}"
data-prefill-by-id="{{ $prefillById }}">
<label for="location_id">{{ $__t('Location') }}&nbsp;&nbsp;<span id="{{ $hintId }}"
<label for="location_id">{{ $__t('Location') }}&nbsp;&nbsp;<span @if(!empty($hintId))id="{{ $hintId }}" @endif
class="small text-muted">{{ $hint }}</span></label>
<select class="form-control location-combobox"
id="location_id"

View File

@ -35,7 +35,12 @@
data-target="@productpicker">
<option value=""></option>
@foreach($products as $product)
<option data-additional-searchdata="{{ FindObjectInArrayByPropertyValue($barcodes, 'product_id', $product->id)->barcodes }},"
@php $bc = null;
if(isset($barcodes)) {
$bc = FindObjectInArrayByPropertyValue($barcodes, 'product_id', $product->id);
}
@endphp
<option data-additional-searchdata="@if(isset($bc)){{ $bc->barcodes }}@endif,"
value="{{ $product->id }}">{{ $product->name }}</option>
@endforeach
</select>

View File

@ -12,7 +12,7 @@
data-next-input-selector="{{ $nextInputSelector }}"
data-prefill-by-name="{{ $prefillByName }}"
data-prefill-by-id="{{ $prefillById }}">
<label for="shopping_location_id">{{ $__t($label) }}&nbsp;&nbsp;<span id="{{ $hintId }}"
<label for="shopping_location_id">{{ $__t($label) }}&nbsp;&nbsp;<span @if(!empty($hintId))id="{{ $hintId }}" @endif
class="small text-muted">{{ $hint }}</span></label>
<select class="form-control shopping-location-combobox"
id="shopping_location_id"

View File

@ -53,13 +53,7 @@
class="text-info font-italic d-none">' . $__t('Tare weight handling enabled - please weigh the whole container, the amount to be posted will be automatically calculcated') . '</div>'
))
@php
$additionalGroupCssClasses = '';
if (!GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
{
$additionalGroupCssClasses = 'd-none';
}
@endphp
@if(GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_TRACKING)
@include('components.datetimepicker', array(
'id' => 'best_before_date',
'label' => 'Best before',
@ -77,7 +71,7 @@
'additionalGroupCssClasses' => $additionalGroupCssClasses,
'activateNumberPad' => GROCY_FEATURE_FLAG_STOCK_BEST_BEFORE_DATE_FIELD_NUMBER_PAD
))
@php $additionalGroupCssClasses = ''; @endphp
@endif
@if(GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
@include('components.numberpicker', array(