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
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
5 changed files with 89 additions and 63 deletions

View File

@ -2040,7 +2040,7 @@ msgstr ""
msgid "After merging, this product will be kept" msgid "After merging, this product will be kept"
msgstr "" 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 "" msgstr ""
msgid "Merge" msgid "Merge"

View File

@ -88,8 +88,15 @@ $(".merge-chores-button").on("click", function(e)
$("#merge-chores-modal").modal("show"); $("#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 choreIdToKeep = $("#merge-chores-keep").val();
var choreIdToRemove = $("#merge-chores-remove").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-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 productIdToKeep = $("#merge-products-keep").val();
var productIdToRemove = $("#merge-products-remove").val(); var productIdToRemove = $("#merge-products-remove").val();

View File

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

View File

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