@extends($_layout.'main') {{-- khai báo title --}} @section('title', "Cấu hình Style $template->name") {{-- tên modul xuất hiện trong sub header --}} @section('module.name', $template->name) @section('content') @php $itemExists = []; $urlOptions['new'] = 'Thêm mới'; @endphp
@include('admin.forms.templates.crazyselect', [ 'input' => html_input([ 'type' => 'crazyselect', 'name' => 'templateurl', 'data' => $urlOptions, '@change' => 'StyleSetTemplate.changeTemplate', 'default' => str_replace('http://', 'https://', URL::current()) ]) ])
@php $data = $template->toFormData(); $data['avatar_url'] = $template->getAvatar(); $preview = crazy_arr($data); $width = old('width',$preview->width(340)); $height = old('height',$preview->height(500)); $bg = $preview->avatar_url(asset('static/images/default.png')); @endphp
@if ($templateItemConfigs && count($templateItemConfigs)) @foreach ($templateItemConfigs as $item) @php $itemExists[] = $item->config_id; $arrItem = new \Gomee\Helpers\Arr($item->toArray()); $itemWidth = $arrItem->get('preview_config.width'); $itemHeight = $arrItem->get('preview_config.height'); $itemTop = $arrItem->get('preview_config.top'); $itemLeft = $arrItem->get('preview_config.left'); if($itemWidth == null || $itemWidth <= 0) $itemWidth = $width/2; if($itemHeight == null || $itemHeight <= 0) $itemHeight = $itemWidth; if($itemTop === null) $itemTop = ($height - $itemHeight)/2; if($itemLeft === null) $itemLeft = ($width - $itemWidth)/2; @endphp
{{$item->itemConfig->name}}
@endforeach @endif
@include($_base.'forms.form', [ 'inputs' => array_merge($templateInputs, [ 'id' => ['type' => 'hidden', 'id' => 'hidden-id'] ]), 'data' => $template->toFormData(), 'config' => [ 'save_button_text' => 'Lưu', 'cancel_button_text' => 'Hủy', 'form_group_options' => [ 'group_class' => 'row', 'label_class' => 'col-label col-12 col-sm-6 col-md-5 col-xl-4', 'wrapper_class' => 'col-12 col-sm-6 col-md-7 col-xl-8' ], ], 'attrs' => [ 'method' => 'post', 'action' => route('admin.style-sets.personal.templates.ajax-update'), 'id' => 'template-form', ] ])

Items

