<?php
use Illuminate\Support\Facades\Auth;
?>

<div class="dropdown">
    <button type="button" class="btn p-0 dropdown-toggle hide-arrow" data-bs-toggle="dropdown" aria-expanded="false">
        <i class="bx bx-dots-vertical-rounded fs-large"></i>
    </button>
    <div class="dropdown-menu">
        <a href="#" class="dropdown-item editor_open">
            <i class="bx bx-show me-1"></i> Permessi
        </a>
        @if(Auth::user()->can('edit-role'))
        <a href="#" class="dropdown-item editor_edit">
            <i class="bx bx-edit-alt me-1"></i> Modifica
        </a>
        @endif
        @if(Auth::user()->can('remove-role'))
        <a href="#" class="dropdown-item editor_delete">
            <i class="bx bx-trash me-1"></i> Elimina
        </a>
        @endif
    </div>
</div>
<script>
    $(document).on('click', 'a.editor_open', function (e) {
        e.preventDefault();
        var id = $(this).closest('tr').attr('id');
        var route = "{{ route('role.getPermissions') }}?role_id=" + id;
        $('#standardModal .modal-content').load(route + '&modal-edit=true', function () {
            $('#standardModal').modal('show');
        });
    });
</script>