Improved products/chore merge dialogs form validation

This commit is contained in:
Bernd Bestel
2022-03-26 11:17:08 +01:00
parent 585ec1212d
commit 033cd306c1
5 changed files with 89 additions and 63 deletions

View File

@@ -2040,7 +2040,7 @@ msgstr ""
msgid "After merging, this product will be kept"
msgstr ""
msgid "After merging, all occurences of this product will be replaced by \"Product to keep\" (means this product will not exist anymore)"
msgid "After merging, all occurences of this product will be replaced by the kept product (means this product will not exist anymore)"
msgstr ""
msgid "Merge"

View File

@@ -88,8 +88,15 @@ $(".merge-chores-button").on("click", function(e)
$("#merge-chores-modal").modal("show");
});
$("#merge-chores-save-button").on("click", function()
$("#merge-chores-save-button").on("click", function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("merge-chores-form", true))
{
return;
}
var choreIdToKeep = $("#merge-chores-keep").val();
var choreIdToRemove = $("#merge-chores-remove").val();

View File

@@ -137,8 +137,15 @@ $(".merge-products-button").on("click", function(e)
$("#merge-products-modal").modal("show");
});
$("#merge-products-save-button").on("click", function()
$("#merge-products-save-button").on("click", function(e)
{
e.preventDefault();
if (!Grocy.FrontendHelpers.ValidateForm("merge-products-form", true))
{
return;
}
var productIdToKeep = $("#merge-products-keep").val();
var productIdToRemove = $("#merge-products-remove").val();

View File

@@ -163,6 +163,9 @@
<h4 class="modal-title w-100">{{ $__t('Merge chores') }}</h4>
</div>
<div class="modal-body">
<form id="merge-chores-form"
novalidate>
<div class="form-group">
<label for="merge-chores-keep">{{ $__t('Chore to keep') }}&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
@@ -170,7 +173,8 @@
title="{{ $__t('After merging, this chore will be kept') }}"></i>
</label>
<select class="custom-control custom-select"
id="merge-chores-keep">
id="merge-chores-keep"
required>
<option></option>
@foreach($chores as $chore)
<option value="{{ $chore->id }}">{{ $chore->name }}</option>
@@ -184,13 +188,16 @@
title="{{ $__t('After merging, all occurences of this chore will be replaced by the kept chore (means this chore will not exist anymore)') }}"></i>
</label>
<select class="custom-control custom-select"
id="merge-chores-remove">
id="merge-chores-remove"
required>
<option></option>
@foreach($chores as $chore)
<option value="{{ $chore->id }}">{{ $chore->name }}</option>
@endforeach
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button"
@@ -198,8 +205,7 @@
data-dismiss="modal">{{ $__t('Cancel') }}</button>
<button id="merge-chores-save-button"
type="button"
class="btn btn-primary"
data-dismiss="modal">{{ $__t('OK') }}</button>
class="btn btn-primary">{{ $__t('OK') }}</button>
</div>
</div>
</div>

View File

@@ -233,6 +233,9 @@
<h4 class="modal-title w-100">{{ $__t('Merge products') }}</h4>
</div>
<div class="modal-body">
<form id="merge-products-form"
novalidate>
<div class="form-group">
<label for="merge-products-keep">{{ $__t('Product to keep') }}&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
@@ -240,7 +243,8 @@
title="{{ $__t('After merging, this product will be kept') }}"></i>
</label>
<select class="custom-control custom-select"
id="merge-products-keep">
id="merge-products-keep"
required>
<option></option>
@foreach($products as $product)
<option value="{{ $product->id }}">{{ $product->name }}</option>
@@ -251,16 +255,19 @@
<label for="merge-products-remove">{{ $__t('Product to remove') }}&nbsp;<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
data-trigger="hover click"
title="{{ $__t('After merging, all occurences of this product will be replaced by "Product to keep" (means this product will not exist anymore)') }}"></i>
title="{{ $__t('After merging, all occurences of this product will be replaced by the kept product (means this product will not exist anymore)') }}"></i>
</label>
<select class="custom-control custom-select"
id="merge-products-remove">
id="merge-products-remove"
required>
<option></option>
@foreach($products as $product)
<option value="{{ $product->id }}">{{ $product->name }}</option>
@endforeach
</select>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button"
@@ -268,8 +275,7 @@
data-dismiss="modal">{{ $__t('Cancel') }}</button>
<button id="merge-products-save-button"
type="button"
class="btn btn-primary"
data-dismiss="modal">{{ $__t('OK') }}</button>
class="btn btn-primary">{{ $__t('OK') }}</button>
</div>
</div>
</div>