-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
actions.blade.php
137 lines (115 loc) · 7.36 KB
/
actions.blade.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@php
$count_buttons = 1;
$more_actions = [];
@endphp
@mobile
<x-table.actions-mobile :actions="$actions" :model="$model" />
@else
<div class="absolute ltr:right-12 rtl:left-12 -top-4 hidden items-center group-hover:flex">
@foreach ($actions as $action)
@if ($count_buttons > 3 && $loop->count > 4)
@break
@endif
@if (
empty($action['permission'])
|| (! empty($action['permission']) && user()->can($action['permission']))
)
@php
$type = ! empty($action['type']) ? $action['type'] : 'link';
@endphp
@switch($type)
@case('button')
<button type="button" class="relative bg-white hover:bg-gray-100 border py-0.5 px-1 cursor-pointer index-actions group/tooltip" {!! $action['attributes'] ?? null !!}>
<span class="material-icons-outlined text-purple text-lg pointer-events-none">
{{ $action['icon'] }}
</span>
<div class="inline-block absolute invisible z-20 py-1 px-2 text-sm font-medium text-gray-900 bg-white rounded-lg border border-gray-200 shadow-sm whitespace-nowrap opacity-0 -top-10 -left-2 group-hover/tooltip:opacity-100 group-hover/tooltip:visible" data-tooltip-placement="top">
<span>{{ $action['title'] }}</span>
<div class="absolute w-2 h-2 -bottom-1 before:content-[' '] before:absolute before:w-2 before:h-2 before:bg-white before:border-gray-200 before:transform before:rotate-45 before:border before:border-t-0 before:border-l-0" data-popper-arrow></div>
</div>
</button>
@break
@case('delete')
@php
$text = $action['text'] ?? null;
$title = $action['title'] ?? null;
$modelId = ! empty($action['model-id']) ? $action['model-id'] : 'id';
$modelName = ! empty($action['model-name']) ? $action['model-name'] : 'name';
@endphp
<x-delete-button :model="$action['model']" :route="$action['route']" :title="$title" :text="$text" :model-id="$modelId" :model-name="$modelName" />
@break
@default
<a href="{{ $action['url'] }}" class="relative bg-white hover:bg-gray-100 border py-0.5 px-1 cursor-pointer index-actions group/tooltip" {!! $action['attributes'] ?? null !!}>
<span class="material-icons-outlined text-purple text-lg pointer-events-none">
{{ $action['icon'] }}
</span>
<div class="inline-block absolute invisible z-20 py-1 px-2 text-sm font-medium text-gray-900 bg-white rounded-lg border border-gray-200 shadow-sm whitespace-nowrap opacity-0 -top-10 -left-2 group-hover/tooltip:opacity-100 group-hover/tooltip:visible" data-tooltip-placement="top">
<span>{{ $action['title'] }}</span>
<div class="absolute w-2 h-2 -bottom-1 before:content-[' '] before:absolute before:w-2 before:h-2 before:bg-white before:border-gray-200 before:transform before:rotate-45 before:border before:border-t-0 before:border-l-0" data-popper-arrow></div>
</div>
</a>
@endswitch
@php
array_shift($actions);
$count_buttons++;
@endphp
@endif
@endforeach
@foreach ($actions as $action)
@if (
empty($action['permission'])
|| (! empty($action['permission']) && user()->can($action['permission']))
)
@php $more_actions[] = $action; @endphp
@endif
@endforeach
@if ($more_actions)
@php $divider = false; @endphp
<div class="relative bg-white hover:bg-gray-100 border py-0.5 px-1 cursor-pointer index-actions">
<button type="button" data-dropdown-toggle="dropdown-actions-{{ $model->id }}-{{ $loop->index }}" data-dropdown-placement="left" class="material-icons-outlined text-purple text-lg">more_horiz</button>
<div id="dropdown-actions-{{ $model->id }}-{{ $loop->index }}" data-dropdown-actions class="absolute py-2 bg-white rounded-md border border-gray-200 shadow-xl z-20 hidden !mt-[50px]" style="left:auto; min-width:10rem;">
@foreach ($more_actions as $action)
@php
$type = ! empty($action['type']) ? $action['type'] : 'link';
@endphp
@switch($type)
@case('button')
@php $divider = false; @endphp
<div class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" {!! $action['attributes'] ?? null !!}>
<button type="button" class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">
{{ $action['title'] }}
</button>
</div>
@break
@case('delete')
@php $divider = false; @endphp
@php
$text = $action['text'] ?? null;
$title = $action['title'] ?? null;
$modelId = ! empty($action['model-id']) ? $action['model-id'] : 'id';
$modelName = ! empty($action['model-name']) ? $action['model-name'] : 'name';
@endphp
<x-delete-link :model="$action['model']" :route="$action['route']" :title="$title" :title="$text" :model-id="$modelId" :model-name="$modelName" />
@break
@case('divider')
@if (! $divider)
@php $divider = true; @endphp
<div class="py-2 px-2">
<div class="w-full border-t border-gray-200"></div>
</div>
@endif
@break
@default
@php $divider = false; @endphp
<div class="w-full flex items-center text-purple px-2 h-9 leading-9 whitespace-nowrap" {!! $action['attributes'] ?? null !!}>
<a href="{{ $action['url'] }}" class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">
{{ $action['title'] }}
</a>
</div>
@endswitch
@endforeach
</div>
</div>
@endif
</div>
@endmobile