From 4debaaea39667d86fdc710c14706b90d25d08617 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 16 Sep 2024 14:31:10 +0100 Subject: [PATCH] Fixed #15504 - allow nulling/not changing locale in user bulk edit Signed-off-by: snipe --- app/Http/Controllers/Api/UsersController.php | 5 +++++ app/Http/Controllers/Users/BulkUsersController.php | 4 ++++ app/Models/User.php | 1 + app/Presenters/UserPresenter.php | 8 ++++++++ resources/views/users/bulk-edit.blade.php | 13 +++++++++++-- 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 856b3b6a69..7a126ba97a 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -206,6 +206,10 @@ class UsersController extends Controller $users->where('autoassign_licenses', '=', $request->input('autoassign_licenses')); } + if ($request->filled('locale')) { + $users = $users->where('users.locale', '=', $request->input('locale')); + } + if (($request->filled('deleted')) && ($request->input('deleted') == 'true')) { $users = $users->onlyTrashed(); @@ -276,6 +280,7 @@ class UsersController extends Controller 'end_date', 'autoassign_licenses', 'website', + 'locale', ]; $sort = in_array($request->input('sort'), $allowed_columns) ? $request->input('sort') : 'first_name'; diff --git a/app/Http/Controllers/Users/BulkUsersController.php b/app/Http/Controllers/Users/BulkUsersController.php index 5d1007e79a..a848f3808b 100644 --- a/app/Http/Controllers/Users/BulkUsersController.php +++ b/app/Http/Controllers/Users/BulkUsersController.php @@ -157,6 +157,10 @@ class BulkUsersController extends Controller $this->update_array['end_date'] = null; } + if ($request->input('null_locale')=='1') { + $this->update_array['locale'] = null; + } + if (! $manager_conflict) { $this->conditionallyAddItem('manager_id'); } diff --git a/app/Models/User.php b/app/Models/User.php index c03b0d33c0..5b3d876827 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -122,6 +122,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo 'jobtitle', 'employee_num', 'website', + 'locale', ]; /** diff --git a/app/Presenters/UserPresenter.php b/app/Presenters/UserPresenter.php index 635eaa86aa..12d833e60b 100644 --- a/app/Presenters/UserPresenter.php +++ b/app/Presenters/UserPresenter.php @@ -188,6 +188,14 @@ class UserPresenter extends Presenter 'title' => trans('general.employee_number'), 'visible' => false, ], + [ + 'field' => 'locale', + 'searchable' => true, + 'sortable' => true, + 'switchable' => true, + 'title' => trans('general.language'), + 'visible' => false, + ], [ 'field' => 'department', 'searchable' => true, diff --git a/resources/views/users/bulk-edit.blade.php b/resources/views/users/bulk-edit.blade.php index 7235035760..25519ef273 100644 --- a/resources/views/users/bulk-edit.blade.php +++ b/resources/views/users/bulk-edit.blade.php @@ -90,15 +90,24 @@ - +
- {!! Form::locales('locale', old('locale', $user->locale), 'select2') !!} + {!! Form::locales('locale', old('locale', ''), 'select2') !!} {!! $errors->first('locale', '') !!}
+
+
+ +
+
+