mirror of
https://github.com/grocy/grocy.git
synced 2025-10-22 20:46:33 +00:00
Make it possible to test quantity unit plural forms (closes #261)
This commit is contained in:
@@ -26,6 +26,10 @@
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else if (redirectDestination == "stay")
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);
|
||||
@@ -50,6 +54,10 @@
|
||||
{
|
||||
window.location.reload();
|
||||
}
|
||||
else if (redirectDestination == "stay")
|
||||
{
|
||||
// Do nothing
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = redirectDestination.replace("editobjectid", Grocy.EditObjectId);
|
||||
@@ -181,3 +189,22 @@ $("#qu-conversion-add-button").on("click", function(e)
|
||||
Grocy.QuantityUnitEditFormRedirectUri = U("/quantityunitconversion/new?qu-unit=editobjectid");
|
||||
$('#save-quantityunit-button').click();
|
||||
});
|
||||
|
||||
$("#test-quantityunit-plural-forms-button").on("click", function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
|
||||
Grocy.QuantityUnitEditFormRedirectUri = "stay";
|
||||
$("#save-quantityunit-button").click();
|
||||
|
||||
bootbox.alert({
|
||||
message: '<iframe height="400px" class="embed-responsive" src="' + U("/quantityunitpluraltesting?embedded&qu=") + Grocy.EditObjectId.toString() + '"></iframe>',
|
||||
closeButton: false,
|
||||
size: "large",
|
||||
callback: function(result)
|
||||
{
|
||||
Grocy.QuantityUnitEditFormRedirectUri = undefined;
|
||||
Grocy.FrontendHelpers.EndUiBusy("quantityunit-form");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
38
public/viewjs/quantityunitpluraltesting.js
Normal file
38
public/viewjs/quantityunitpluraltesting.js
Normal file
@@ -0,0 +1,38 @@
|
||||
$("#qu_id").change(function(event)
|
||||
{
|
||||
RefreshQuPluralTestingResult();
|
||||
});
|
||||
|
||||
$("#amount").keyup(function (event)
|
||||
{
|
||||
RefreshQuPluralTestingResult();
|
||||
});
|
||||
|
||||
$("#amount").change(function (event)
|
||||
{
|
||||
RefreshQuPluralTestingResult();
|
||||
});
|
||||
|
||||
function RefreshQuPluralTestingResult()
|
||||
{
|
||||
var singularForm = $("#qu_id option:selected").data("singular-form");
|
||||
var pluralForm = $("#qu_id option:selected").data("plural-form");
|
||||
var amount = $("#amount").val();
|
||||
|
||||
if (singularForm.toString().isEmpty() || amount.toString().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$("#result").parent().effect("highlight", {}, 100);
|
||||
$("#result").fadeOut(100, function ()
|
||||
{
|
||||
$(this).text(__n(amount, singularForm, pluralForm)).fadeIn(100);
|
||||
});
|
||||
}
|
||||
|
||||
if (GetUriParam("qu") !== undefined)
|
||||
{
|
||||
$("#qu_id").val(GetUriParam("qu"));
|
||||
$("#qu_id").trigger("change");
|
||||
}
|
Reference in New Issue
Block a user