Fixed #15504 - allow nulling/not changing locale in user bulk edit

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-09-16 14:31:10 +01:00
parent 8774da3921
commit 4debaaea39
5 changed files with 29 additions and 2 deletions

View file

@ -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';

View file

@ -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');
}

View file

@ -122,6 +122,7 @@ class User extends SnipeModel implements AuthenticatableContract, AuthorizableCo
'jobtitle',
'employee_num',
'website',
'locale',
];
/**

View file

@ -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,

View file

@ -90,15 +90,24 @@
</div>
<!-- language -->
<!-- Language -->
<div class="form-group {{ $errors->has('locale') ? 'has-error' : '' }}">
<label class="col-md-3 control-label" for="locale">{{ trans('general.language') }}</label>
<div class="col-md-8">
{!! Form::locales('locale', old('locale', $user->locale), 'select2') !!}
{!! Form::locales('locale', old('locale', ''), 'select2') !!}
{!! $errors->first('locale', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
</div>
</div>
<div class="form-group">
<div class=" col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::checkbox('null_locale', '1', false) }}
{{ trans_choice('general.set_users_field_to_null', count($users), ['field' => trans('general.language'), 'user_count' => count($users)]) }}
</label>
</div>
</div>
<!-- City -->
<div class="form-group{{ $errors->has('city') ? ' has-error' : '' }}">
<label class="col-md-3 control-label" for="city">{{ trans('general.city') }}</label>