Implemented new Userfield type "Link" (references #258)

This commit is contained in:
Bernd Bestel
2019-09-17 19:33:06 +02:00
parent 6aa278c19c
commit 0fa0138972
6 changed files with 17 additions and 2 deletions

View File

@@ -20,9 +20,10 @@
- Equipment improvements/fixes - Equipment improvements/fixes
- Fixed that the delete button not always deleted the currently selected equipment item - Fixed that the delete button not always deleted the currently selected equipment item
- Userfield improvements/fixes - 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 - 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 "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) - 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 - General improvements/fixes
- Improved the handling which entry page to use with disabled feature flags (thanks @nielstholenaar) - 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) - Boolean settings provided via environment variables (so the strings `true` and `false`) are now parsed correctly (thanks @mduret)

View File

@@ -38,3 +38,6 @@ msgstr "Select list (a single item can be selected)"
msgid "preset-checklist" msgid "preset-checklist"
msgstr "Select list (multiple items can be selected)" msgstr "Select list (multiple items can be selected)"
msgid "link"
msgstr "Link"

View File

@@ -38,3 +38,6 @@ msgstr ""
msgid "preset-checklist" msgid "preset-checklist"
msgstr "" msgstr ""
msgid "link"
msgstr ""

View File

@@ -13,6 +13,7 @@ class UserfieldsService extends BaseService
const USERFIELD_TYPE_CHECKBOX = 'checkbox'; const USERFIELD_TYPE_CHECKBOX = 'checkbox';
const USERFIELD_TYPE_PRESET_LIST = 'preset-list'; const USERFIELD_TYPE_PRESET_LIST = 'preset-list';
const USERFIELD_TYPE_PRESET_CHECKLIST = 'preset-checklist'; const USERFIELD_TYPE_PRESET_CHECKLIST = 'preset-checklist';
const USERFIELD_TYPE_LINK = 'link';
public function __construct() public function __construct()
{ {

View File

@@ -10,6 +10,8 @@
@if($userfieldObject->value == 1)<i class="fas fa-check"></i>@endif @if($userfieldObject->value == 1)<i class="fas fa-check"></i>@endif
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_CHECKLIST) @elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_CHECKLIST)
{!! str_replace(',', '<br>', $userfieldObject->value) !!} {!! str_replace(',', '<br>', $userfieldObject->value) !!}
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_LINK)
<a href="{{ $userfieldObject->value }}" target="_blank">{{ $userfieldObject->value }}</a>
@else @else
{{ $userfieldObject->value }} {{ $userfieldObject->value }}
@endif @endif

View File

@@ -93,6 +93,11 @@
@endforeach @endforeach
</select> </select>
</div> </div>
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_LINK)
<div class="form-group">
<label for="name">{{ $userfield->caption }}</label>
<input type="link" class="form-control userfield-input" data-userfield-name="{{ $userfield->name }}">
</div>
@endif @endif
@endforeach @endforeach