@if ($templateItemConfigs && count($templateItemConfigs)) @php $itemInp = $itemConfigInputs; $itemInp['template_id'] = [ 'type' => 'hidden', 'value' => $template->id, 'id' => 'hidden-template-' . $template->id ]; $itemInp['id'] = [ 'type' => 'hidden' ]; $itemInp['config_id'] = [ 'type' => 'hidden' ]; @endphp @foreach ($templateItemConfigs as $itemConfig)
@if ($itemConfig->templateItems && count($itemConfig->templateItems)) @php $inputList = []; $inputList['id'] = [ 'type' => 'hidden', 'namespace' => 'hidden_id' ]; foreach ($itemInputs as $name => $inpCfg) { $a = $inpCfg; $a['id'] = 'style-template-item-input-' . $name . '-' . $itemConfig->id; $inputList[$name] = $a; } @endphp @foreach ($itemConfig->templateItems as $templateItem)
@php $tiData = $templateItem->toFormData(); $inputList['id']['value'] = $templateItem->id; $inputList['tags']['data'] = get_input_tag_data('PS-TEMP-ITEM', $templateItem->id, ['id' => $tiData['tags']]); @endphp @include($_base.'forms.form', [ 'inputs' => $inputList, 'data' => $tiData, 'config' => [ 'button_block_type' => 2, 'save_button_text' => 'Cập nhật', 'cancel_button_text' => "Xóa", 'cancel_button_class' => "danger btn-delete-template-item", 'form_group_options' => [ 'group_class' => '', 'label_class' => '', 'wrapper_class' => '' ], ], 'attrs' => [ 'method' => 'post', 'action' => route('admin.style-sets.personal.templates.update-item'), 'id' => 'template-item-update-form-' .$itemConfig->id . '-'. $templateItem->id, 'class' => 'template-item-update-form', 'data-item-id' => $templateItem->id, 'data-config-id' => $itemConfig->id, ] ])
@endforeach @endif
@include($_base.'forms.form', [ 'inputs' => array_merge($itemInputs, [ // 'id' => ['type' => 'hidden', 'id' => 'hidden-id'] ]), 'data' => ['template_item_config_id' => $itemConfig->id], 'config' => [ 'save_button_text' => 'Thêm Mới', 'hide_cancel_button' => true, 'form_group_options' => [ 'group_class' => '', 'label_class' => '', 'wrapper_class' => '' ], ], 'attrs' => [ 'method' => 'post', 'action' => route('admin.style-sets.personal.templates.create-item'), 'id' => 'template-item-create-form-' .$itemConfig->id, 'class' => 'template-item-create-form', 'data-config-id' => $itemConfig->id, ] ])
@php foreach ($itemConfigInputs as $name => $inp) { $itemInp[$name]['id'] = $name .'-item-config-'.$itemConfig->id; } @endphp @include($_base.'forms.form', [ 'inputs' => $itemInp, 'data' => $itemConfig->toFormData(), 'config' => [ 'button_block_type' => 1, 'save_button_text' => 'Cập nhật', 'hide_cancel_button' => true, // 'cancel_button_class' => 'danger btn-delete-item', // 'cancel_button_url' => route('admin.style-sets.personal.templates.delete-item'), 'form_group_options' => [ 'group_class' => '', 'label_class' => '', 'wrapper_class' => '' ], 'form_group_style' => 'custom', 'log_style' => true, ], 'attrs' => [ 'method' => 'post', 'class' => 'style-template-item-config-update-form', 'data-id' => $itemConfig->id, 'action' => route('admin.style-sets.personal.templates.update-item-config'), 'id' => 'style-template-item-config-update-form-' . $itemConfig->id, ] ])
@endforeach @endif
@if (count($itemExists) < count($styleItemConfigs))

Thêm cấu hình Item

@foreach ($styleItemConfigs as $styleItemConfig) @if (in_array($styleItemConfig->id, $itemExists)) @continue @endif @php $itemInp['config_id'] = [ 'type' => 'hidden', 'value' => $styleItemConfig->id ]; @endphp
@php $itemInp = $itemConfigInputs; $itemInp['config_id'] = [ 'type' => 'hidden', 'value' => $styleItemConfig->id, 'id' => 'hidden-config' . $styleItemConfig->id ]; $itemInp['template_id'] = [ 'type' => 'hidden', 'value' => $template->id, 'id' => 'hidden-template-' . $template->id ]; @endphp @include($_base.'forms.form', [ 'inputs' => $itemInp, 'data' => $styleItemConfig->toArray(), 'config' => [ 'button_block_type' => 1, 'save_button_text' => 'Thêm', 'hide_cancel_button' => true, // 'cancel_button_class' => 'danger btn-delete-item', // 'cancel_button_url' => route('admin.style-sets.personal.templates.delete-item'), 'form_group_options' => [ 'group_class' => '', 'label_class' => '', 'wrapper_class' => '' ], 'form_group_style' => 'custom', 'log_style' => true, ], 'attrs' => [ 'method' => 'post', 'class' => 'style-template-item-config-create-form', 'data-id' => $styleItemConfig->id, 'action' => route('admin.style-sets.personal.templates.create-item-config'), 'id' => 'style-template-item-config-create-form-' . $styleItemConfig->id, ] ])
@endforeach
@endif
@include('admin._templates.style-set-template-form-modal') @endsection