fixed list page table mobile-action permission issue..

This commit is contained in:
Cüneyt Şentürk 2023-06-14 18:11:00 +03:00
parent e1f3d1fc53
commit c430c39f1c

View File

@ -19,70 +19,70 @@
<div class="w-full my-10 m-auto flex flex-col px-2 sm:px-0 max-w-md"> <div class="w-full my-10 m-auto flex flex-col px-2 sm:px-0 max-w-md">
<div class="p-2 bg-body rounded-lg"> <div class="p-2 bg-body rounded-lg">
@foreach ($actions as $action) @foreach ($actions as $action)
@if (! empty($action['permission']))
@can($action['permission'])
@endif
@if ($count_buttons > 3 && $loop->count > 4) @if ($count_buttons > 3 && $loop->count > 4)
@break @break
@endif @endif
@php @if (isset($action['type']) && $action['type'] == 'divider')
$type = ! empty($action['type']) ? $action['type'] : 'link'; @continue
@endphp @endif
@switch($type) @if (
@case('button') empty($action['permission'])
<button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9" {!! $action['attributes'] ?? null !!}> || (! empty($action['permission']) && user()->can($action['permission']))
<div class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100"> )
<span class="material-icons-outlined text-purple text-lg ltr:mr-2 rtl:ml-2 pointer-events-none"> @php
{{ $action['icon'] }} $type = ! empty($action['type']) ? $action['type'] : 'link';
</span> @endphp
{{ $action['title'] }} @switch($type)
</div> @case('button')
</button> <button type="button" class="w-full flex items-center text-purple px-2 h-9 leading-9" {!! $action['attributes'] ?? null !!}>
@break <div class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">
<span class="material-icons-outlined text-purple text-lg ltr:mr-2 rtl:ml-2 pointer-events-none">
{{ $action['icon'] }}
</span>
@case('delete') {{ $action['title'] }}
@php </div>
$title = $action['title'] ?? null; </button>
$modelId = ! empty($action['model-id']) ? $action['model-id'] : 'id'; @break
$modelName = ! empty($action['model-name']) ? $action['model-name'] : 'name';
@endphp
<x-delete-button :model="$action['model']" :route="$action['route']" :text="$title" :model-id="$modelId" :model-name="$modelName" /> @case('delete')
@break @php
$title = $action['title'] ?? null;
$modelId = ! empty($action['model-id']) ? $action['model-id'] : 'id';
$modelName = ! empty($action['model-name']) ? $action['model-name'] : 'name';
@endphp
@default <x-delete-button :model="$action['model']" :route="$action['route']" :text="$title" :model-id="$modelId" :model-name="$modelName" />
<a href="{{ $action['url'] }}" class="w-full flex items-center text-purple px-2 h-9 leading-9" {!! $action['attributes'] ?? null !!}> @break
<div class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">
<span class="material-icons-outlined text-purple text-lg ltr:mr-2 rtl:ml-2 pointer-events-none">
{{ $action['icon'] }}
</span>
{{ $action['title'] }} @default
</div> <a href="{{ $action['url'] }}" class="w-full flex items-center text-purple px-2 h-9 leading-9" {!! $action['attributes'] ?? null !!}>
</a> <div class="w-full h-full flex items-center rounded-md px-2 text-sm hover:bg-lilac-100">
@endswitch <span class="material-icons-outlined text-purple text-lg ltr:mr-2 rtl:ml-2 pointer-events-none">
{{ $action['icon'] }}
</span>
@php {{ $action['title'] }}
array_shift($actions); </div>
</a>
@endswitch
$count_buttons++; @php
@endphp array_shift($actions);
@if (! empty($action['permission'])) $count_buttons++;
@endcan @endphp
@endif @endif
@endforeach @endforeach
@foreach ($actions as $action) @foreach ($actions as $action)
@if (! empty($action['permission'])) @if (
@can($action['permission']) empty($action['permission'])
@php $more_actions[] = $action; @endphp || (! empty($action['permission']) && user()->can($action['permission']))
@endcan )
@else
@php $more_actions[] = $action; @endphp @php $more_actions[] = $action; @endphp
@endif @endif
@endforeach @endforeach
@ -147,4 +147,4 @@
@endif @endif
</div> </div>
</div> </div>
</div> </div>