mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
Add new date input shorthand
This commit is contained in:
parent
ecdaaab789
commit
b1522742cc
@ -40,6 +40,8 @@ The following shorthands are available:
|
|||||||
- Example: `0517` will be converted to `2018-05-17`
|
- Example: `0517` will be converted to `2018-05-17`
|
||||||
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
|
- `YYYYMMDD` gets expanded to the proper ISO-8601 notation
|
||||||
- Example: `20190417` will be converted to `2019-04-17`
|
- Example: `20190417` will be converted to `2019-04-17`
|
||||||
|
- `YYYYMMe` or `YYYYMM+` gets expanded to the end of the given month in the given year in proper notation
|
||||||
|
- Example: `201807e` will be converted to `2018-07-31`
|
||||||
- `x` gets expanded to `2999-12-31` (which I use for products which never expire)
|
- `x` gets expanded to `2999-12-31` (which I use for products which never expire)
|
||||||
- Down/up arrow keys will increase/decrease the date by one day
|
- Down/up arrow keys will increase/decrease the date by one day
|
||||||
- Right/left arrow keys will increase/decrease the date by 1 week
|
- Right/left arrow keys will increase/decrease the date by 1 week
|
||||||
|
@ -101,6 +101,12 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
|||||||
Grocy.Components.DateTimePicker.SetValue(value.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'));
|
Grocy.Components.DateTimePicker.SetValue(value.replace(/(\d{4})(\d{2})(\d{2})/, '$1-$2-$3'));
|
||||||
nextInputElement.focus();
|
nextInputElement.focus();
|
||||||
}
|
}
|
||||||
|
else if (value.length === 7 && $.isNumeric(value.substring(0, 6)) && (value.substring(6, 7).toLowerCase() === "e" || value.substring(6, 7).toLowerCase() === "+"))
|
||||||
|
{
|
||||||
|
var date = moment(value.substring(0, 4) + "-" + value.substring(4, 6) + "-01").endOf("month");
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(date.format(format));
|
||||||
|
nextInputElement.focus();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var dateObj = moment(value, format, true);
|
var dateObj = moment(value, format, true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user