Added a button to quickly create multiple tasks without having to close/reopen the dialog (closes #1776)

This commit is contained in:
Bernd Bestel
2022-02-06 18:35:19 +01:00
parent e6a6d7ae42
commit 9eb46df517
4 changed files with 33 additions and 7 deletions

View File

@@ -6,6 +6,7 @@
- When using reverse proxy authentication (`ReverseProxyAuthMiddleware`), it's now also possible to pass the username in an environment variable instead of an HTTP header (new `config.php` option `REVERSE_PROXY_AUTH_USE_ENV`) (thanks @Forceu)
- Performance improvements (page loading time) of the recipes page
- New input shorthand `[+/-]n[d/m/y]` for date fields to quickly input a date relative to today (adding `+` or subtracting `-` the number of days/months/years, see the full list of available shorthands [here](https://github.com/grocy/grocy#input-shorthands-for-date-fields))
- Added a "Save & add another task"-button on the add task dialog to quickly create multiple tasks without having to close/reopen the dialog
- Fixed that stock entry labels on purchase were printed, even when "No label" was selected (was only a problem when running label printer WebHooks server side)
- Fixed that when adding missing recipe ingredients, with the option "Only check if any amount is in stock" enabled, to the shopping list, unit conversions (if any) weren't considered
- Fixed that the meal plan showed the total calories per recipe (instead of per serving as stated by the suffix)

View File

@@ -2280,3 +2280,9 @@ msgstr[1] ""
msgid "Set to 0 to hide due soon filters/highlighting"
msgstr ""
msgid "Save & close"
msgstr ""
msgid "Save & add another task"
msgstr ""

View File

@@ -1,4 +1,4 @@
$('#save-task-button').on('click', function(e)
$('.save-task-button').on('click', function(e)
{
e.preventDefault();
@@ -16,6 +16,8 @@
if (Grocy.EditMode === 'create')
{
var addAnother = $(e.currentTarget).hasClass("add-another");
Grocy.Api.Post('objects/tasks', jsonData,
function(result)
{
@@ -23,13 +25,27 @@
Grocy.Components.UserfieldsForm.Save(function()
{
if (GetUriParam("embedded") !== undefined)
{
if (addAnother)
{
window.location.href = U('/task/new?embedded');
}
else
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
}
else
{
if (addAnother)
{
window.location.href = U('/task/new');
}
else
{
window.location.href = U('/tasks');
}
}
});
},
function(xhr)
@@ -82,7 +98,7 @@ $('#task-form input').keydown(function(event)
}
else
{
$('#save-task-button').click();
$('.save-task-button').first().click();
}
}
});

View File

@@ -104,9 +104,12 @@
'entity' => 'tasks'
))
<button id="save-task-button"
class="btn btn-success">{{ $__t('Save') }}</button>
@if($mode == 'edit')
<button class="btn btn-success save-task-button">{{ $__t('Save') }}</button>
@else
<button class="btn btn-success save-task-button">{{ $__t('Save & close') }}</button>
<button class="btn btn-primary save-task-button add-another">{{ $__t('Save & add another task') }}</button>
@endif
</form>
</div>
</div>