mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Added a new config option for energy unit display (closes #2109)
This commit is contained in:
parent
0bd698c968
commit
b64d726c42
@ -47,7 +47,7 @@
|
|||||||
|
|
||||||
### Meal plan
|
### Meal plan
|
||||||
|
|
||||||
- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` to only disable the meal plan if not needed (thanks @webysther)
|
- Added a new sub feature flag `FEATURE_FLAG_RECIPES_MEALPLAN` (in `config.php`) to only disable the meal plan if not needed (thanks @webysther)
|
||||||
|
|
||||||
### Chores
|
### Chores
|
||||||
|
|
||||||
@ -75,6 +75,7 @@
|
|||||||
|
|
||||||
### General
|
### General
|
||||||
|
|
||||||
|
- Added a new `config.php` setting `ENERGY_UNIT` to customize the label to display energy values (was fixed `kcal` before and defaults to that, so no changed behavior when not configured)
|
||||||
- New translations: (thanks all the translators)
|
- New translations: (thanks all the translators)
|
||||||
- Romanian (demo available at <https://ro.demo.grocy.info>)
|
- Romanian (demo available at <https://ro.demo.grocy.info>)
|
||||||
|
|
||||||
|
@ -41,6 +41,10 @@ Setting('MEAL_PLAN_FIRST_DAY_OF_WEEK', '');
|
|||||||
// ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
|
// ISO 4217 code of the currency ("USD", "EUR", "GBP", etc.)
|
||||||
Setting('CURRENCY', 'USD');
|
Setting('CURRENCY', 'USD');
|
||||||
|
|
||||||
|
// Your preferred unit for energy
|
||||||
|
// E.g. "kcal" or "kJ" or something else (doesn't really matter, it's only used to display energy values)
|
||||||
|
Setting('ENERGY_UNIT', 'kcal');
|
||||||
|
|
||||||
// When running grocy in a subdirectory, this should be set to the relative path, otherwise empty
|
// When running grocy in a subdirectory, this should be set to the relative path, otherwise empty
|
||||||
// It needs to be set to the part (of the URL) AFTER the document root,
|
// It needs to be set to the part (of the URL) AFTER the document root,
|
||||||
// if URL rewriting is disabled, including index.php
|
// if URL rewriting is disabled, including index.php
|
||||||
|
@ -1356,7 +1356,7 @@ msgstr ""
|
|||||||
msgid "Output"
|
msgid "Output"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Energy (kcal)"
|
msgid "Energy"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Per stock quantity unit"
|
msgid "Per stock quantity unit"
|
||||||
|
@ -168,11 +168,11 @@ $(".calendar").each(function()
|
|||||||
var costsAndCaloriesPerServing = ""
|
var costsAndCaloriesPerServing = ""
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-currency">' + resolvedRecipe.costs + '</span> / <span class="locale-number locale-number-generic">' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + '</span> kcal ' + __t('per serving') + '</h5>';
|
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-currency">' + resolvedRecipe.costs + '</span> / <span class="locale-number locale-number-generic">' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + '</span> ' + Grocy.EnergyUnit + ' ' + __t('per serving') + '</h5>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-generic">' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + '</span> kcal ' + __t('per serving') + '</h5>';
|
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-generic">' + resolvedRecipe.calories / mealPlanEntry.recipe_servings + '</span> ' + Grocy.EnergyUnit + ' ' + __t('per serving') + '</h5>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK)
|
if (!Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK)
|
||||||
@ -245,11 +245,11 @@ $(".calendar").each(function()
|
|||||||
var costsAndCaloriesPerServing = ""
|
var costsAndCaloriesPerServing = ""
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-currency">' + productDetails.last_price * mealPlanEntry.product_amount + '</span> / <span class="locale-number locale-number-generic">' + productDetails.product.calories + '</span> kcal ' + '</h5>';
|
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-currency">' + productDetails.last_price * mealPlanEntry.product_amount + '</span> / <span class="locale-number locale-number-generic">' + productDetails.product.calories + '</span> ' + Grocy.EnergyUnit + ' </h5>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-generic">' + productDetails.product.calories + '</span> kcal ' + '</h5>';
|
costsAndCaloriesPerServing = '<h5 class="small text-truncate mb-1"><span class="locale-number locale-number-generic">' + productDetails.product.calories + '</span> ' + Grocy.EnergyUnit + ' </h5>';
|
||||||
}
|
}
|
||||||
|
|
||||||
var shoppingListButtonHtml = "";
|
var shoppingListButtonHtml = "";
|
||||||
@ -302,11 +302,11 @@ $(".calendar").each(function()
|
|||||||
var costsAndCaloriesPerDay = ""
|
var costsAndCaloriesPerDay = ""
|
||||||
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING)
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerDay = '<h5 class="small text-truncate"><span class="locale-number locale-number-currency">' + dayRecipeResolved.costs + '</span> / <span class="locale-number locale-number-generic">' + dayRecipeResolved.calories + '</span> kcal ' + __t('per day') + '</h5>';
|
costsAndCaloriesPerDay = '<h5 class="small text-truncate"><span class="locale-number locale-number-currency">' + dayRecipeResolved.costs + '</span> / <span class="locale-number locale-number-generic">' + dayRecipeResolved.calories + '</span> ' + Grocy.EnergyUnit + ' ' + __t('per day') + '</h5>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
costsAndCaloriesPerDay = '<h5 class="small text-truncate"><span class="locale-number locale-number-generic">' + dayRecipeResolved.calories + '</span> kcal ' + __t('per day') + '</h5>';
|
costsAndCaloriesPerDay = '<h5 class="small text-truncate"><span class="locale-number locale-number-generic">' + dayRecipeResolved.calories + '</span> ' + Grocy.EnergyUnit + ' ' + __t('per day') + '</h5>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".calendar[data-primary-section='true'] .fc-day-header[data-date='" + dayRecipeName + "']").append('<h5 id="day-summary-' + dayRecipeName + '" class="small text-truncate border-top pt-1 pb-0">' + costsAndCaloriesPerDay + '</h5>');
|
$(".calendar[data-primary-section='true'] .fc-day-header[data-date='" + dayRecipeName + "']").append('<h5 id="day-summary-' + dayRecipeName + '" class="small text-truncate border-top pt-1 pb-0">' + costsAndCaloriesPerDay + '</h5>');
|
||||||
|
@ -161,7 +161,7 @@ $('.input-group-qu').on('change', function(e)
|
|||||||
{
|
{
|
||||||
$("#tare_weight_qu_info").text($("#qu_id_stock option:selected").text());
|
$("#tare_weight_qu_info").text($("#qu_id_stock option:selected").text());
|
||||||
$("#quick_consume_qu_info").text($("#qu_id_stock option:selected").text());
|
$("#quick_consume_qu_info").text($("#qu_id_stock option:selected").text());
|
||||||
$("#energy_qu_info").text($("#qu_id_stock option:selected").text());
|
$("#energy_qu_info").text(Grocy.EnergyUnit + " / " + $("#qu_id_stock option:selected").text());
|
||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm('product-form');
|
Grocy.FrontendHelpers.ValidateForm('product-form');
|
||||||
});
|
});
|
||||||
|
@ -95,6 +95,7 @@
|
|||||||
Grocy.CurrentUrlRelative = "/" + window.location.href.split('?')[0].replace(Grocy.BaseUrl, "");
|
Grocy.CurrentUrlRelative = "/" + window.location.href.split('?')[0].replace(Grocy.BaseUrl, "");
|
||||||
Grocy.ActiveNav = '@yield('activeNav', '')';
|
Grocy.ActiveNav = '@yield('activeNav', '')';
|
||||||
Grocy.Currency = '{{ GROCY_CURRENCY }}';
|
Grocy.Currency = '{{ GROCY_CURRENCY }}';
|
||||||
|
Grocy.EnergyUnit = '{{ GROCY_ENERGY_UNIT }}';
|
||||||
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
|
Grocy.CalendarFirstDayOfWeek = '{{ GROCY_CALENDAR_FIRST_DAY_OF_WEEK }}';
|
||||||
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
|
Grocy.CalendarShowWeekNumbers = {{ BoolToString(GROCY_CALENDAR_SHOW_WEEK_OF_YEAR) }};
|
||||||
Grocy.LocalizationStrings = {!! $LocalizationStrings !!};
|
Grocy.LocalizationStrings = {!! $LocalizationStrings !!};
|
||||||
|
@ -478,7 +478,7 @@
|
|||||||
@php if($mode == 'edit') { $value = $product->calories; } else { $value = 0; } @endphp
|
@php if($mode == 'edit') { $value = $product->calories; } else { $value = 0; } @endphp
|
||||||
@include('components.numberpicker', array(
|
@include('components.numberpicker', array(
|
||||||
'id' => 'calories',
|
'id' => 'calories',
|
||||||
'label' => 'Energy (kcal)',
|
'label' => 'Energy',
|
||||||
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts']),
|
'min' => '0.' . str_repeat('0', $userSettings['stock_decimal_places_amounts']),
|
||||||
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
'decimals' => $userSettings['stock_decimal_places_amounts'],
|
||||||
'value' => $value,
|
'value' => $value,
|
||||||
|
@ -388,7 +388,7 @@
|
|||||||
<div class="row ml-1">
|
<div class="row ml-1">
|
||||||
@if(!empty($calories) && intval($calories) > 0)
|
@if(!empty($calories) && intval($calories) > 0)
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<label>{{ $__t('Energy (kcal)') }}</label>
|
<label>{{ GROCY_ENERGY_UNIT }}</label>
|
||||||
<i class="fa-solid fa-question-circle text-muted d-print-none"
|
<i class="fa-solid fa-question-circle text-muted d-print-none"
|
||||||
data-toggle="tooltip"
|
data-toggle="tooltip"
|
||||||
data-trigger="hover click"
|
data-trigger="hover click"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user