<?php $__env->startSection('panel'); ?>
    <div class="row">
        <div class="col-lg-12">
            <div class="card b-radius--10">
                <div class="card-body p-0">
                    <div class="table-responsive--md table-responsive">
                        <table class="table table--light style--two">
                            <thead>
                                <tr>
                                    <th><?php echo app('translator')->get('Name'); ?></th>
                                    <th><?php echo app('translator')->get('Action'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php $__empty_1 = true; $__currentLoopData = $templates; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $template): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                                    <tr>
                                        <td><?php echo e(__($template->name)); ?></td>
                                        <td>
                                            <a href="<?php echo e(route('admin.product.type.edit', $template->id)); ?>" data-resource="<?php echo e($template); ?>" class="btn btn-sm btn-outline--primary editBtn"><i class="la la-pencil"></i> <?php echo app('translator')->get('Edit'); ?></a>
                                        </td>
                                    </tr>
                                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                                    <tr>
                                        <td class="text-muted text-center" colspan="100%"><?php echo e(__($emptyMessage)); ?></td>
                                    </tr>
                                <?php endif; ?>
                            </tbody>
                        </table>
                    </div>
                    <?php if($templates->hasPages()): ?>
                        <div class="card-footer py-4">
                            <?php echo e(paginateLinks($templates)); ?>

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

<?php $__env->startPush('breadcrumb-plugins'); ?>
    <div class="d-flex gap-3">
        <?php if (isset($component)) { $__componentOriginale48b4598ffc2f41a085f001458a956d1 = $component; } ?>
<?php if (isset($attributes)) { $__attributesOriginale48b4598ffc2f41a085f001458a956d1 = $attributes; } ?>
<?php $component = Illuminate\View\AnonymousComponent::resolve(['view' => 'components.search-form','data' => []] + (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag ? $attributes->all() : [])); ?>
<?php $component->withName('search-form'); ?>
<?php if ($component->shouldRender()): ?>
<?php $__env->startComponent($component->resolveView(), $component->data()); ?>
<?php if (isset($attributes) && $attributes instanceof Illuminate\View\ComponentAttributeBag): ?>
<?php $attributes = $attributes->except(\Illuminate\View\AnonymousComponent::ignoredParameterNames()); ?>
<?php endif; ?>
<?php $component->withAttributes([]); ?>
<?php echo $__env->renderComponent(); ?>
<?php endif; ?>
<?php if (isset($__attributesOriginale48b4598ffc2f41a085f001458a956d1)): ?>
<?php $attributes = $__attributesOriginale48b4598ffc2f41a085f001458a956d1; ?>
<?php unset($__attributesOriginale48b4598ffc2f41a085f001458a956d1); ?>
<?php endif; ?>
<?php if (isset($__componentOriginale48b4598ffc2f41a085f001458a956d1)): ?>
<?php $component = $__componentOriginale48b4598ffc2f41a085f001458a956d1; ?>
<?php unset($__componentOriginale48b4598ffc2f41a085f001458a956d1); ?>
<?php endif; ?>
        <a href="<?php echo e(route('admin.product.type.create')); ?>" class="btn btn-outline--primary btn-sm flex-shrink-0">
            <i class="las la-plus"></i> <?php echo app('translator')->get('Add New'); ?>
        </a>
    </div>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('script-lib'); ?>
    <script src="<?php echo e(asset('assets/global/js/jquery-ui.min.js')); ?>"></script>
<?php $__env->stopPush(); ?>

<?php $__env->startPush('script'); ?>
    <script>
        (function($) {
            "use strict";

            const modal = $('#specificationModal');
            const specificationsWrapper = $('#specificationsWrapper');
            const form = $('#speficationForm');
            const formAction = `<?php echo e(route('admin.product.type.store')); ?>`;
            const addGroupBtn = $('#addGroupBtn');

            const addButtonClickHandler = () => {
                form[0].action = formAction;
                modal.modal('show');
            }

            const editButtonClickHandler = function() {
                const data = $(this).data('resource');
                form[0].action = formAction + '/' + data.id;
                data.specifications.forEach((specification, i) => {
                    appendSpecificationField(specification);
                });
                modal.find('[name=name]').val(data.name);

                $("#specificationsWrapper").sortable();
                modal.modal('show');
            }

            const onModalHideHandler = () => {
                modal.find('input:not([name="_token"]').val('');
                specificationsWrapper.empty();
            }

            const addFieldBtnClickHandler = () => {
                appendSpecificationField('');
                $("#specificationsWrapper").sortable();
            }

            const appendSpecificationField = (value = '') => {
                const content = buildSpecificationElement(value);
                $(content).appendTo(specificationsWrapper).hide().slideDown('slow');
            }

            const buildSpecificationElement = (value = '') => {
                return `
                        <div class="form-group specification-group ui-state-default">
                            <div class="input-group">
                                <span class="input-group-text ui-icon ui-icon-arrowthick-2-n-s"><i class=" fa fa-arrows-alt"></i></span>
                                <input type="text" class="form-control" name="specifications[]" value="${value}" placeholder="<?php echo app('translator')->get('Attribute Name'); ?>" required>
                                <button type="button" class="input-group-text btn--danger border-0 remove-specification"><i class="la la-times"></i></button>
                            </div>
                        </div>`;

            }

            const removeSpecificationHandler = function() {
                const group = $(this).closest('.specification-group');
                group.slideUp('slow', function() {
                    group.remove();
                });
            }


            const addGroupBtnClickHandler = () => {
                form.append(`

                    `);
            }

            addGroupBtn.on('click', addGroupBtnClickHandler)
            specificationsWrapper.on('click', '.remove-specification', removeSpecificationHandler);
            $('.addBtn').on('click', addButtonClickHandler);
            $('.editBtn').on('click', editButtonClickHandler);
            modal.on('hidden.bs.modal', onModalHideHandler);
            $('#addFieldBtn').on('click', addFieldBtnClickHandler);

        })(jQuery);
    </script>
<?php $__env->stopPush(); ?>

<?php echo $__env->make('admin.layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/creativedesignbd/ecommerce7.creativedesign.com.bd/core/resources/views/admin/product_type/index.blade.php ENDPATH**/ ?>