<div class="table-primary">
    <table class="table table-striped table-bordered" id="comments-table" width="100%">
        <thead>
        <tr>
            <th><?php echo e(trans('admin.fields.id')); ?></th>
            <th><?php echo e(trans('admin.capsule.content')); ?></th>
            <th><?php echo e(trans('admin.capsule.created_at')); ?></th>
            <th><?php echo e(trans('admin.capsule.updated_at')); ?></th>
            <?php if($managerPermissions->contains('value', 'users.full')): ?><th></th><?php endif; ?>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>

<?php $__env->startSection('scripts'); ?>
    ##parent-placeholder-16728d18790deb58b3b8c1df74f06e536b532695##

    <script>
        var comments_table = $('#comments-table').DataTable({
            "processing": true,
            "serverSide": true,
            "pageLength": 10,
            "lengthMenu": [[15, 30], [15, 30]],
            "order": [[ 0, "desc" ]],
            "ajax": {
                "url": "<?php echo e(route('admin.user.user_comments.list', ['id' => $user->id])); ?>"
            },
            "columns": [
                {data: 'id', name: 'id'},
                {data: 'content', name: 'content'},
                {data: 'created_at', name: 'created_at'},
                {data: 'updated_at', name: 'updated_at'},
                <?php if($managerPermissions->contains('value', 'users.full')): ?>
                {
                    data: 'id',
                    name: 'id',
                    render: function (data, type, row) {
                        return "<a class='btn btn-xs btn-info' href='" + row.showLink + "'><?php echo e(__('admin.buttons.show')); ?></a>" +
                            "<a class='btn btn-xs btn-primary' href='" + row.editLink + "'><?php echo e(__('admin.buttons.edit')); ?></a>" +
                            "<a class='btn btn-xs btn-danger delete-comment' href='" + row.deleteLink + "'><?php echo e(__('admin.buttons.delete')); ?></a>";
                    },
                    orderable: false,
                    searchable: false
                }
                <?php endif; ?>
            ]
        });

        <?php if($managerPermissions->contains('value', 'users.full')): ?>
        $(document).on('click', '.delete-comment', function (e) {
            e.preventDefault();

            if (confirm('<?php echo e(__('admin.capsule.comment.ask.delete')); ?>')) {
                $.ajax({
                    url: $(this).attr('href'),
                    type: 'DELETE',
                    dataType: 'json',
                    data: { method: '_DELETE' }
                }).always(function (result) {
                    if (typeof result.status !== 'undefined' && result.status === 'success') {
                        comments_table.draw(false);
                    }
                });
            }
        });
        <?php endif; ?>
    </script>
<?php $__env->stopSection(); ?><?php /**PATH /var/www/html/resources/views.admin/admin/user/lists/comments.blade.php ENDPATH**/ ?>