edit.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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' => 'chat', 'options' => $chatSourceOptions, 'colors' => [], 'settings' => $settings['chat_settings'] ?? []],
  59. ],
  60. ])
  61. </div>
  62. {{-- <div class="tab-pane fade" id="permissions-pane" role="tabpanel" aria-labelledby="permissions-tab">--}}
  63. {{-- @if(($user?->resolvedRoleSlug()) === \App\Models\Role::ADMIN)--}}
  64. {{-- <div class="alert alert-warning py-2">--}}
  65. {{-- Администратору всегда доступны все права. Пользовательские deny и снятие прав не применяются.--}}
  66. {{-- </div>--}}
  67. {{-- @else--}}
  68. {{-- <div class="mb-2 text-muted small">--}}
  69. {{-- Значение "По роли" оставляет право как в выбранной роли. Allow или deny здесь переопределяют роль только для этого пользователя.--}}
  70. {{-- </div>--}}
  71. {{-- @endif--}}
  72. {{-- --}}
  73. {{-- @include('admin.roles.partials.permissions-table', [--}}
  74. {{-- 'permissionGroups' => $permissionGroups ?? collect(),--}}
  75. {{-- 'permissionEffects' => $permissionEffects ?? [],--}}
  76. {{-- 'inputName' => 'permission_effects',--}}
  77. {{-- 'adminLocked' => ($user?->resolvedRoleSlug()) === \App\Models\Role::ADMIN,--}}
  78. {{-- 'inheritLabel' => 'По роли',--}}
  79. {{-- ])--}}
  80. {{-- </div>--}}
  81. </div>
  82. {{-- @if($user)--}}
  83. {{-- <div class="mt-3 border-top pt-3">--}}
  84. {{-- <div class="row">--}}
  85. {{-- <label class="col-form-label small col-md-4 text-md-end">Создать роль из прав</label>--}}
  86. {{-- <div class="col-md-8">--}}
  87. {{-- <div class="input-group input-group-sm mb-2">--}}
  88. {{-- <input type="text" name="name" class="form-control" form="create-role-from-user"--}}
  89. {{-- placeholder="Название новой роли">--}}
  90. {{-- <input type="text" name="slug" class="form-control" form="create-role-from-user"--}}
  91. {{-- placeholder="code">--}}
  92. {{-- <button type="submit" class="btn btn-outline-primary" form="create-role-from-user">--}}
  93. {{-- Создать роль--}}
  94. {{-- </button>--}}
  95. {{-- </div>--}}
  96. {{-- </div>--}}
  97. {{-- </div>--}}
  98. {{-- </div>--}}
  99. {{-- @endif--}}
  100. @if($user && !is_null($user->deleted_at))
  101. <div class="col-12 text-center">
  102. <div class="text-danger">ПОЛЬЗОВАТЕЛЬ УДАЛЁН!!!</div>
  103. <a href="#" class="btn btn-sm btn-warning undelete">Восстановить</a>
  104. </div>
  105. @else
  106. @include('partials.submit', ['delete' => ['form_id' => 'delete-user'], 'back_url' => $back_url ?? route('user.index', session('gp_users', []))])
  107. @if($user && auth()->id() !== $user->id)
  108. <div class="text-center mt-2">
  109. <a href="#" class="btn btn-sm btn-outline-primary impersonate-user">Impersonate</a>
  110. </div>
  111. @endif
  112. @endif
  113. </form>
  114. @if($user)
  115. <form action="{{ route('user.undelete', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="undelete-user">
  116. @csrf
  117. </form>
  118. <form action="{{ route('user.destroy', ['user' => $user->id, 'nav' => $nav ?? null]) }}" method="post" class="d-none" id="delete-user">
  119. @method('DELETE')
  120. @csrf
  121. </form>
  122. <form action="{{ route('user.impersonate', $user->id) }}" method="post" class="d-none" id="impersonate-user">
  123. @csrf
  124. </form>
  125. {{-- <form action="{{ route('admin.roles.store-from-user', $user) }}" method="post" class="d-none" id="create-role-from-user">--}}
  126. {{-- @csrf--}}
  127. {{-- <input type="hidden" name="description" value="Создана из прав пользователя {{ $user->name }}">--}}
  128. {{-- </form>--}}
  129. @endif
  130. </div>
  131. </div>
  132. @endsection
  133. @push('scripts')
  134. <script type="module">
  135. $('.undelete').on('click', function (){
  136. customConfirm('Восстановить пользователя?', function () {
  137. $('#undelete-user').submit();
  138. });
  139. });
  140. $('.impersonate-user').on('click', function (){
  141. customConfirm('Войти от имени этого пользователя?', function () {
  142. $('#impersonate-user').submit();
  143. });
  144. });
  145. </script>
  146. @endpush