diff --git a/changelog/73_UNRELEASED_xxxx-xx-xx.md b/changelog/73_UNRELEASED_xxxx-xx-xx.md index 519b6f05..e0bee572 100644 --- a/changelog/73_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/73_UNRELEASED_xxxx-xx-xx.md @@ -47,7 +47,7 @@ ### Userfields -- xxx +- New Userfield type "Number (currency)", just like the type "Number (decimal)", but it will render the value according to / with the configured currency ### General diff --git a/localization/en/userfield_types.po b/localization/en/userfield_types.po index 457793bb..ff411a90 100644 --- a/localization/en/userfield_types.po +++ b/localization/en/userfield_types.po @@ -24,6 +24,9 @@ msgstr "Number (integral)" msgid "number-decimal" msgstr "Number (decimal)" +msgid "number-currency" +msgstr "Number (currency)" + msgid "date" msgstr "Date (without time)" diff --git a/localization/userfield_types.pot b/localization/userfield_types.pot index 6c144ed3..e9b8d8af 100644 --- a/localization/userfield_types.pot +++ b/localization/userfield_types.pot @@ -28,6 +28,10 @@ msgstr "" msgid "number-decimal" msgstr "" +# Number (currency) +msgid "number-currency" +msgstr "" + # Date (without time) msgid "date" msgstr "" diff --git a/services/UserfieldsService.php b/services/UserfieldsService.php index 75cdbb4e..903658a7 100644 --- a/services/UserfieldsService.php +++ b/services/UserfieldsService.php @@ -7,10 +7,11 @@ class UserfieldsService extends BaseService const USERFIELD_TYPE_CHECKBOX = 'checkbox'; const USERFIELD_TYPE_DATE = 'date'; const USERFIELD_TYPE_DATETIME = 'datetime'; - const USERFIELD_TYPE_DECIMAL_NUMBER = 'number-decimal'; + const USERFIELD_TYPE_NUMBER_INT = 'number-integral'; + const USERFIELD_TYPE_NUMBER_DECIMAL = 'number-decimal'; + const USERFIELD_TYPE_NUMBER_CURRENCY = 'number-currency'; const USERFIELD_TYPE_FILE = 'file'; const USERFIELD_TYPE_IMAGE = 'image'; - const USERFIELD_TYPE_INTEGRAL_NUMBER = 'number-integral'; const USERFIELD_TYPE_LINK = 'link'; const USERFIELD_TYPE_LINK_WITH_TITLE = 'link-with-title'; const USERFIELD_TYPE_PRESET_CHECKLIST = 'preset-checklist'; diff --git a/views/components/userfields_tbody.blade.php b/views/components/userfields_tbody.blade.php index 4db0503c..d3ed819c 100644 --- a/views/components/userfields_tbody.blade.php +++ b/views/components/userfields_tbody.blade.php @@ -48,6 +48,10 @@ $excludeFieldTypes = []; alt="{{ base64_decode(explode('_', $userfieldObject->value)[1]) }}" loading="lazy"> + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_DECIMAL) + {{ $userfieldObject->value }} + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_CURRENCY) + {{ $userfieldObject->value }} @else {{ $userfieldObject->value }} @endif diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 6b04f462..59224093 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -34,7 +34,7 @@ @if($userfield->input_required == 1) required @endif>
{{ $__t('Mandatory Userfield') }}
- @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_INTEGRAL_NUMBER) + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_INT) @include('components.numberpicker', array( 'id' => $userfield->name, 'label' => $userfield->caption, @@ -45,7 +45,7 @@ 'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"', 'value' => '' )) - @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DECIMAL_NUMBER) + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_DECIMAL) @include('components.numberpicker', array( 'id' => '', 'label' => $userfield->caption, @@ -57,6 +57,18 @@ 'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"', 'value' => '' )) + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_NUMBER_CURRENCY) + @include('components.numberpicker', array( + 'id' => '', + 'label' => $userfield->caption, + 'noNameAttribute' => true, + 'min' => 0, + 'decimals' => 4, + 'isRequired' => $userfield->input_required == 1, + 'additionalCssClasses' => 'userfield-input locale-number-input locale-number-currency', + 'additionalAttributes' => 'data-userfield-name="' . $userfield->name . '"', + 'value' => '' + )) @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_DATE) @include('components.datetimepicker2', array( 'id' => $userfield->name,