diff --git a/changelog/60_3.0.0_2020-12-22.md b/changelog/60_3.0.0_2020-12-22.md index 286847e6..07162703 100644 --- a/changelog/60_3.0.0_2020-12-22.md +++ b/changelog/60_3.0.0_2020-12-22.md @@ -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 diff --git a/controllers/UsersController.php b/controllers/UsersController.php index a27f64c3..0037f7e5 100644 --- a/controllers/UsersController.php +++ b/controllers/UsersController.php @@ -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') ]); } } diff --git a/public/viewjs/userform.js b/public/viewjs/userform.js index 1b2f857f..43a3ed6b 100644 --- a/public/viewjs/userform.js +++ b/public/viewjs/userform.js @@ -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'); diff --git a/views/users.blade.php b/views/users.blade.php index 261b7d1b..ca573c75 100644 --- a/views/users.blade.php +++ b/views/users.blade.php @@ -29,6 +29,10 @@ href="{{ $U('/user/new') }}"> {{ $__t('Add') }} + + {{ $__t('Configure userfields') }} + @@ -76,6 +80,10 @@ {{ $__t('Username') }} {{ $__t('First name') }} {{ $__t('Last name') }} + + @include('components.userfields_thead', array( + 'userfields' => $userfields + )) @@ -112,6 +120,11 @@ {{ $user->last_name }} + + @include('components.userfields_tbody', array( + 'userfields' => $userfields, + 'userfieldValues' => FindAllObjectsInArrayByPropertyValue($userfieldValues, 'object_id', $user->id) + )) @endforeach