16
16
17
17
<div class =" flex items-center gap-x-2.5" >
18
18
{!! view_render_event (' admin.settings.users.index.create_button.before' ) ! !}
19
-
19
+
20
20
<!-- Create button for User -->
21
21
@if (bouncer ()-> hasPermission (' settings.user.users.create' ) )
22
22
<div class =" flex items-center gap-x-2.5" >
@@ -46,7 +46,7 @@ class="primary-button"
46
46
id =" users-settings-template"
47
47
>
48
48
{!! view_render_event (' admin.settings.users.index.datagrid.before' ) ! !}
49
-
49
+
50
50
<!-- Datagrid -->
51
51
< x- admin:: datagrid
52
52
: src= " route('admin.settings.users.index')"
@@ -63,7 +63,7 @@ class="primary-button"
63
63
< template v- if = " isLoading" >
64
64
< x- admin:: shimmer .datagrid .table .body / >
65
65
< / template>
66
-
66
+
67
67
< template v- else >
68
68
< div
69
69
v- for = " record in available.records"
@@ -86,10 +86,10 @@ class="icon-checkbox-outline peer-checked:icon-checkbox-select cursor-pointer ro
86
86
: for = " `mass_action_select_record_${record.id}`"
87
87
>< / label>
88
88
< / div>
89
-
89
+
90
90
<!-- Users Id -->
91
91
< p> @ {{ record .id }}< / p>
92
-
92
+
93
93
<!-- Users Name and Profile -->
94
94
< div class = " flex items-center gap-2.5" >
95
95
< template v- if = " record.name.image" >
@@ -118,7 +118,7 @@ class="flex h-9 w-9 items-center justify-center rounded-full"
118
118
>
119
119
@ {{ record .status == 1 ? ' @lang (' admin::app.settings.users.index.active' )' : ' @lang (' admin::app.settings.users.index.inactive' )' }}
120
120
< / span>
121
-
121
+
122
122
<!-- Users Creation Date -->
123
123
< p> @ {{ record .created_at }}< / p>
124
124
@@ -131,7 +131,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
131
131
>
132
132
< / span>
133
133
< / a>
134
-
134
+
135
135
< a @click = " performAction(record.actions.find(action => action.index === 'delete'))" >
136
136
< span
137
137
: class = " record.actions.find(action => action.index === 'delete')?.icon"
@@ -160,7 +160,7 @@ class="hidden border-b px-4 py-4 text-black dark:border-gray-800 dark:text-gray-
160
160
class = " peer hidden"
161
161
v- model= " applied.massActions.indices"
162
162
>
163
-
163
+
164
164
< span class = " icon-checkbox-outline peer-checked:icon-checkbox-select cursor-pointer rounded-md text-2xl text-gray-500 peer-checked:text-brandColor" >
165
165
< / span>
166
166
< / label>
@@ -179,7 +179,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
179
179
>
180
180
< / span>
181
181
< / a>
182
-
182
+
183
183
< a @click = " performAction(record.actions.find(action => action.index === 'delete'))" >
184
184
< span
185
185
: class = " record.actions.find(action => action.index === 'delete')?.icon"
@@ -204,28 +204,31 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
204
204
< / template>
205
205
< / template>
206
206
< / x- admin:: datagrid>
207
-
207
+
208
208
{!! view_render_event (' admin.users.index.datagrid.after' ) ! !}
209
-
209
+
210
210
< x- admin:: form
211
211
v- slot= " { meta, values, errors, handleSubmit }"
212
212
as= " div"
213
213
ref= " modalForm"
214
214
>
215
- < form
215
+ < form
216
216
@submit = " handleSubmit($event, updateOrCreate)"
217
217
ref= " userForm"
218
218
>
219
219
{!! view_render_event (' admin.settings.users.index.form_controls.before' ) ! !}
220
220
221
- < x- admin:: modal ref= " userUpdateAndCreateModal" >
221
+ < x- admin:: modal
222
+ ref= " userUpdateAndCreateModal"
223
+ @toggle = " handleToggle"
224
+ >
222
225
<!-- Modal Header -->
223
226
< x- slot: header>
224
227
< p class = " text-lg font-bold text-gray-800 dark:text-white" >
225
- @ {{
228
+ @ {{
226
229
selectedType == ' create'
227
230
? " @lang (' admin::app.settings.users.index.create.title' )"
228
- : " @lang (' admin::app.settings.users.index.edit.title' )"
231
+ : " @lang (' admin::app.settings.users.index.edit.title' )"
229
232
}}
230
233
< / p>
231
234
< / x- slot>
@@ -328,7 +331,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
328
331
{!! view_render_event (' admin.settings.users.index.form.password.after' ) ! !}
329
332
330
333
{!! view_render_event (' admin.settings.users.index.form.role_id.before' ) ! !}
331
-
334
+
332
335
< div class = " flex gap-4" >
333
336
<!-- Role -->
334
337
< x- admin:: form .control - group class = " flex-1" >
@@ -347,11 +350,11 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
347
350
v- for = " role in roles"
348
351
: key= " role.id"
349
352
: value= " role.id"
350
- >
351
- @ {{ role .name }}
353
+ >
354
+ @ {{ role .name }}
352
355
< / option>
353
356
< / x- admin:: form .control - group .control >
354
-
357
+
355
358
< x- admin:: form .control - group .error control- name= " role_id" / >
356
359
< / x- admin:: form .control - group>
357
360
@@ -372,7 +375,7 @@ class="cursor-pointer rounded-md p-1.5 text-2xl transition-all hover:bg-gray-200
372
375
< option value= " global" selected>
373
376
@lang (' admin::app.settings.users.index.create.global' )
374
377
< / option>
375
-
378
+
376
379
< option value= " group" >
377
380
@lang (' admin::app.settings.users.index.create.group' )
378
381
< / option>
@@ -446,7 +449,7 @@ class="flex min-h-[39px] w-full rounded-md border px-3 py-2 text-sm text-gray-60
446
449
:: checked= " parseInt(user.status || 0)"
447
450
/ >
448
451
< / x- admin:: form .control - group>
449
-
452
+
450
453
{!! view_render_event (' admin.settings.users.index.form.status.after' ) ! !}
451
454
< / x- slot>
452
455
@@ -475,7 +478,7 @@ class="primary-button justify-center"
475
478
<script type =" module" >
476
479
app .component (' v-users-settings' , {
477
480
template: ' #users-settings-template' ,
478
-
481
+
479
482
data () {
480
483
return {
481
484
isProcessing: false ,
@@ -491,32 +494,50 @@ class="primary-button justify-center"
491
494
computed: {
492
495
gridsCount () {
493
496
let count = this .$refs .datagrid .available .columns .length ;
494
-
497
+
495
498
if (this .$refs .datagrid .available .actions .length ) {
496
499
++ count;
497
500
}
498
-
501
+
499
502
if (this .$refs .datagrid .available .massActions .length ) {
500
503
++ count;
501
504
}
502
-
505
+
503
506
return count;
504
507
},
505
508
506
509
selectedType () {
507
510
return this .user .id ? ' edit' : ' create' ;
508
511
},
509
512
},
510
-
513
+
514
+ mounted () {
515
+ @if (request (' action' ) === ' create' )
516
+ this .openModal ();
517
+ @endif
518
+ },
519
+
511
520
methods: {
521
+ handleToggle (state ) {
522
+ if (state .isActive ) {
523
+ return ;
524
+ }
525
+
526
+ const url = new URL (window .location .href );
527
+
528
+ url .searchParams .delete (' action' );
529
+
530
+ window .history .replaceState ({}, ' ' , url);
531
+ },
532
+
512
533
openModal () {
513
534
this .user = {
514
535
groups: [],
515
536
};
516
537
517
538
this .$refs .userUpdateAndCreateModal .toggle ();
518
539
},
519
-
540
+
520
541
updateOrCreate (params , {resetForm, setErrors}) {
521
542
const userForm = new FormData (this .$refs .userForm );
522
543
@@ -542,10 +563,10 @@ class="primary-button justify-center"
542
563
}
543
564
});
544
565
},
545
-
566
+
546
567
editModal (url ) {
547
568
this .$axios .get (url)
548
- .then (response => {
569
+ .then (response => {
549
570
this .user = response .data .data ;
550
571
551
572
this .user .groups = this .user .groups .map (group => group .id );
0 commit comments