{!! Form::open([ 'url' => route('admin_settings_emails_update'), 'method' => 'post', 'class' => 'modal-content' ]) !!}
{{ Form::hidden('action', 'email_template') }}
{{ Form::hidden('step', false) }}
{{ Form::hidden('id', $value->id) }}
<div class="modal-header">
    <h5 class="modal-title">E-Mail Vorlagen <span class="font-weight-light">anlegen/bearbeiten</span></h5>
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>
</div>
<div class="modal-body">


    <div class="form-row">
        <label class="form-label" for="filter_service_provider_id">Verzeichniss</label>
        <select class="custom-select" name="email_template_dir_id" id="email_template_dir_id">
            <option value="">Kein Verzeichniss</option>
            @foreach($directories as $directory)
                <option value="{{$directory->id}}" @if($value->email_template_dir_id === $directory->id) selected @endif>{{$directory->name}}</option>
            @endforeach
        </select>

    </div>
    <hr>
    <div class="form-row">
        <div class="form-group col">
            <label for="name" class="form-label">Vorlage Bezeichnung*</label>
            {{ Form::text('name', $value->name,  array('class'=>'form-control', 'required'=>true)) }}
        </div>
    </div>

    <div class="form-row">
        <div class="form-group col">
            <label for="subject" class="form-label">Betreff</label>
            {{ Form::text('subject', $value->subject,  array('class'=>'form-control')) }}
        </div>
    </div>
    <div class="form-row">
        <div class="form-group col">
            <label class="form-label" for="message">Nachricht</label>
            <div id="message-editor-toolbar">
                <span class="ql-formats">
                              <button class="ql-bold"></button>
                              <button class="ql-italic"></button>
                              <button class="ql-underline"></button>
                              <button class="ql-strike"></button>
                            </span>
                <span class="ql-formats">
                              <button class="ql-header" value="1"></button>
                              <button class="ql-header" value="2"></button>
                              <button class="ql-blockquote"></button>
                              <button class="ql-code-block"></button>
                            </span>
                <span class="ql-formats">
                              <button class="ql-list" value="ordered"></button>
                              <button class="ql-list" value="bullet"></button>
                              <button class="ql-indent" value="-1"></button>
                              <button class="ql-indent" value="+1"></button>
                            </span>
                <span class="ql-formats">
                              <select class="ql-align"></select>
                            </span>
                <span class="ql-formats">
                              <button class="ql-clean"></button>
                            </span>
                <span class="ql-formats">
                    <select class="ql-placeholder">
                        {!! \App\Services\Placeholder::getBookingOptions() !!}
                    </select>
                </span>
            </div>
            <div id="message-editor" style="height: 400px">{!! $value->message !!}</div>
            {{ Form::textarea('message', $value->message,  array('placeholder'=>'', 'id'=>'message-editor-fallback', 'class'=>'form-control d-none', 'rows'=>15)) }}
        </div>
    </div>
    <div class="form-group">
        <label class="custom-control custom-checkbox m-0">
            {{ Form::checkbox('active', 1, $value->active, array('class'=>'custom-control-input')) }}
            <span class="custom-control-label">{{__('sichtbar')}}</span>
        </label>
    </div>
</div>
<div class="modal-footer">
    <button type="button" class="btn btn-default" data-dismiss="modal">{{__('close')}}</button>
    <button type="submit" class="btn btn-primary submit-button-form">{{__('save')}}</button>
</div>
{!! Form::close() !!}



<script>
    $( document ).ready(function() {
        if (!window.Quill) {
            $('#message-editor,#message-editor-toolbar').remove();
            $('#message-editor-fallback').removeClass('d-none');
        } else {
            Quill.register('modules/placeholder', PlaceholderModule.default(Quill))
            //$('#message-editor-fallback').remove();
            var quill = new Quill('#message-editor', {
                modules: {
                    toolbar: '#message-editor-toolbar',
                    placeholder: {
                        placeholders: [
                            {!! \App\Services\Placeholder::getBookingQuill() !!}
                        ]
                    }
                },
                placeholder: '',
                theme: 'snow'
            });
            //quill.clipboard.dangerouslyPasteHTML('<span class="ql-placeholder-content" data-id="foo" data-label="foo"></span>')
        }

        $(".submit-button-form").click(function(event) {
            $("#message-editor-fallback").val($('#message-editor .ql-editor').html());
            $( "#customer-mail-form" ).submit();
        });
    });
</script>
