mirror of
https://github.com/grocy/grocy.git
synced 2025-04-30 10:05:45 +00:00
Improved date display for dates of today and no time
Instead of the hours since midnight now just "Today" will be shown
This commit is contained in:
parent
df529c3c0b
commit
c6c10c87e4
@ -4,3 +4,4 @@
|
|||||||
- Fixed wrong recipes costs calculation with nested recipes when the base recipe servings are > 1 (also affected the meal plan when adding such a recipe there)
|
- Fixed wrong recipes costs calculation with nested recipes when the base recipe servings are > 1 (also affected the meal plan when adding such a recipe there)
|
||||||
- Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex)
|
- Improved recipes API - added new endpoints to get stock fulfillment information (thanks @Aerex)
|
||||||
- Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown)
|
- Improved date display for products that never expires (instead of "2999-12-31" now just "Never" will be shown)
|
||||||
|
- Improved date display for dates of today and no time (instead of the hours since midnight now just "Today" will be shown)
|
||||||
|
@ -1274,3 +1274,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "Never"
|
msgid "Never"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "Today"
|
||||||
|
msgstr ""
|
||||||
|
@ -300,10 +300,15 @@ RefreshContextualTimeago = function()
|
|||||||
var element = $(this);
|
var element = $(this);
|
||||||
var timestamp = element.attr("datetime");
|
var timestamp = element.attr("datetime");
|
||||||
var isNever = timestamp && timestamp.substring(0, 10) == "2999-12-31";
|
var isNever = timestamp && timestamp.substring(0, 10) == "2999-12-31";
|
||||||
|
var isToday = timestamp && timestamp.length == 10 && timestamp.substring(0, 10) == moment().format("YYYY-MM-DD");
|
||||||
if (isNever)
|
if (isNever)
|
||||||
{
|
{
|
||||||
element.prev().text(__t("Never"));
|
element.prev().text(__t("Never"));
|
||||||
}
|
}
|
||||||
|
if (isToday)
|
||||||
|
{
|
||||||
|
element.text(__t("Today"));
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
element.timeago("update", timestamp);
|
element.timeago("update", timestamp);
|
||||||
|
@ -8,13 +8,14 @@ Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
|||||||
$('#batterycard-battery-name').text(batteryDetails.battery.name);
|
$('#batterycard-battery-name').text(batteryDetails.battery.name);
|
||||||
$('#batterycard-battery-used_in').text(batteryDetails.battery.used_in);
|
$('#batterycard-battery-used_in').text(batteryDetails.battery.used_in);
|
||||||
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || __t('never')));
|
$('#batterycard-battery-last-charged').text((batteryDetails.last_charged || __t('never')));
|
||||||
$('#batterycard-battery-last-charged-timeago').text($.timeago(batteryDetails.last_charged || ''));
|
$('#batterycard-battery-last-charged-timeago').attr("datetime", batteryDetails.last_charged || '');
|
||||||
$('#batterycard-battery-charge-cycles-count').text((batteryDetails.charge_cycles_count || '0'));
|
$('#batterycard-battery-charge-cycles-count').text((batteryDetails.charge_cycles_count || '0'));
|
||||||
|
|
||||||
$('#batterycard-battery-edit-button').attr("href", U("/battery/" + batteryDetails.battery.id.toString()));
|
$('#batterycard-battery-edit-button').attr("href", U("/battery/" + batteryDetails.battery.id.toString()));
|
||||||
$('#batterycard-battery-edit-button').removeClass("disabled");
|
$('#batterycard-battery-edit-button').removeClass("disabled");
|
||||||
|
|
||||||
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', __t('timeago_nan'));
|
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', __t('timeago_nan'));
|
||||||
|
RefreshContextualTimeago();
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@ Grocy.Components.ChoreCard.Refresh = function(choreId)
|
|||||||
{
|
{
|
||||||
$('#chorecard-chore-name').text(choreDetails.chore.name);
|
$('#chorecard-chore-name').text(choreDetails.chore.name);
|
||||||
$('#chorecard-chore-last-tracked').text((choreDetails.last_tracked || __t('never')));
|
$('#chorecard-chore-last-tracked').text((choreDetails.last_tracked || __t('never')));
|
||||||
$('#chorecard-chore-last-tracked-timeago').text($.timeago(choreDetails.last_tracked || ''));
|
$('#chorecard-chore-last-tracked-timeago').attr("datetime", choreDetails.last_tracked || '');
|
||||||
$('#chorecard-chore-tracked-count').text((choreDetails.tracked_count || '0'));
|
$('#chorecard-chore-tracked-count').text((choreDetails.tracked_count || '0'));
|
||||||
$('#chorecard-chore-last-done-by').text((choreDetails.last_done_by.display_name || __t('Unknown')));
|
$('#chorecard-chore-last-done-by').text((choreDetails.last_done_by.display_name || __t('Unknown')));
|
||||||
|
|
||||||
@ -15,6 +15,7 @@ Grocy.Components.ChoreCard.Refresh = function(choreId)
|
|||||||
$('#chorecard-chore-edit-button').removeClass("disabled");
|
$('#chorecard-chore-edit-button').removeClass("disabled");
|
||||||
|
|
||||||
EmptyElementWhenMatches('#chorecard-chore-last-tracked-timeago', __t('timeago_nan'));
|
EmptyElementWhenMatches('#chorecard-chore-last-tracked-timeago', __t('timeago_nan'));
|
||||||
|
RefreshContextualTimeago();
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
@ -235,8 +235,9 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
|||||||
|
|
||||||
Grocy.Components.DateTimePicker.GetInputElement().on('input', function(e)
|
Grocy.Components.DateTimePicker.GetInputElement().on('input', function(e)
|
||||||
{
|
{
|
||||||
$('#datetimepicker-timeago').text($.timeago(Grocy.Components.DateTimePicker.GetValue()));
|
$('#datetimepicker-timeago').attr("datetime", Grocy.Components.DateTimePicker.GetValue());
|
||||||
EmptyElementWhenMatches('#datetimepicker-timeago', __t('timeago_nan'));
|
EmptyElementWhenMatches('#datetimepicker-timeago', __t('timeago_nan'));
|
||||||
|
RefreshContextualTimeago();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.datetimepicker').on('update.datetimepicker', function(e)
|
$('.datetimepicker').on('update.datetimepicker', function(e)
|
||||||
|
@ -12,9 +12,9 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
$('#productcard-product-stock-amount').text(stockAmount);
|
$('#productcard-product-stock-amount').text(stockAmount);
|
||||||
$('#productcard-product-stock-qu-name').text(__n(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural));
|
$('#productcard-product-stock-qu-name').text(__n(stockAmount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural));
|
||||||
$('#productcard-product-last-purchased').text((productDetails.last_purchased || __t('never')).substring(0, 10));
|
$('#productcard-product-last-purchased').text((productDetails.last_purchased || __t('never')).substring(0, 10));
|
||||||
$('#productcard-product-last-purchased-timeago').text($.timeago(productDetails.last_purchased || ''));
|
$('#productcard-product-last-purchased-timeago').attr("datetime", productDetails.last_purchased || '');
|
||||||
$('#productcard-product-last-used').text((productDetails.last_used || __t('never')).substring(0, 10));
|
$('#productcard-product-last-used').text((productDetails.last_used || __t('never')).substring(0, 10));
|
||||||
$('#productcard-product-last-used-timeago').text($.timeago(productDetails.last_used || ''));
|
$('#productcard-product-last-used-timeago').attr("datetime", productDetails.last_used || '');
|
||||||
$('#productcard-product-location').text(productDetails.location.name);
|
$('#productcard-product-location').text(productDetails.location.name);
|
||||||
$('#productcard-product-spoil-rate').text(parseFloat(productDetails.spoil_rate_percent).toLocaleString(undefined, { style: "percent" }));
|
$('#productcard-product-spoil-rate').text(parseFloat(productDetails.spoil_rate_percent).toLocaleString(undefined, { style: "percent" }));
|
||||||
|
|
||||||
@ -71,6 +71,7 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
|
|
||||||
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', __t('timeago_nan'));
|
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', __t('timeago_nan'));
|
||||||
EmptyElementWhenMatches('#productcard-product-last-used-timeago', __t('timeago_nan'));
|
EmptyElementWhenMatches('#productcard-product-last-used-timeago', __t('timeago_nan'));
|
||||||
|
RefreshContextualTimeago();
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user