More modal iframe dialog handling improvements

This commit is contained in:
Bernd Bestel
2025-01-10 20:26:37 +01:00
parent 201bda93a2
commit a373f8ae4b
24 changed files with 117 additions and 42 deletions

View File

@@ -120,6 +120,11 @@ input[type='number'] {
appearance: textfield;
}
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
.sticky-form-footer {
border-top: 1px solid #d6d6d6;
background-color: white;
@@ -275,11 +280,20 @@ a:not([href]) {
z-index: 99998;
}
/* There is a little too much padding around modals */
.modal-body {
padding: 0.75rem;
}
@media (min-width: 576px) {
.form .modal-dialog {
max-width: 650px;
}
.wider .modal-dialog {
max-width: 800px;
}
.table .modal-dialog {
max-width: 90%;
}

View File

@@ -703,6 +703,30 @@ if (Grocy.CalendarFirstDayOfWeek)
});
}
if (GetUriParam("embedded"))
{
$("body").append('<div class="fixed-top"> \
<button class="btn btn-light float-right close-last-modal-button" \
type="button" \> \
<i class="fa-solid fa-xmark"></i> \
</button> \
</div>');
}
$(document).on("click", ".close-last-modal-button", function()
{
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
});
$("body").on("keydown", function(e)
{
if (e.key == "Escape")
{
window.parent.postMessage(WindowMessageBag("CloseLastModal"), Grocy.BaseUrl);
}
});
$(window).on("message", function(e)
{
var data = e.originalEvent.data;
@@ -769,17 +793,7 @@ function IframeModal(link, dialogClass = "form")
size: 'large',
backdrop: true,
closeButton: false,
className: dialogClass,
buttons: {
cancel: {
label: __t('Close'),
className: 'btn-secondary responsive-button',
callback: function()
{
$(".modal").last().modal("hide");
}
}
}
className: dialogClass
});
}

View File

@@ -107,5 +107,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('battery-form');

View File

@@ -492,7 +492,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductPicker.HideCustomError();
Grocy.FrontendHelpers.ValidateForm('consume-form');
$('#display_amount').focus();
setTimeout(function()
{
$('#display_amount').focus();
}, 150);
if (productDetails.stock_amount == productDetails.stock_amount_opened || productDetails.product.enable_tare_weight_handling == 1)
{

View File

@@ -311,7 +311,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$('#display_amount').val(productDetails.stock_amount);
RefreshLocaleNumberInput();
$(".input-group-productamountpicker").trigger("change");
$('#display_amount').focus();
setTimeout(function()
{
$('#display_amount').focus();
}, 150);
$('#display_amount').trigger('keyup');
RefreshPriceHint();
},

View File

@@ -93,4 +93,4 @@ Grocy.FrontendHelpers.ValidateForm('location-form');
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);

View File

@@ -99,7 +99,7 @@ Grocy.FrontendHelpers.ValidateForm('barcode-form');
setTimeout(function()
{
$('#barcode').focus();
}, 250);
}, 150);
RefreshLocaleNumberInput();
Grocy.Components.UserfieldsForm.Load()

View File

@@ -78,5 +78,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('product-group-form');

View File

@@ -343,7 +343,10 @@ if (Grocy.Components.ProductPicker !== undefined)
$("#stock_label_type").trigger("change");
}
$("#display_amount").focus();
setTimeout(function()
{
$('#display_amount').focus();
}, 150);
Grocy.FrontendHelpers.ValidateForm('purchase-form');
if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && Grocy.FrontendHelpers.ValidateForm("purchase-form"))

View File

@@ -124,14 +124,14 @@ if (!Grocy.Components.ProductPicker.InAnyFlow())
setTimeout(function()
{
$("#display_amount").focus();
}, 250);
}, 150);
}
else
{
setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 250);
}, 150);
}
}
else
@@ -143,7 +143,7 @@ else
setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 250);
}, 150);
}
}

View File

@@ -82,5 +82,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('shopping-list-form');

View File

@@ -210,7 +210,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
$("#display_amount").trigger("change");
}
$('#display_amount').focus();
setTimeout(function()
{
$('#display_amount').focus();
}, 150);
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
Grocy.ShoppingListItemFormInitialLoadDone = true;
},
@@ -289,14 +292,14 @@ if (!Grocy.Components.ProductPicker.InAnyFlow())
setTimeout(function()
{
$("#display_amount").focus();
}, 250);
}, 150);
}
else
{
setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 250);
}, 150);
}
}
else
@@ -308,7 +311,7 @@ else
setTimeout(function()
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}, 250);
}, 150);
}
}

View File

@@ -92,5 +92,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('shoppinglocation-form');

View File

@@ -149,5 +149,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#amount').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm("stockentry-form");

View File

@@ -92,5 +92,5 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('task-category-form');

View File

@@ -112,6 +112,6 @@ Grocy.Components.UserfieldsForm.Load();
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.Components.DateTimePicker.GetInputElement().trigger('input');
Grocy.FrontendHelpers.ValidateForm('task-form');

View File

@@ -280,7 +280,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Components.ProductPicker.HideCustomError();
Grocy.FrontendHelpers.ValidateForm('transfer-form');
$('#display_amount').focus();
setTimeout(function()
{
$('#display_amount').focus();
}, 150);
},
function(xhr)
{

View File

@@ -103,7 +103,7 @@ $("#show_in_sidebar_menu").on("click", function()
setTimeout(function()
{
$('#name').focus();
}, 250);
}, 150);
Grocy.FrontendHelpers.ValidateForm('userentity-form');
// Click twice to trigger on-click but not change the actual checked state