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,34 +163,41 @@
<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">
<div class="form-group"> <form id="merge-chores-form"
<label for="merge-chores-keep">{{ $__t('Chore to keep') }}&nbsp;<i class="fas fa-question-circle text-muted" novalidate>
data-toggle="tooltip"
data-trigger="hover click" <div class="form-group">
title="{{ $__t('After merging, this chore will be kept') }}"></i> <label for="merge-chores-keep">{{ $__t('Chore to keep') }}&nbsp;<i class="fas fa-question-circle text-muted"
</label> data-toggle="tooltip"
<select class="custom-control custom-select" data-trigger="hover click"
id="merge-chores-keep"> title="{{ $__t('After merging, this chore will be kept') }}"></i>
<option></option> </label>
@foreach($chores as $chore) <select class="custom-control custom-select"
<option value="{{ $chore->id }}">{{ $chore->name }}</option> id="merge-chores-keep"
@endforeach required>
</select> <option></option>
</div> @foreach($chores as $chore)
<div class="form-group"> <option value="{{ $chore->id }}">{{ $chore->name }}</option>
<label for="merge-chores-remove">{{ $__t('Chore to remove') }}&nbsp;<i class="fas fa-question-circle text-muted" @endforeach
data-toggle="tooltip" </select>
data-trigger="hover click" </div>
title="{{ $__t('After merging, all occurences of this chore will be replaced by the kept chore (means this chore will not exist anymore)') }}"></i> <div class="form-group">
</label> <label for="merge-chores-remove">{{ $__t('Chore to remove') }}&nbsp;<i class="fas fa-question-circle text-muted"
<select class="custom-control custom-select" data-toggle="tooltip"
id="merge-chores-remove"> data-trigger="hover click"
<option></option> title="{{ $__t('After merging, all occurences of this chore will be replaced by the kept chore (means this chore will not exist anymore)') }}"></i>
@foreach($chores as $chore) </label>
<option value="{{ $chore->id }}">{{ $chore->name }}</option> <select class="custom-control custom-select"
@endforeach id="merge-chores-remove"
</select> required>
</div> <option></option>
@foreach($chores as $chore)
<option value="{{ $chore->id }}">{{ $chore->name }}</option>
@endforeach
</select>
</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,34 +233,41 @@
<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">
<div class="form-group"> <form id="merge-products-form"
<label for="merge-products-keep">{{ $__t('Product to keep') }}&nbsp;<i class="fas fa-question-circle text-muted" novalidate>
data-toggle="tooltip"
data-trigger="hover click" <div class="form-group">
title="{{ $__t('After merging, this product will be kept') }}"></i> <label for="merge-products-keep">{{ $__t('Product to keep') }}&nbsp;<i class="fas fa-question-circle text-muted"
</label> data-toggle="tooltip"
<select class="custom-control custom-select" data-trigger="hover click"
id="merge-products-keep"> title="{{ $__t('After merging, this product will be kept') }}"></i>
<option></option> </label>
@foreach($products as $product) <select class="custom-control custom-select"
<option value="{{ $product->id }}">{{ $product->name }}</option> id="merge-products-keep"
@endforeach required>
</select> <option></option>
</div> @foreach($products as $product)
<div class="form-group"> <option value="{{ $product->id }}">{{ $product->name }}</option>
<label for="merge-products-remove">{{ $__t('Product to remove') }}&nbsp;<i class="fas fa-question-circle text-muted" @endforeach
data-toggle="tooltip" </select>
data-trigger="hover click" </div>
title="{{ $__t('After merging, all occurences of this product will be replaced by "Product to keep" (means this product will not exist anymore)') }}"></i> <div class="form-group">
</label> <label for="merge-products-remove">{{ $__t('Product to remove') }}&nbsp;<i class="fas fa-question-circle text-muted"
<select class="custom-control custom-select" data-toggle="tooltip"
id="merge-products-remove"> data-trigger="hover click"
<option></option> title="{{ $__t('After merging, all occurences of this product will be replaced by the kept product (means this product will not exist anymore)') }}"></i>
@foreach($products as $product) </label>
<option value="{{ $product->id }}">{{ $product->name }}</option> <select class="custom-control custom-select"
@endforeach id="merge-products-remove"
</select> required>
</div> <option></option>
@foreach($products as $product)
<option value="{{ $product->id }}">{{ $product->name }}</option>
@endforeach
</select>
</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>