Implemented Userfields for users (closes #1159)

This commit is contained in:
Bernd Bestel 2020-12-20 22:16:58 +01:00
parent 8f1ce607f7
commit 2b13102299
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
4 changed files with 18 additions and 1 deletions

View File

@ -157,6 +157,7 @@
- Dialogs are now used everywhere where appropriate instead of jumping between pages (for example when adding/editing shopping list items)
- Added a "Clear filter"-button on all pages (with filters) to quickly reset applied filters
- Users can now have a picture (will then be shown next to the current user name instead of the generic user icon)
- Users can now also have Userfields
- Prefilled number inputs now use sensible decimal places (max. the configured decimals while hiding trailing zeros where appropriate, means if you never use partial amounts for a product, you'll never see decimals for it)
- Improved / more precise validation messages for number inputs
- Ordering now happens case-insensitive

View File

@ -64,7 +64,9 @@ class UsersController extends BaseController
{
User::checkPermission($request, User::PERMISSION_USERS_READ);
return $this->renderPage($response, 'users', [
'users' => $this->getDatabase()->users()->orderBy('username')
'users' => $this->getDatabase()->users()->orderBy('username'),
'userfields' => $this->getUserfieldsService()->GetFields('users'),
'userfieldValues' => $this->getUserfieldsService()->GetAllValues('users')
]);
}
}

View File

@ -138,4 +138,5 @@ $("#delete-current-user-picture-button").on("click", function(e)
$("#user-picture-label-none").removeClass("d-none");
});
Grocy.Components.UserfieldsForm.Load();
Grocy.FrontendHelpers.ValidateForm('user-form');

View File

@ -29,6 +29,10 @@
href="{{ $U('/user/new') }}">
{{ $__t('Add') }}
</a>
<a class="btn btn-outline-secondary m-1 mt-md-0 mb-md-0 float-right"
href="{{ $U('/userfields?entity=users') }}">
{{ $__t('Configure userfields') }}
</a>
</div>
</div>
</div>
@ -76,6 +80,10 @@
<th>{{ $__t('Username') }}</th>
<th>{{ $__t('First name') }}</th>
<th>{{ $__t('Last name') }}</th>
@include('components.userfields_thead', array(
'userfields' => $userfields
))
</tr>
</thead>
<tbody class="d-none">
@ -112,6 +120,11 @@
<td>
{{ $user->last_name }}
</td>
@include('components.userfields_tbody', array(
'userfields' => $userfields,
'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $user->id)
))
</tr>
@endforeach
</tbody>