edit.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. @extends('layouts.app')
  2. @section('content')
  3. <div class="px-3">
  4. <div class="col-xxl-6 offset-xxl-2">
  5. <form action="{{ route('user.store', ['nav' => $nav ?? null]) }}" method="post">
  6. @csrf
  7. <input type="hidden" name="nav" value="{{ $nav ?? '' }}">
  8. @if($user)
  9. <input type="hidden" name="id" value="{{ $user->id }}">
  10. @endif
  11. <ul class="nav nav-tabs mb-3" role="tablist">
  12. <li class="nav-item" role="presentation">
  13. <button class="nav-link active" id="main-tab" data-bs-toggle="tab" data-bs-target="#main-pane" type="button" role="tab">Основное</button>
  14. </li>
  15. <li class="nav-item" role="presentation">
  16. <button class="nav-link" id="notifications-tab" data-bs-toggle="tab" data-bs-target="#notifications-pane" type="button" role="tab">Уведомления</button>
  17. </li>
  18. <li class="nav-item" role="presentation">
  19. <button class="nav-link" id="permissions-tab" data-bs-toggle="tab" data-bs-target="#permissions-pane" type="button" role="tab">Права</button>
  20. </li>
  21. </ul>
  22. <div class="tab-content">
  23. <div class="tab-pane fade show active" id="main-pane" role="tabpanel" aria-labelledby="main-tab">
  24. @include('partials.input', ['name' => 'email',
  25. 'type' => 'text',
  26. 'title' => 'Логин/email',
  27. 'required' => true,
  28. 'value' => $user->email ?? '',
  29. 'disabled' => ($user && $user->email_verified_at),
  30. ])
  31. @include('partials.input', ['name' => 'notification_email',
  32. 'type' => 'email',
  33. 'title' => 'Email для уведомлений',
  34. 'value' => old('notification_email', $user->notification_email ?? '')])
  35. @include('partials.input', ['name' => 'name', 'title' => 'Имя', 'required' => true, 'value' => $user->name ?? ''])
  36. @include('partials.input', ['name' => 'phone', 'title' => 'Телефон', 'value' => $user->phone ?? ''])
  37. @include('partials.input', ['name' => 'password', 'type' => 'password', 'title' => 'Пароль'])
  38. @include('partials.select', [
  39. 'name' => 'role_id',
  40. 'title' => 'Роль',
  41. 'options' => $roles ?? getRoleIdOptions(),
  42. 'value' => old('role_id', $user->role_id ?? null),
  43. ])
  44. @include('partials.input', ['name' => 'color', 'title' => 'Цвет', 'value' => $user->color ?? '#FFFFFF', 'type' => 'color'])
  45. @if($user)
  46. @include('partials.input', ['name' => 'token_fcm', 'title' => 'FCM Token', 'value' => $user->token_fcm ?? '', 'disabled' => true])
  47. @endif
  48. </div>
  49. <div class="tab-pane fade" id="notifications-pane" role="tabpanel" aria-labelledby="notifications-tab">
  50. @php($settings = $notificationSettings ?? [])
  51. @include('partials.notification-settings-table', [
  52. 'channels' => $notificationChannels,
  53. 'disabledChannels' => $disabledChannels ?? [],
  54. 'sections' => [
  55. ['title' => 'Площадки', 'settingsKey' => 'orders', 'options' => $orderStatusOptions, 'colors' => $orderStatusColors, 'settings' => $settings['order_settings'] ?? []],
  56. ['title' => 'Рекламации', 'settingsKey' => 'reclamations', 'options' => $reclamationStatusOptions, 'colors' => $reclamationStatusColors, 'settings' => $settings['reclamation_settings'] ?? []],
  57. ['title' => 'График монтажей', 'settingsKey' => 'schedule', 'options' => $scheduleSourceOptions, 'colors' => [], 'settings' => $settings['schedule_settings'] ?? []],
  58. ['title' => 'График заказов', 'settingsKey' => 'production_orders', 'options' => $productionOrderEventOptions, 'colors' => [], 'settings' => $settings['production_order_settings'] ?? []],
  59. ['title' => 'Чат', 'settingsKey' => 'chat', 'options' => $chatSourceOptions, 'colors' => [], 'settings' => $settings['chat_settings'] ?? []],
  60. ],
  61. ])
  62. </div>
  63. <div class="tab-pane fade" id="permissions-pane" role="tabpanel" aria-labelledby="permissions-tab">
  64. @php($isSystemAdmin = $user?->roleModel?->is_system && $user?->roleModel?->slug === \App\Models\Role::ADMIN)
  65. @if($isSystemAdmin)
  66. <div class="alert alert-warning py-2">
  67. Администратору всегда доступны все права. Пользовательские overrides для системного администратора не применяются.
  68. </div>
  69. @else
  70. <div class="mb-2 text-muted small">
  71. Значение "По роли" оставляет право как в выбранной роли. Allow или deny переопределяют право только для этого пользователя.
  72. </div>
  73. @endif
  74. @include('admin.roles.partials.permissions-table', [
  75. 'permissionGroups' => $permissionGroups ?? collect(),
  76. 'permissionEffects' => $permissionEffects ?? [],
  77. 'inheritedPermissionEffects' => $rolePermissionEffects ?? [],
  78. 'inputName' => 'permission_effects',
  79. 'adminLocked' => $isSystemAdmin,
  80. 'inheritLabel' => 'По роли',
  81. ])
  82. </div>
  83. </div>
  84. @if($user)
  85. <div class="mt-3 border-top pt-3">
  86. <div class="row">
  87. <label class="col-form-label small col-md-4 text-md-end">Создать роль из прав</label>
  88. <div class="col-md-8">
  89. <div class="input-group input-group-sm mb-2">
  90. <input type="text" name="name" class="form-control" form="create-role-from-user"
  91. placeholder="Название новой роли">
  92. <input type="text" name="slug" class="form-control" form="create-role-from-user"
  93. placeholder="code">
  94. <button type="submit" class="btn btn-outline-primary" form="create-role-from-user">
  95. Создать роль
  96. </button>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. @endif
  102. @if($user && !is_null($user->deleted_at))
  103. <div class="col-12 text-center">
  104. <div class="text-danger">ПОЛЬЗОВАТЕЛЬ УДАЛЁН!!!</div>
  105. <a href="#" class="btn btn-sm btn-warning undelete">Восстановить</a>
  106. </div>
  107. @else
  108. @include('partials.submit', ['delete' => ['form_id' => 'delete-user'], 'back_url' => $back_url ?? route('user.index', session('gp_users', []))])
  109. @if($user && auth()->id() !== $user->id)
  110. <div class="text-center mt-2">
  111. <a href="#" class="btn btn-sm btn-outline-primary impersonate-user">Impersonate</a>
  112. </div>
  113. @endif
  114. @endif
  115. </form>
  116. @if($user)
  117. <form action="{{ route('user.undelete', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="undelete-user">
  118. @csrf
  119. </form>
  120. <form action="{{ route('user.destroy', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="delete-user">
  121. @method('DELETE')
  122. @csrf
  123. </form>
  124. <form action="{{ route('user.impersonate', $user->id) }}" method="post" class="d-none" id="impersonate-user">
  125. @csrf
  126. </form>
  127. <form action="{{ route('admin.roles.store-from-user', $user) }}" method="post" class="d-none" id="create-role-from-user">
  128. @csrf
  129. <input type="hidden" name="description" value="Создана из прав пользователя {{ $user->name }}">
  130. </form>
  131. @endif
  132. </div>
  133. </div>
  134. @endsection
  135. @push('scripts')
  136. <script type="module">
  137. $('.undelete').on('click', function (){
  138. customConfirm('Восстановить пользователя?', function () {
  139. $('#undelete-user').submit();
  140. });
  141. });
  142. $('.impersonate-user').on('click', function (){
  143. customConfirm('Войти от имени этого пользователя?', function () {
  144. $('#impersonate-user').submit();
  145. });
  146. });
  147. </script>
  148. @endpush