@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>게시판 그룹 관리 - @if($boardGroupID) 수정 @else 등록 @endif</h2>
    <hr/>
    @include('admin.messages')
    @if($boardGroupID)
        @include('admin.board.group.navTabs')
    @endif

    <form name="f_admin_write" id="fAdminWrite" method="post" action="{{ $actionURL }}" enctype="multipart/form-data">
        @csrf
        @if($boardGroupID)
            <input type="hidden" name="board_group_id" value="{{ $boardGroupID }}" />
            @method('PUT')
        @endif
        <div class="row mb-3">
            <label for="code" class="col-sm-2 col-form-label">주소</label>
            <div class="col-sm-10">
                <div class="row">
                    <div class="col-auto align-self-center">
                        {{ url('group') }} /
                    </div>
                    <div class="col ps-0">
                        <input type="text" name="code" id="code" class="form-control" value="{{ $boardGroupData->code ?? old('code') }}" />
                    </div>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="name" class="col-sm-2 col-form-label">제목</label>
            <div class="col-sm-10">
                <input type="text" name="name" id="name" class="form-control" value="{{ $boardGroupData->name ?? old('name') }}" />
            </div>
        </div>
        <div class="row mb-3">
            <label for="sort" class="col-sm-2 col-form-label">순서</label>
            <div class="col-sm-10">
                <div class="form-inline">
                    <input type="number" name="sort" id="sort" class="form-control only-digits-input" value="{{ $boardGroupData->sort ?? old('sort') }}" />
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="pcHeaderContent" class="col-sm-2 col-form-label">PC 상단 내용</label>
            <div class="col-sm-10">
                <?php echo htmlEditor('pc_header_content', ($boardGroupMetaData->pc_header_content ?? old('pc_header_content')), 'form-control dhtml-editor', true, false, '', 8, 'pcHeaderContent'); ?>
            </div>
        </div>
        <div class="row mb-3">
            <label for="pcFooterContent" class="col-sm-2 col-form-label">PC 하단 내용</label>
            <div class="col-sm-10">
                <?php echo htmlEditor('pc_footer_content', ($boardGroupMetaData->pc_footer_content ?? old('pc_footer_content')), 'form-control dhtml-editor', true, false, '', 8, 'pcFooterContent'); ?>
            </div>
        </div>
        <div class="row mb-3">
            <label for="mobileHeaderContent" class="col-sm-2 col-form-label">모바일 상단 내용</label>
            <div class="col-sm-10">
                <?php echo htmlEditor('mobile_header_content', ($boardGroupMetaData->mobile_header_content ?? old('mobile_header_content')), 'form-control dhtml-editor', true, false, '', 8, 'mobileHeaderContent'); ?>
            </div>
        </div>
        <div class="row mb-3">
            <label for="mobileFooterContent" class="col-sm-2 col-form-label">모바일 하단 내용</label>
            <div class="col-sm-10">
                <?php echo htmlEditor('mobile_footer_content', ($boardGroupMetaData->mobile_footer_content ?? old('mobile_footer_content')), 'form-control dhtml-editor', true, false, '', 8, 'mobileFooterContent'); ?>
            </div>
        </div>
        <hr/>
        <div class="text-end">
            <button type="submit" class="btn btn-success">저장하기</button>
            <button type="button" class="btn btn-light btn-write-cancel" value="{{ route('admin.board.group.list.index') }}">취소하기</button>
        </div>
    </form>
</div>

<script type="module">
$("#fAdminWrite").validate({
    rules: {
        code: {required: true, minlength: 3, maxlength: 50, alpha_dash: true},
        name: {required: true, maxlength: 255},
        sort: {required: true, number: true},
        pc_header_content: {'required_tinymce': false},
        pc_footer_content: {'required_tinymce': false},
        mobile_header_content: {'required_tinymce': false},
        mobile_footer_content: {'required_tinymce': false}
    }
});
</script>
@endsection
