@extends('layout.index', [
	'title' => __('Core.mail_templates.title'),
	'subtitle' => __('Core.mail_templates.list'),
	'breadcrumb' => []
])

@section('content')
    <x-card>
        @include('components.datatable', [
            'route' => route('Admin.Core.Mail.MailTemplate.index'),
            'model' => 'mail_templates',
            'with_add' => true,
            'with_print' => false,
            'with_filters' => true,
            'create_callback' => 'MailTemplateCreate();',
            'edit_callback' => 'MailTemplateEdit(id);',
            'show_callback' => 'MailTemplateView(id)',
        ])
    </x-card>

    @component('components.layout.modal-filters', ['title' => 'Filters', 'id' => 'modal-mail_templates-filters'])
        @include('Admin.Core.Mail.MailTemplate.partials.filters', ['model' => 'mail_templates'])
    @endcomponent
@endsection

@include('load.form.datepicker')
@include('load.form.select2')
@include('load.form.editor')
@include('load.form.toggle')
@include('load.form.upload.fileinput')
@include('load.layout.modal')

@push('js')
	<script>

        function MailTemplateCreate() {
			var url_open = "{{ route('Admin.Core.Mail.MailTemplate.modalCreate') }}";
			var url_save = "{{ route('Admin.Core.Mail.MailTemplate.storeAjax') }}";
			openModal("{{ __('Core.mail_templates.add') }}", '#mail_template-form', url_open, url_save, "MailTemplateRefresh();", "xl");
		}

		function MailTemplateEdit(id) {
			var url_open = "{{ route('Admin.Core.Mail.MailTemplate.modalEdit') }}/" + id;
			var url_save = "{{ route('Admin.Core.Mail.MailTemplate.storeAjax') }}";
			openModal("{{ __('Core.mail_templates.edit') }}", '#mail_template-form', url_open, url_save, "MailTemplateRefresh();", "xl");
		}

        function MailTemplateView(id) {
			var url_open = "{{ route('Admin.Core.Mail.MailTemplate.modalPreview') }}/" + id;
			openModal("{{ __('Core.preview') }}", '#preview_template-form', url_open);
        }

		function MailTemplateRefresh()
		{
			reloadDatatable("mail_templates");
		}

		$(document).ready(function () {
			initSelect2();
		});
	</script>
@endpush
