mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 01:32:38 +00:00
Implemented new Userfield type "Select list" (closes #325)
This commit is contained in:
parent
bbd5ce1dc4
commit
0c27157db6
@ -19,6 +19,8 @@
|
|||||||
- When tracking an execution from the chores overview page, filter are re-applied afterwards (means when have filtered the page to only show overdue chores and after the execution the chore is not overdue anymore, it will now immediately hide id)
|
- When tracking an execution from the chores overview page, filter are re-applied afterwards (means when have filtered the page to only show overdue chores and after the execution the chore is not overdue anymore, it will now immediately hide id)
|
||||||
- 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
|
||||||
|
- 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
|
||||||
- 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)
|
||||||
- Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31)
|
- Fixed that the Userfield type "Preset list" had always the caption "Product group" instead of the configured one (thanks @oncleben31)
|
||||||
|
@ -32,3 +32,9 @@ msgstr "Date & time"
|
|||||||
|
|
||||||
msgid "checkbox"
|
msgid "checkbox"
|
||||||
msgstr "Checkbox"
|
msgstr "Checkbox"
|
||||||
|
|
||||||
|
msgid "preset-list"
|
||||||
|
msgstr "Select list (a single item can be selected)"
|
||||||
|
|
||||||
|
msgid "preset-checklist"
|
||||||
|
msgstr "Select list (multiple items can be selected)"
|
||||||
|
@ -35,3 +35,6 @@ msgstr ""
|
|||||||
|
|
||||||
msgid "preset-list"
|
msgid "preset-list"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
msgid "preset-checklist"
|
||||||
|
msgstr ""
|
||||||
|
@ -112,3 +112,8 @@ FindAllObjectsInArrayByPropertyValue = function(array, propertyName, propertyVal
|
|||||||
|
|
||||||
return returnArray;
|
return returnArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$.fn.hasAttr = function(name)
|
||||||
|
{
|
||||||
|
return this.attr(name) !== undefined;
|
||||||
|
};
|
||||||
|
@ -14,7 +14,7 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
|||||||
|
|
||||||
var jsonData = { };
|
var jsonData = { };
|
||||||
|
|
||||||
$("#userfields-form .userfield-input").each(function()
|
$("#userfields-form .userfield-input").not("div").each(function()
|
||||||
{
|
{
|
||||||
var input = $(this);
|
var input = $(this);
|
||||||
var fieldName = input.attr("data-userfield-name");
|
var fieldName = input.attr("data-userfield-name");
|
||||||
@ -28,6 +28,10 @@ Grocy.Components.UserfieldsForm.Save = function(success, error)
|
|||||||
jsonData[fieldName] = "1";
|
jsonData[fieldName] = "1";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if ($(this).hasAttr("multiple"))
|
||||||
|
{
|
||||||
|
jsonData[fieldName] = $(this).val().join(",");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
jsonData[fieldName] = fieldValue;
|
jsonData[fieldName] = fieldValue;
|
||||||
@ -70,6 +74,11 @@ Grocy.Components.UserfieldsForm.Load = function()
|
|||||||
{
|
{
|
||||||
input.prop("checked", true);
|
input.prop("checked", true);
|
||||||
}
|
}
|
||||||
|
else if (input.hasAttr("multiple"))
|
||||||
|
{
|
||||||
|
input.val(value.split(","));
|
||||||
|
$(".selectpicker").selectpicker("render");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
input.val(value);
|
input.val(value);
|
||||||
|
@ -72,7 +72,7 @@ $("#type").on("change", function(e)
|
|||||||
{
|
{
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
|
|
||||||
if (value === "preset-list")
|
if (value === "preset-list" || value === "preset-checklist")
|
||||||
{
|
{
|
||||||
$("#config").parent().removeClass("d-none");
|
$("#config").parent().removeClass("d-none");
|
||||||
$("#config-hint").text(__t("A predefined list of values, one per line"));
|
$("#config-hint").text(__t("A predefined list of values, one per line"));
|
||||||
|
@ -12,6 +12,7 @@ class UserfieldsService extends BaseService
|
|||||||
const USERFIELD_TYPE_DATETIME = 'datetime';
|
const USERFIELD_TYPE_DATETIME = 'datetime';
|
||||||
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';
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
|
@ -8,15 +8,6 @@
|
|||||||
|
|
||||||
@section('viewJsName', 'choreform')
|
@section('viewJsName', 'choreform')
|
||||||
|
|
||||||
@push('pageScripts')
|
|
||||||
<script src="{{ $U('/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js?v=', true) }}{{ $version }}"></script>
|
|
||||||
@if(!empty($__t('bootstrap-select_locale') && $__t('bootstrap-select_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/bootstrap-select/dist/js/i18n/defaults-{{ $__t('bootstrap-select_locale') }}.js?v={{ $version }}"></script>@endif
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
@push('pageStyles')
|
|
||||||
<link href="{{ $U('/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
|
||||||
@endpush
|
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-lg-6 col-xs-12">
|
<div class="col-lg-6 col-xs-12">
|
||||||
|
@ -7,9 +7,11 @@
|
|||||||
<td>
|
<td>
|
||||||
@if($userfieldObject !== null)
|
@if($userfieldObject !== null)
|
||||||
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
|
@if($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_CHECKBOX)
|
||||||
@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)
|
||||||
|
{!! str_replace(',', '<br>', $userfieldObject->value) !!}
|
||||||
@else
|
@else
|
||||||
{{ $userfieldObject->value }}
|
{{ $userfieldObject->value }}
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</td>
|
</td>
|
||||||
|
@ -84,6 +84,15 @@
|
|||||||
@endforeach
|
@endforeach
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
@elseif($userfield->type == \Grocy\Services\UserfieldsService::USERFIELD_TYPE_PRESET_CHECKLIST)
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{ $userfield->name }}">{{ $userfield->caption }}</label>
|
||||||
|
<select multiple class="form-control userfield-input selectpicker" data-userfield-name="{{ $userfield->name }}" data-actions-Box="true" data-live-search="true">
|
||||||
|
@foreach(preg_split('/\r\n|\r|\n/', $userfield->config) as $option)
|
||||||
|
<option value="{{ $option }}">{{ $option }}</option>
|
||||||
|
@endforeach
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@endforeach
|
@endforeach
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
<link href="{{ $U('/node_modules/toastr/build/toastr.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/node_modules/toastr/build/toastr.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
<link href="{{ $U('/node_modules/tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/node_modules/tempusdominus-bootstrap-4/build/css/tempusdominus-bootstrap-4.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
<link href="{{ $U('/node_modules/summernote/dist/summernote-bs4.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/node_modules/summernote/dist/summernote-bs4.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
|
<link href="{{ $U('/node_modules/bootstrap-select/dist/css/bootstrap-select.min.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
<link href="{{ $U('/components_unmanaged/noto-sans-v6-latin/noto-sans-v6-latin.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/components_unmanaged/noto-sans-v6-latin/noto-sans-v6-latin.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
<link href="{{ $U('/css/grocy.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/css/grocy.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
<link href="{{ $U('/css/grocy_night_mode.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
<link href="{{ $U('/css/grocy_night_mode.css?v=', true) }}{{ $version }}" rel="stylesheet">
|
||||||
@ -387,6 +388,8 @@
|
|||||||
<script src="{{ $U('/node_modules/gettext-translator/src/translator.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/gettext-translator/src/translator.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/node_modules/summernote/dist/summernote-bs4.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/node_modules/summernote/dist/summernote-bs4.js?v=', true) }}{{ $version }}"></script>
|
||||||
@if(!empty($__t('summernote_locale') && $__t('summernote_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/summernote/dist/lang/summernote-{{ $__t('summernote_locale') }}.js?v={{ $version }}"></script>@endif
|
@if(!empty($__t('summernote_locale') && $__t('summernote_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/summernote/dist/lang/summernote-{{ $__t('summernote_locale') }}.js?v={{ $version }}"></script>@endif
|
||||||
|
<script src="{{ $U('/node_modules/bootstrap-select/dist/js/bootstrap-select.min.js?v=', true) }}{{ $version }}"></script>
|
||||||
|
@if(!empty($__t('bootstrap-select_locale') && $__t('bootstrap-select_locale') != 'x'))<script src="{{ $U('/node_modules', true) }}/bootstrap-select/dist/js/i18n/defaults-{{ $__t('bootstrap-select_locale') }}.js?v={{ $version }}"></script>@endif
|
||||||
|
|
||||||
<script src="{{ $U('/js/extensions.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/extensions.js?v=', true) }}{{ $version }}"></script>
|
||||||
<script src="{{ $U('/js/grocy.js?v=', true) }}{{ $version }}"></script>
|
<script src="{{ $U('/js/grocy.js?v=', true) }}{{ $version }}"></script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user