From 0fa0138972ba43a208ca50d9f00c629705b4b006 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Tue, 17 Sep 2019 19:33:06 +0200 Subject: [PATCH] Implemented new Userfield type "Link" (references #258) --- changelog/52_UNRELEASED_2019-xx-xx.md | 5 +++-- localization/en/userfield_types.po | 3 +++ localization/userfield_types.pot | 3 +++ services/UserfieldsService.php | 1 + views/components/userfields_tbody.blade.php | 2 ++ views/components/userfieldsform.blade.php | 5 +++++ 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/changelog/52_UNRELEASED_2019-xx-xx.md b/changelog/52_UNRELEASED_2019-xx-xx.md index ff5f44fb..90379d15 100644 --- a/changelog/52_UNRELEASED_2019-xx-xx.md +++ b/changelog/52_UNRELEASED_2019-xx-xx.md @@ -20,9 +20,10 @@ - Equipment improvements/fixes - Fixed that the delete button not always deleted the currently selected equipment item - Userfield improvements/fixes - - New userfield type "Select list" for a list of predefined values where a single or also multiple values can then be selected on the entity object - - Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31) + - New Userfield type "Select list" for a list of predefined values where a single or also multiple values can then be selected on the entity object + - New Userfield type "Link" - a single-line-textbox where the content will be rendered as a clickable link - Userfields of type "checkbox" are rendered as a checkmark in tables when checked (instead of "1" as till now) + - Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31) - General improvements/fixes - 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) diff --git a/localization/en/userfield_types.po b/localization/en/userfield_types.po index ffc95ec9..e54d0ea5 100644 --- a/localization/en/userfield_types.po +++ b/localization/en/userfield_types.po @@ -38,3 +38,6 @@ msgstr "Select list (a single item can be selected)" msgid "preset-checklist" msgstr "Select list (multiple items can be selected)" + +msgid "link" +msgstr "Link" diff --git a/localization/userfield_types.pot b/localization/userfield_types.pot index 2a7b7e1a..59c3e04a 100644 --- a/localization/userfield_types.pot +++ b/localization/userfield_types.pot @@ -38,3 +38,6 @@ msgstr "" msgid "preset-checklist" msgstr "" + +msgid "link" +msgstr "" diff --git a/services/UserfieldsService.php b/services/UserfieldsService.php index cb162146..5fae50a2 100644 --- a/services/UserfieldsService.php +++ b/services/UserfieldsService.php @@ -13,6 +13,7 @@ class UserfieldsService extends BaseService const USERFIELD_TYPE_CHECKBOX = 'checkbox'; const USERFIELD_TYPE_PRESET_LIST = 'preset-list'; const USERFIELD_TYPE_PRESET_CHECKLIST = 'preset-checklist'; + const USERFIELD_TYPE_LINK = 'link'; public function __construct() { diff --git a/views/components/userfields_tbody.blade.php b/views/components/userfields_tbody.blade.php index ae99cdd9..11771650 100644 --- a/views/components/userfields_tbody.blade.php +++ b/views/components/userfields_tbody.blade.php @@ -10,6 +10,8 @@ @if($userfieldObject->value == 1)@endif @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_CHECKLIST) {!! str_replace(',', '
', $userfieldObject->value) !!} + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_LINK) + {{ $userfieldObject->value }} @else {{ $userfieldObject->value }} @endif diff --git a/views/components/userfieldsform.blade.php b/views/components/userfieldsform.blade.php index 50462b9a..225d4826 100644 --- a/views/components/userfieldsform.blade.php +++ b/views/components/userfieldsform.blade.php @@ -93,6 +93,11 @@ @endforeach + @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_LINK) +
+ + +
@endif @endforeach