mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Make it possible to test quantity unit plural forms (closes #261)
This commit is contained in:
@@ -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)
|
||||
|
@@ -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')
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -1453,3 +1453,12 @@ msgstr ""
|
||||
|
||||
msgid "Configure fields"
|
||||
msgstr ""
|
||||
|
||||
msgid "Quantity unit plural form testing"
|
||||
msgstr ""
|
||||
|
||||
msgid "Result"
|
||||
msgstr ""
|
||||
|
||||
msgid "Test plural forms"
|
||||
msgstr ""
|
||||
|
@@ -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");
|
||||
}
|
@@ -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
|
||||
|
@@ -57,6 +57,7 @@
|
||||
))
|
||||
|
||||
<button id="save-quantityunit-button" class="btn btn-success">{{ $__t('Save') }}</button>
|
||||
<button id="test-quantityunit-plural-forms-button" class="btn btn-secondary">{{ $__t('Test plural forms') }}</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
42
views/quantityunitpluraltesting.blade.php
Normal file
42
views/quantityunitpluraltesting.blade.php
Normal file
@@ -0,0 +1,42 @@
|
||||
@extends('layout.default')
|
||||
|
||||
@section('title', $__t('Quantity unit plural form testing'))
|
||||
|
||||
@section('viewJsName', 'quantityunitpluraltesting')
|
||||
|
||||
@push('pageScripts')
|
||||
<script src="{{ $U('/node_modules/jquery-ui-dist/jquery-ui.min.js?v=', true) }}{{ $version }}"></script>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="row">
|
||||
<div class="col-lg-6 col-xs-12">
|
||||
<h1>@yield('title')</h1>
|
||||
|
||||
<form id="quantityunitpluraltesting-form" novalidate>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="qu_id">{{ $__t('Quantity unit') }}</label>
|
||||
<select class="form-control" id="qu_id" name="qu_id">
|
||||
<option></option>
|
||||
@foreach($quantityUnits as $quantityUnit)
|
||||
<option value="{{ $quantityUnit->id }}" data-singular-form="{{ $quantityUnit->name }}" data-plural-form="{{ $quantityUnit->name_plural }}">{{ $quantityUnit->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@include('components.numberpicker', array(
|
||||
'id' => 'amount',
|
||||
'label' => 'Amount',
|
||||
'min' => 0.0001,
|
||||
'step' => 1,
|
||||
'isRequired' => false,
|
||||
'value' => 1
|
||||
))
|
||||
|
||||
</form>
|
||||
|
||||
<h2><strong>{{ $__t('Result') }}:</strong> <span id="result"></span></h2>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
Reference in New Issue
Block a user