<?php $__env->startSection('page_title'); ?>
    <?php echo e(__('admin::app.settings.roles.edit-title')); ?>

<?php $__env->stopSection(); ?>

<?php $__env->startSection('content-wrapper'); ?>
    <div class="content full-page adjacent-center">
        <?php echo view_render_event('admin.settings.roles.edit.header.before', ['role' => $role]); ?>


        <div class="page-header">
            
            <?php echo e(Breadcrumbs::render('settings.roles.edit', $role)); ?>


            <div class="page-title">
                <h1><?php echo e(__('admin::app.settings.roles.edit-title')); ?></h1>
            </div>
        </div>

        <?php echo view_render_event('admin.settings.roles.edit.header.after', ['role' => $role]); ?>


        <form method="POST" action="<?php echo e(route('admin.settings.roles.update', ['id' => $role->id])); ?>" @submit.prevent="onSubmit">
            <div class="page-content">
                <div class="form-container">
                    <div class="panel">
                        <div class="panel-header">
                            <?php echo view_render_event('admin.settings.roles.edit.form_buttons.before', ['role' => $role]); ?>


                            <button type="submit" class="btn btn-md btn-primary">
                                <?php echo e(__('admin::app.settings.roles.save-btn-title')); ?>

                            </button>

                            <a href="<?php echo e(route('admin.settings.roles.index')); ?>">
                                <?php echo e(__('admin::app.layouts.back')); ?>

                            </a>

                            <?php echo view_render_event('admin.settings.roles.edit.form_buttons.after', ['role' => $role]); ?>

                        </div>

                        <div class="panel-body">
                            <?php echo view_render_event('admin.settings.roles.edit.form_controls.before', ['role' => $role]); ?>


                            <?php echo csrf_field(); ?>

                            <input name="_method" type="hidden" value="PUT">
                            
                            <div class="form-group" :class="[errors.has('name') ? 'has-error' : '']">
                                <label class="required">
                                    <?php echo e(__('admin::app.layouts.name')); ?>

                                </label>

                                <input
                                    type="text"
                                    name="name"
                                    class="control"
                                    value="<?php echo e(old('name') ?? $role->name); ?>"
                                    placeholder="<?php echo e(__('admin::app.layouts.name')); ?>"
                                    v-validate="'required'"
                                    data-vv-as="<?php echo e(__('admin::app.layouts.name')); ?>"
                                />

                                <span class="control-error" v-if="errors.has('name')">
                                    {{ errors.first('name') }}
                                </span>
                            </div>

                            <div class="form-group" :class="[errors.has('description') ? 'has-error' : '']">
                                <label class="required">
                                    <?php echo e(__('admin::app.settings.roles.description')); ?>

                                </label>

                                <textarea
                                    class="control"
                                    name="description"
                                    placeholder="<?php echo e(__('admin::app.settings.roles.description')); ?>"
                                    v-validate="'required'"
                                    data-vv-as="<?php echo e(__('admin::app.settings.roles.description')); ?>"
                                ><?php echo e(old('description') ?? $role->description); ?></textarea>

                                <span class="control-error" v-if="errors.has('description')">
                                    {{ errors.first('description') }}
                                </span>
                            </div>

                            <div class="form-group" :class="[errors.has('permission_type') ? 'has-error' : '']">
                                <label class="required">
                                    <?php echo e(__('admin::app.settings.roles.permission_type')); ?>

                                </label>

                                <?php $selectedOption = old('permission_type') ?: $role->permission_type ?>

                                <select
                                    class="control"
                                    name="permission_type"
                                    id="permission_type"
                                    v-validate="'required'"
                                    data-vv-as="<?php echo e(__('admin::app.settings.roles.role')); ?>"
                                >
                                    <option value="custom" <?php echo e($selectedOption == 'custom' ? 'selected' : ''); ?>>
                                        <?php echo e(__('admin::app.settings.roles.custom')); ?>

                                    </option>

                                    <option value="all" <?php echo e($selectedOption == 'all' ? 'selected' : ''); ?>>
                                        <?php echo e(__('admin::app.settings.roles.all')); ?>

                                    </option>
                                </select>

                                <span class="control-error" v-if="errors.has('permission_type')">
                                    {{ errors.first('permission_type') }}
                                </span>
                            </div>

                            <div class="control-group tree-wrapper <?php echo e($selectedOption == 'all' ? 'hide' : ''); ?>">
                                <tree-view value-field="key" id-field="key" items='<?php echo json_encode($acl->items, 15, 512) ?>' value='<?php echo json_encode($role->permissions, 15, 512) ?>'></tree-view>
                            </div>

                            <?php echo view_render_event('admin.settings.roles.edit.form_controls.after', ['role' => $role]); ?>

                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
<?php $__env->stopSection(); ?>

<?php $__env->startPush('scripts'); ?>
    <script>
        $(document).ready(function () {
            $('#permission_type').on('change', function(event) {
                if ($(event.target).val() == 'custom') {
                    $('.tree-wrapper').removeClass('hide')
                } else {
                    $('.tree-wrapper').addClass('hide')
                }

            })
        });
    </script>
<?php $__env->stopPush(); ?>
<?php echo $__env->make('admin::layouts.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/quikappspane/public_html/gestionquik/laravel-crm/packages/Webkul/Admin/src/Providers/../Resources/views/settings/roles/edit.blade.php ENDPATH**/ ?>