mirror of
https://github.com/grocy/grocy.git
synced 2025-04-28 17:23:56 +00:00
Replace Timeago with momentjs (#1687)
* Replaced timeago with moment.fromNow * Fixed datetime when best_before_date is empty * Removed the now unnecessary timeago package * Removed not longer localization strings * Check for empty instead of string comparison Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
parent
b83e4f53b1
commit
98bf36dbc8
@ -12,12 +12,6 @@ msgstr ""
|
|||||||
"Language: en\n"
|
"Language: en\n"
|
||||||
"X-Domain: grocy/component_translations\n"
|
"X-Domain: grocy/component_translations\n"
|
||||||
|
|
||||||
msgid "timeago_locale"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "timeago_nan"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid "moment_locale"
|
msgid "moment_locale"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -33,7 +33,6 @@
|
|||||||
"summernote": "^0.8.18",
|
"summernote": "^0.8.18",
|
||||||
"swagger-ui-dist": "^3.32.1",
|
"swagger-ui-dist": "^3.32.1",
|
||||||
"tempusdominus-bootstrap-4": "https://github.com/berrnd/tempusdominus-bootstrap-4.git#master",
|
"tempusdominus-bootstrap-4": "https://github.com/berrnd/tempusdominus-bootstrap-4.git#master",
|
||||||
"timeago": "^1.6.7",
|
|
||||||
"toastr": "^2.1.4"
|
"toastr": "^2.1.4"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -316,7 +316,6 @@ if (window.localStorage.getItem("sidebar_state") === "collapsed")
|
|||||||
$("#sidenavToggler").click();
|
$("#sidenavToggler").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
$.timeago.settings.allowFuture = true;
|
|
||||||
RefreshContextualTimeago = function(rootSelector = "#page-content")
|
RefreshContextualTimeago = function(rootSelector = "#page-content")
|
||||||
{
|
{
|
||||||
$(rootSelector + " time.timeago").each(function()
|
$(rootSelector + " time.timeago").each(function()
|
||||||
@ -352,7 +351,7 @@ RefreshContextualTimeago = function(rootSelector = "#page-content")
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
element.timeago("update", timestamp);
|
element.text(moment(timestamp).fromNow());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDateWithoutTime)
|
if (isDateWithoutTime)
|
||||||
|
@ -16,7 +16,6 @@ Grocy.Components.BatteryCard.Refresh = function(batteryId)
|
|||||||
$('#batterycard-battery-edit-button').removeClass("disabled");
|
$('#batterycard-battery-edit-button').removeClass("disabled");
|
||||||
$('#batterycard-battery-journal-button').removeClass("disabled");
|
$('#batterycard-battery-journal-button').removeClass("disabled");
|
||||||
|
|
||||||
EmptyElementWhenMatches('#batterycard-battery-last-charged-timeago', __t('timeago_nan'));
|
|
||||||
RefreshContextualTimeago(".batterycard");
|
RefreshContextualTimeago(".batterycard");
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
|
@ -25,7 +25,6 @@ Grocy.Components.ChoreCard.Refresh = function(choreId)
|
|||||||
$("#chorecard-chore-last-tracked-timeago").removeClass("timeago-date-only");
|
$("#chorecard-chore-last-tracked-timeago").removeClass("timeago-date-only");
|
||||||
}
|
}
|
||||||
|
|
||||||
EmptyElementWhenMatches('#chorecard-chore-last-tracked-timeago', __t('timeago_nan'));
|
|
||||||
RefreshContextualTimeago(".chorecard");
|
RefreshContextualTimeago(".chorecard");
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
|
@ -270,7 +270,6 @@ 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').attr("datetime", Grocy.Components.DateTimePicker.GetValue());
|
$('#datetimepicker-timeago').attr("datetime", Grocy.Components.DateTimePicker.GetValue());
|
||||||
EmptyElementWhenMatches('#datetimepicker-timeago', __t('timeago_nan'));
|
|
||||||
RefreshContextualTimeago(".datetimepicker-wrapper");
|
RefreshContextualTimeago(".datetimepicker-wrapper");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -270,7 +270,6 @@ Grocy.Components.DateTimePicker2.GetInputElement().on('keyup', function(e)
|
|||||||
Grocy.Components.DateTimePicker2.GetInputElement().on('input', function(e)
|
Grocy.Components.DateTimePicker2.GetInputElement().on('input', function(e)
|
||||||
{
|
{
|
||||||
$('#datetimepicker2-timeago').attr("datetime", Grocy.Components.DateTimePicker2.GetValue());
|
$('#datetimepicker2-timeago').attr("datetime", Grocy.Components.DateTimePicker2.GetValue());
|
||||||
EmptyElementWhenMatches('#datetimepicker2-timeago', __t('timeago_nan'));
|
|
||||||
RefreshContextualTimeago(".datetimepicker2-wrapper");
|
RefreshContextualTimeago(".datetimepicker2-wrapper");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -110,8 +110,6 @@ Grocy.Components.ProductCard.Refresh = function(productId)
|
|||||||
$("#productcard-product-picture").addClass("d-none");
|
$("#productcard-product-picture").addClass("d-none");
|
||||||
}
|
}
|
||||||
|
|
||||||
EmptyElementWhenMatches('#productcard-product-last-purchased-timeago', __t('timeago_nan'));
|
|
||||||
EmptyElementWhenMatches('#productcard-product-last-used-timeago', __t('timeago_nan'));
|
|
||||||
RefreshContextualTimeago(".productcard");
|
RefreshContextualTimeago(".productcard");
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
|
@ -697,8 +697,6 @@
|
|||||||
<script src="{{ $U('/node_modules/datatables.net-rowgroup-bs4/js/rowGroup.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/datatables.net-rowgroup-bs4/js/rowGroup.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/datatables.net-select/js/dataTables.select.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/datatables.net-select/js/dataTables.select.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/datatables.net-select-bs4/js/select.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/datatables.net-select-bs4/js/select.bootstrap4.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/timeago/jquery.timeago.js?v=', true) }}{{ $version }}"></script>
|
|
||||||
<script src="{{ $U('/node_modules', true) }}/timeago/locales/jquery.timeago.{{ $__t('timeago_locale') }}.js?v={{ $version }}"></script>
|
|
||||||
<script src="{{ $U('/node_modules/toastr/build/toastr.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/toastr/build/toastr.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/sprintf-js/dist/sprintf.min.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/sprintf-js/dist/sprintf.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
|
@ -241,7 +241,7 @@
|
|||||||
<span id="stock-{{ $stockEntry->id }}-due-date">{{ $stockEntry->best_before_date }}</span>
|
<span id="stock-{{ $stockEntry->id }}-due-date">{{ $stockEntry->best_before_date }}</span>
|
||||||
<time id="stock-{{ $stockEntry->id }}-due-date-timeago"
|
<time id="stock-{{ $stockEntry->id }}-due-date-timeago"
|
||||||
class="timeago timeago-contextual"
|
class="timeago timeago-contextual"
|
||||||
datetime="{{ $stockEntry->best_before_date }} 23:59:59"></time>
|
@if($stockEntry->best_before_date != "") datetime="{{ $stockEntry->best_before_date }} 23:59:59" @endif></time>
|
||||||
</td>
|
</td>
|
||||||
<td id="stock-{{ $stockEntry->id }}-location"
|
<td id="stock-{{ $stockEntry->id }}-location"
|
||||||
class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif"
|
class="@if(!GROCY_FEATURE_FLAG_STOCK_LOCATION_TRACKING) d-none @endif"
|
||||||
@ -265,7 +265,7 @@
|
|||||||
<span id="stock-{{ $stockEntry->id }}-purchased-date">{{ $stockEntry->purchased_date }}</span>
|
<span id="stock-{{ $stockEntry->id }}-purchased-date">{{ $stockEntry->purchased_date }}</span>
|
||||||
<time id="stock-{{ $stockEntry->id }}-purchased-date-timeago"
|
<time id="stock-{{ $stockEntry->id }}-purchased-date-timeago"
|
||||||
class="timeago timeago-contextual"
|
class="timeago timeago-contextual"
|
||||||
datetime="{{ $stockEntry->purchased_date }} 23:59:59"></time>
|
@if(!empty($stockEntry->purchased_date)) datetime="{{ $stockEntry->purchased_date }} 23:59:59" @endif></time>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none">{{ $stockEntry->purchased_date }}</td>
|
<td class="d-none">{{ $stockEntry->purchased_date }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
@ -352,7 +352,7 @@
|
|||||||
<span id="product-{{ $currentStockEntry->product_id }}-next-due-date">{{ $currentStockEntry->best_before_date }}</span>
|
<span id="product-{{ $currentStockEntry->product_id }}-next-due-date">{{ $currentStockEntry->best_before_date }}</span>
|
||||||
<time id="product-{{ $currentStockEntry->product_id }}-next-due-date-timeago"
|
<time id="product-{{ $currentStockEntry->product_id }}-next-due-date-timeago"
|
||||||
class="timeago timeago-contextual"
|
class="timeago timeago-contextual"
|
||||||
datetime="{{ $currentStockEntry->best_before_date }} 23:59:59"></time>
|
@if(!empty($currentStockEntry->best_before_date)) datetime="{{ $currentStockEntry->best_before_date }} 23:59:59" @endif></time>
|
||||||
</td>
|
</td>
|
||||||
<td class="d-none">
|
<td class="d-none">
|
||||||
@foreach(FindAllObjectsInArrayByPropertyValue($currentStockLocations, 'product_id', $currentStockEntry->product_id) as $locationsForProduct)
|
@foreach(FindAllObjectsInArrayByPropertyValue($currentStockLocations, 'product_id', $currentStockEntry->product_id) as $locationsForProduct)
|
||||||
|
@ -498,7 +498,7 @@ jquery@3.5.1:
|
|||||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.5.1.tgz#d7b4d08e1bfdb86ad2f1a3d039ea17304717abb5"
|
||||||
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
|
integrity sha512-XwIBPqcMn57FxfT+Go5pzySnm4KWkT1Tv7gjrpT1srtf8Weynl6R273VJ5GjkRb51IzMp5nbaPjJXMWeju2MKg==
|
||||||
|
|
||||||
jquery@>=1.12.0, "jquery@>=1.5.0 <4.0", jquery@>=1.7, jquery@>=1.7.2, jquery@^3.0, jquery@^3.5.1:
|
jquery@>=1.12.0, jquery@>=1.7, jquery@>=1.7.2, jquery@^3.0, jquery@^3.5.1:
|
||||||
version "3.6.0"
|
version "3.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
|
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
|
||||||
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==
|
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==
|
||||||
@ -743,13 +743,6 @@ through@^2.3.4:
|
|||||||
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
|
||||||
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
integrity sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=
|
||||||
|
|
||||||
timeago@^1.6.7:
|
|
||||||
version "1.6.7"
|
|
||||||
resolved "https://registry.yarnpkg.com/timeago/-/timeago-1.6.7.tgz#afd467c29a911e697fc22a81888c7c3022783cb5"
|
|
||||||
integrity sha512-FikcjN98+ij0siKH4VO4dZ358PR3oDDq4Vdl1+sN9gWz1/+JXGr3uZbUShYH/hL7bMhcTpPbplJU5Tej4b4jbQ==
|
|
||||||
dependencies:
|
|
||||||
jquery ">=1.5.0 <4.0"
|
|
||||||
|
|
||||||
toastr@^2.1.4:
|
toastr@^2.1.4:
|
||||||
version "2.1.4"
|
version "2.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/toastr/-/toastr-2.1.4.tgz#8b43be64fb9d0c414871446f2db8e8ca4e95f181"
|
resolved "https://registry.yarnpkg.com/toastr/-/toastr-2.1.4.tgz#8b43be64fb9d0c414871446f2db8e8ca4e95f181"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user