mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 12:20:22 +00:00
Added input shorthands for date fields to increase/decrease the date by 1 month/year (closes #405)
This commit is contained in:
@@ -65,8 +65,10 @@ The following shorthands are available:
|
|||||||
- `YYYYMMe` or `YYYYMM+` gets expanded to the end of the given month in the given year in proper notation
|
- `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`
|
- 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 1 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
|
||||||
|
- Shift + down/up arrow keys will increase/decrease the date by 1 month
|
||||||
|
- Shift + right/left arrow keys will increase/decrease the date by 1 year
|
||||||
|
|
||||||
### Keyboard shorthands for buttons
|
### Keyboard shorthands for buttons
|
||||||
Wherever a button contains a bold highlighted letter, this is a shortcut key.
|
Wherever a button contains a bold highlighted letter, this is a shortcut key.
|
||||||
|
@@ -3,3 +3,6 @@
|
|||||||
|
|
||||||
### Recipe fixes
|
### Recipe fixes
|
||||||
- Fixed that recipes were displayed without ingredients if the total recipe count was > 100
|
- Fixed that recipes were displayed without ingredients if the total recipe count was > 100
|
||||||
|
|
||||||
|
### General & other improvements
|
||||||
|
- New Input shorthands for date fields to increase/decrease the date by 1 month/year (shift + arrow keys, see the full list [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields))
|
||||||
|
@@ -170,24 +170,50 @@ Grocy.Components.DateTimePicker.GetInputElement().on('keyup', function(e)
|
|||||||
var dateObj = moment(value, format, true);
|
var dateObj = moment(value, format, true);
|
||||||
if (dateObj.isValid())
|
if (dateObj.isValid())
|
||||||
{
|
{
|
||||||
if (e.keyCode === 38) //Up
|
if (e.shiftKey)
|
||||||
|
{
|
||||||
|
// WITH shift modifier key
|
||||||
|
|
||||||
|
if (e.keyCode === 38) // Up
|
||||||
|
{
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'months').format(format));
|
||||||
|
}
|
||||||
|
else if (e.keyCode === 40) // Down
|
||||||
|
{
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'months').format(format));
|
||||||
|
}
|
||||||
|
else if (e.keyCode === 37) // Left
|
||||||
|
{
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'years').format(format));
|
||||||
|
}
|
||||||
|
else if (e.keyCode === 39) // Right
|
||||||
|
{
|
||||||
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'years').format(format));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// WITHOUT shift modifier key
|
||||||
|
|
||||||
|
if (e.keyCode === 38) // Up
|
||||||
{
|
{
|
||||||
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'days').format(format));
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'days').format(format));
|
||||||
}
|
}
|
||||||
else if (e.keyCode === 40) //Down
|
else if (e.keyCode === 40) // Down
|
||||||
{
|
{
|
||||||
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'days').format(format));
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'days').format(format));
|
||||||
}
|
}
|
||||||
else if (e.keyCode === 37) //Left
|
else if (e.keyCode === 37) // Left
|
||||||
{
|
{
|
||||||
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'weeks').format(format));
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(-1, 'weeks').format(format));
|
||||||
}
|
}
|
||||||
else if (e.keyCode === 39) //Right
|
else if (e.keyCode === 39) // Right
|
||||||
{
|
{
|
||||||
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'weeks').format(format));
|
Grocy.Components.DateTimePicker.SetValue(dateObj.add(1, 'weeks').format(format));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Custom validation
|
//Custom validation
|
||||||
value = Grocy.Components.DateTimePicker.GetValue();
|
value = Grocy.Components.DateTimePicker.GetValue();
|
||||||
|
Reference in New Issue
Block a user