Make Userfields reorderable (closes #1134)

This commit is contained in:
Bernd Bestel 2020-11-17 20:12:45 +01:00
parent 887526c727
commit 6270f39688
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
6 changed files with 44 additions and 3 deletions

View File

@ -119,6 +119,7 @@
### Userfield improvements/fixes ### Userfield improvements/fixes
- New Userfield type "File" to attach any file, will be rendered as a link to the file in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc) - New Userfield type "File" to attach any file, will be rendered as a link to the file in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc)
- New Userfield type "Picture" to attach a picture, the picture will be rendered (small) in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc) - New Userfield type "Picture" to attach a picture, the picture will be rendered (small) in tables (if enabled) (thanks @fipwmaqzufheoxq92ebc)
- Userfields can now be reordered on the input form (new field "Sort number" per Userfield, fields will be ordered by that number, if any)
### General & other improvements/fixes ### General & other improvements/fixes
- UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this) - UI refresh / style improvements (thanks @zsarnett for the idea and initial work on this)

View File

@ -1975,3 +1975,18 @@ msgstr ""
msgid "Automatically do the booking using the last price and the amount of the shopping list item, if the product has \"Default due days\" set" msgid "Automatically do the booking using the last price and the amount of the shopping list item, if the product has \"Default due days\" set"
msgstr "" msgstr ""
msgid "When moving products from/to a freezer location, the products due date is automatically adjusted according to the product settings"
msgstr ""
msgid "This is the internal field name, e. g. for the API"
msgstr ""
msgid "This is used to display the field on the frontend"
msgstr ""
msgid "Multiple Userfields will be ordered by that number on the input form"
msgstr ""
msgid "Sort number"
msgstr ""

2
migrations/0119.sql Normal file
View File

@ -0,0 +1,2 @@
ALTER TABLE userfields
ADD sort_number INTEGER;

View File

@ -65,7 +65,7 @@ class UserfieldsService extends BaseService
throw new \Exception('Entity does not exist or is not exposed'); throw new \Exception('Entity does not exist or is not exposed');
} }
return $this->getDatabase()->userfields()->where('entity', $entity)->orderBy('name', 'COLLATE NOCASE')->fetchAll(); return $this->getDatabase()->userfields()->where('entity', $entity)->orderBy('sort_number')->orderBy('name', 'COLLATE NOCASE')->fetchAll();
} }
public function GetValues($entity, $objectId) public function GetValues($entity, $objectId)

View File

@ -49,7 +49,12 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="name">{{ $__t('Name') }}</label> <label for="name">
{{ $__t('Name') }}
<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
title="{{ $__t('This is the internal field name, e. g. for the API') }}"></i>
</label>
<input type="text" <input type="text"
class="form-control" class="form-control"
required required
@ -61,7 +66,12 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="name">{{ $__t('Caption') }}</label> <label for="name">
{{ $__t('Caption') }}
<i class="fas fa-question-circle text-muted"
data-toggle="tooltip"
title="{{ $__t('This is used to display the field on the frontend') }}"></i>
</label>
<input type="text" <input type="text"
class="form-control" class="form-control"
required required
@ -71,6 +81,15 @@
<div class="invalid-feedback">{{ $__t('A caption is required') }}</div> <div class="invalid-feedback">{{ $__t('A caption is required') }}</div>
</div> </div>
@include('components.numberpicker', array(
'id' => 'sort_number',
'label' => 'Sort number',
'min' => 0,
'value' => $userfield->sort_number,
'isRequired' => false,
'hint' => $__t('Multiple Userfields will be ordered by that number on the input form')
))
<div class="form-group"> <div class="form-group">
<label for="type">{{ $__t('Type') }}</label> <label for="type">{{ $__t('Type') }}</label>
<select required <select required

View File

@ -92,6 +92,7 @@
<th>{{ $__t('Name') }}</th> <th>{{ $__t('Name') }}</th>
<th>{{ $__t('Caption') }}</th> <th>{{ $__t('Caption') }}</th>
<th>{{ $__t('Type') }}</th> <th>{{ $__t('Type') }}</th>
<th>{{ $__t('Sort number') }}</th>
</tr> </tr>
</thead> </thead>
<tbody class="d-none"> <tbody class="d-none">
@ -125,6 +126,9 @@
<td> <td>
{{ $__t($userfield->type) }} {{ $__t($userfield->type) }}
</td> </td>
<td>
{{ $userfield->sort_number }}
</td>
</tr> </tr>
@endforeach @endforeach
</tbody> </tbody>