Fix: UX улучшения по замечаниям
✅ 1. Ссылка 'Все пользователи' в просмотре организации ✅ 2. Кнопка '+' для группы с предустановленной организацией ✅ 3. Упрощён выбор типа группы (по умолчанию организация) ✅ 4. Исправлена ошибка GroupPolicy::update() ✅ 5. Управление группами в редактировании пользователя ✅ Показ всех доступных групп (общие + организации) Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
parent
00229fc4ea
commit
7782c59f5b
|
|
@ -118,7 +118,15 @@ class UserController extends Controller
|
||||||
$organizations = Organization::pluck('name', 'id');
|
$organizations = Organization::pluck('name', 'id');
|
||||||
$roles = Role::pluck('name', 'name');
|
$roles = Role::pluck('name', 'name');
|
||||||
$userGroups = $user->groups->pluck('id')->toArray();
|
$userGroups = $user->groups->pluck('id')->toArray();
|
||||||
$allGroups = $user->organization ? $user->organization->groups : collect();
|
|
||||||
|
// Показываем все доступные группы: общие + группы организации пользователя
|
||||||
|
if ($user->organization_id) {
|
||||||
|
$allGroups = Group::whereNull('organization_id')
|
||||||
|
->orWhere('organization_id', $user->organization_id)
|
||||||
|
->get();
|
||||||
|
} else {
|
||||||
|
$allGroups = Group::whereNull('organization_id')->get();
|
||||||
|
}
|
||||||
|
|
||||||
return view('admin.users.edit', compact('user', 'organizations', 'roles', 'userGroups', 'allGroups'));
|
return view('admin.users.edit', compact('user', 'organizations', 'roles', 'userGroups', 'allGroups'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,20 +20,20 @@
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Тип группы *</label>
|
<label class="form-label">Тип группы *</label>
|
||||||
<select name="group_type" id="groupType" class="form-select @error('group_type') is-invalid @enderror" required onchange="toggleOrganizationField()">
|
<select name="group_type" id="groupType" class="form-select @error('group_type') is-invalid @enderror" required onchange="toggleOrganizationField()">
|
||||||
<option value="">Выберите тип</option>
|
<option value="organization" {{ old('group_type', request('organization_id') ? 'organization' : '') == 'organization' ? 'selected' : '' }}>Группа организации</option>
|
||||||
<option value="organization" {{ old('group_type') == 'organization' ? 'selected' : '' }}>Группа организации</option>
|
<option value="general" {{ old('group_type', request('organization_id') ? '' : 'general') == 'general' ? 'selected' : '' }}>Общая группа</option>
|
||||||
<option value="general" {{ old('group_type') == 'general' ? 'selected' : '' }}>Общая группа</option>
|
|
||||||
</select>
|
</select>
|
||||||
<small class="text-muted">Группа организации — только пользователи этой организации. Общая — любые пользователи.</small>
|
<small class="text-muted">Группа организации — только пользователи этой организации. Общая — любые пользователи.</small>
|
||||||
@error('group_type')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
@error('group_type')<div class="invalid-feedback">{{ $message }}</div>@enderror
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="mb-3" id="organizationField" style="display:none;">
|
<div class="mb-3" id="organizationField" style="display:{{ request('organization_id') || old('group_type') == 'organization' ? 'block' : 'none' }};">
|
||||||
<label class="form-label">Организация *</label>
|
<label class="form-label">Организация *</label>
|
||||||
<x-searchable-select
|
<x-searchable-select
|
||||||
name="organization_id"
|
name="organization_id"
|
||||||
url="{{ route('api.organizations.search') }}"
|
url="{{ route('api.organizations.search') }}"
|
||||||
placeholder="Начните вводить название организации..."
|
placeholder="Начните вводить название организации..."
|
||||||
|
:value="request('organization_id') ?: old('organization_id')"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
@error('organization_id')<div class="invalid-feedback d-block">{{ $message }}</div>@enderror
|
@error('organization_id')<div class="invalid-feedback d-block">{{ $message }}</div>@enderror
|
||||||
|
|
|
||||||
|
|
@ -107,15 +107,18 @@
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-6 mb-4">
|
<div class="col-md-6 mb-4">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-header">
|
<div class="card-header d-flex justify-content-between align-items-center">
|
||||||
<h5 class="mb-0"><i class="bi bi-people"></i> Пользователи</h5>
|
<h5 class="mb-0"><i class="bi bi-people"></i> Пользователи</h5>
|
||||||
|
<a href="{{ route('admin.users.index', ['organization_id' => $organization->id]) }}" class="btn btn-sm btn-primary">
|
||||||
|
Все пользователи <i class="bi bi-arrow-right"></i>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@if($organization->users->count() > 0)
|
@if($organization->users->count() > 0)
|
||||||
<ul class="list-group list-group-flush">
|
<ul class="list-group list-group-flush">
|
||||||
@foreach($organization->users->take(5) as $user)
|
@foreach($organization->users->take(5) as $user)
|
||||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||||
{{ $user->name }}
|
<a href="{{ route('admin.users.show', $user) }}" class="text-decoration-none">{{ $user->name }}</a>
|
||||||
<small class="text-muted">{{ $user->email }}</small>
|
<small class="text-muted">{{ $user->email }}</small>
|
||||||
</li>
|
</li>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue