diff --git a/changelog/52_UNRELEASED_2019-xx-xx.md b/changelog/52_UNRELEASED_2019-xx-xx.md index e98e2f51..5ea7577c 100644 --- a/changelog/52_UNRELEASED_2019-xx-xx.md +++ b/changelog/52_UNRELEASED_2019-xx-xx.md @@ -37,12 +37,13 @@ - Product Userfields are now also rendered on the shopping list (for items which have a product referenced) - Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31) -### General improvements/fixes +### General & other improvements/fixes - Added a new `config.php` setting `CALENDAR_SHOW_WEEK_OF_YEAR` to configure if calendars should show week numbers (defaults to `true`) - Fixed that datetimepickers not considered the `config.php` setting `CALENDAR_FIRST_DAY_OF_WEEK` - Improved the handling which entry page to use with disabled feature flags (thanks @nielstholenaar) - Boolean settings provided via environment variables (so the strings `true` and `false`) are now parsed correctly (thanks @mduret) - All uploaded pictures (currently for products and recipes) are now automatically downscaled to the appropriate size when serving them to improve page load times +- It's now possible to test plural forms of quantity units (button on the quantity unit edit page) ### API improvements & non-breaking changes - New endpoint `/stock/shoppinglist/add-product` to add a product to a shopping list (thanks @Forceu) diff --git a/controllers/StockController.php b/controllers/StockController.php index 70ff6a00..64dd3fc6 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -322,4 +322,11 @@ class StockController extends BaseController ]); } } + + public function QuantityUnitPluralFormTesting(\Slim\Http\Request $request, \Slim\Http\Response $response, array $args) + { + return $this->AppContainer->view->render($response, 'quantityunitpluraltesting', [ + 'quantityUnits' => $this->Database->quantity_units()->orderBy('name') + ]); + } } diff --git a/localization/strings.pot b/localization/strings.pot index c021b3b4..d515d0f8 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -1453,3 +1453,12 @@ msgstr "" msgid "Configure fields" msgstr "" + +msgid "Quantity unit plural form testing" +msgstr "" + +msgid "Result" +msgstr "" + +msgid "Test plural forms" +msgstr "" diff --git a/public/viewjs/quantityunitform.js b/public/viewjs/quantityunitform.js index ff33755e..ef9bb016 100644 --- a/public/viewjs/quantityunitform.js +++ b/public/viewjs/quantityunitform.js @@ -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: '', + closeButton: false, + size: "large", + callback: function(result) + { + Grocy.QuantityUnitEditFormRedirectUri = undefined; + Grocy.FrontendHelpers.EndUiBusy("quantityunit-form"); + } + }); +}); diff --git a/public/viewjs/quantityunitpluraltesting.js b/public/viewjs/quantityunitpluraltesting.js new file mode 100644 index 00000000..645806dd --- /dev/null +++ b/public/viewjs/quantityunitpluraltesting.js @@ -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"); +} diff --git a/routes.php b/routes.php index 2766740f..5b4aaa1c 100644 --- a/routes.php +++ b/routes.php @@ -47,6 +47,7 @@ $app->group('', function() $this->get('/productgroup/{productGroupId}', '\Grocy\Controllers\StockController:ProductGroupEditForm'); $this->get('/stockjournal', '\Grocy\Controllers\StockController:Journal'); $this->get('/locationcontentsheet', '\Grocy\Controllers\StockController:LocationContentSheet'); + $this->get('/quantityunitpluraltesting', '\Grocy\Controllers\StockController:QuantityUnitPluralFormTesting'); } // Shopping list routes diff --git a/views/quantityunitform.blade.php b/views/quantityunitform.blade.php index 28a47b62..d5f2dd38 100644 --- a/views/quantityunitform.blade.php +++ b/views/quantityunitform.blade.php @@ -57,6 +57,7 @@ )) + diff --git a/views/quantityunitpluraltesting.blade.php b/views/quantityunitpluraltesting.blade.php new file mode 100644 index 00000000..5a42ce90 --- /dev/null +++ b/views/quantityunitpluraltesting.blade.php @@ -0,0 +1,42 @@ +@extends('layout.default') + +@section('title', $__t('Quantity unit plural form testing')) + +@section('viewJsName', 'quantityunitpluraltesting') + +@push('pageScripts') + +@endpush + +@section('content') +