@extends('admin.layouts.app')

@section('content')
<div class="container-fluid">
    <h2>게시판 관리 - 목록</h2>
    <hr/>
    @include('admin.messages')
    @if($boardID)
        @include('admin.board.board.navTabs')
    @endif

    <form name="f_admin_write" id="fAdminWrite" method="post" action="{{ $actionURL }}" enctype="multipart/form-data">
        @csrf
        <input type="hidden" name="board_id" value="{{ $boardID }}" />
        <div class="row mb-3">
            <label for="boardLayoutType_0" class="col-sm-2">게시판 종류</label>
            <div class="col-sm-8">
                <div class="form-check form-check-inline">
                    <input type="radio" name="board_layout_type" id="boardLayoutType_0" class="form-check-input" value="0" @if(($boardMetaData->board_layout_type ?? old('board_layout_type', '0')) == '0') checked @endif/>
                    <label for="boardLayoutType_0" class="form-check-label">일반</label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="radio" name="board_layout_type" id="boardLayoutType_1" class="form-check-input" value="1" @if(($boardMetaData->board_layout_type ?? old('board_layout_type')) == '1') checked @endif />
                    <label for="boardLayoutType_1" class="form-check-label">사진/동영상</label>
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[board_layout_type]" id="grpBoardLayoutType" class="form-check-input" value="1" />
                    <label for="grpBoardLayoutType" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[board_layout_type]" id="allBoardLayoutType" class="form-check-input" value="1" />
                    <label for="allBoardLayoutType" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="listSortType" class="col-sm-2 col-form-label">기본 정렬 순</label>
            <div class="col-sm-8">
                <select name="list_sort_type" id="listSortType" class="form-select w-auto">
                    <option value="1" @if(($boardMetaData->list_sort_type ?? old('list_sort_type')) == '1') selected @endif>날짜순</option>
                    <option value="2" @if(($boardMetaData->list_sort_type ?? old('list_sort_type')) == '2') selected @endif>조회순</option>
                    <option value="3" @if(($boardMetaData->list_sort_type ?? old('list_sort_type')) == '3') selected @endif>댓글순</option>
                    <option value="4" @if(($boardMetaData->list_sort_type ?? old('list_sort_type')) == '4') selected @endif>추천순</option>
                </select>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[list_sort_type]" id="grpListSortType" class="form-check-input" value="1" />
                    <label for="grpListSortType" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[list_sort_type]" id="allListSortType" class="form-check-input" value="1" />
                    <label for="allListSortType" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="listPerPage" class="col-sm-2 col-form-label">목록 수</label>
            <div class="col-sm-8">
                <div class="row g-2">
                    <div class="col col-sm-2">
                        <label for="listPerPage" class="form-label">PC</label>
                        <input type="number" name="list_per_page" id="listPerPage" class="form-control" value="{{ $boardMetaData->list_per_page ?? old('list_per_page') }}" />
                    </div>
                    <div class="col col-sm-2">
                        <label for="listMobilePerPage" class="form-label">모바일</label>
                        <input type="number" name="list_mobile_per_page" id="listMobilePerPage" class="form-control" value="{{ $boardMetaData->list_mobile_per_page ?? old('list_mobile_per_page') }}" />
                    </div>
                </div>
                <div class="form-text text-muted">
                    한 페이지에 보이는 게시물 수입니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[list_per_page]" id="grpListPerPage" class="form-check-input" value="1" />
                    <label for="grpListPerPage" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[list_per_page]" id="allListPerPage" class="form-check-input" value="1" />
                    <label for="allListPerPage" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="listPageCount" class="col-sm-2 col-form-label">페이지 수</label>
            <div class="col-sm-8">
                <div class="row g-2">
                    <div class="col col-sm-2">
                        <label for="listPageCount" class="form-label">PC</label>
                        <input type="number" name="list_page_count" id="listPageCount" class="form-control" value="{{ $boardMetaData->list_page_count ?? old('list_page_count') }}" />
                    </div>
                    <div class="col col-sm-2">
                        <label for="listPageMobileCount" class="form-label">모바일 </label>
                        <input type="number" name="list_page_mobile_count" id="listPageMobileCount" class="form-control" value="{{ $boardMetaData->list_page_mobile_count ?? old('list_page_mobile_count') }}" />
                    </div>
                </div>
                <div class="form-text text-muted">
                   목록 하단, 페이지를 이동하는 페이지 번호 수를 지정할 수 있습니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[list_page_count]" id="grpListPageCount" class="form-check-input" value="1" />
                    <label for="grpListPageCount" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[list_page_count]" id="allListPageCount" class="form-check-input" value="1" />
                    <label for="allListPageCount" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="alwaysShowWriteButton_1" class="col-sm-2">글쓰기 버튼 보이기</label>
            <div class="col-sm-8">
                <div class="form-check form-check-inline">
                    <input type="radio" name="always_show_write_button" id="alwaysShowWriteButton_1" class="form-check-input" value="1" @if($boardMetaData->always_show_write_button ?? old('always_show_write_button')) checked @endif/>
                    <label for="alwaysShowWriteButton_1" class="form-check-label">예</label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="radio" name="always_show_write_button" id="alwaysShowWriteButton_0" class="form-check-input" value="0" @if(!($boardMetaData->always_show_write_button ?? old('always_show_write_button'))) checked @endif/>
                    <label for="alwaysShowWriteButton_0" class="form-check-label">아니오</label>
                </div>
                <div class="form-text text-muted">
                    권한이 없는 사용자라도 글쓰기 버튼은 항상 보입니다
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[always_show_write_button]" id="grpAlwaysShowWriteButton" class="form-check-input" value="1" />
                    <label for="grpAlwaysShowWriteButton" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[always_show_write_button]" id="allAlwaysShowWriteButton" class="form-check-input" value="1" />
                    <label for="allAlwaysShowWriteButton" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="showListFromView_1" class="col-sm-2">하단 목록 보이기</label>
            <div class="col-sm-8">
                <div class="form-check form-check-inline">
                    <input type="radio" name="show_list_from_view" id="showListFromView_1" class="form-check-input" value="1" @if($boardMetaData->show_list_from_view ?? old('show_list_from_view')) checked @endif/>
                    <label for="showListFromView_1" class="form-check-label">예</label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="radio" name="show_list_from_view" id="showListFromView_0" class="form-check-input" value="0" @if(!($boardMetaData->show_list_from_view ?? old('show_list_from_view'))) checked @endif/>
                    <label for="showListFromView_0" class="form-check-label">아니오</label>
                </div>
                <div class="form-text text-muted">
                    글읽기 화면 하단에도 목록을 표시합니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[show_list_from_view]" id="grpShowListFromView" class="form-check-input" value="1" />
                    <label for="grpShowListFromView" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[show_list_from_view]" id="allShowListFromView" class="form-check-input" value="1" />
                    <label for="allShowListFromView" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="newIconHour" class="col-sm-2 col-form-label">NEW 아이콘</label>
            <div class="col-sm-8">
                <input type="number" name="new_icon_hour" id="newIconHour" class="form-control d-inline w-auto" value="{{ $boardMetaData->new_icon_hour ?? old('new_icon_hour') }}" /> 시간 동안 NEW 아이콘이 보입니다.
                <div class="form-text text-muted">
                    0이면 24시간 기준으로 노출됩니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[new_icon_hour]" id="grpNewIconHour" class="form-check-input" value="1" />
                    <label for="grpNewIconHour" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[new_icon_hour]" id="allNewIconHour" class="form-check-input" value="1" />
                    <label for="allNewIconHour" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="hotIconHit" class="col-sm-2 col-form-label">HOT 아이콘</label>
            <div class="col-sm-8">
                <input type="number" name="hot_icon_hit" id="hotIconHit" class="form-control d-inline w-auto" value="{{ $boardMetaData->hot_icon_hit ?? old('hot_icon_hit') }}" /> 조회 수 이상이면 HOT 아이콘이 보입니다.
                <div class="form-text text-muted">
                    0 이면 노출되지 않습니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[hot_icon_hit]" id="grpHotIconHit" class="form-check-input" value="1" />
                    <label for="grpHotIconHit" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[hot_icon_hit]" id="allHotIconHit" class="form-check-input" value="1" />
                    <label for="allHotIconHit" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="hotIconDay" class="col-sm-2 col-form-label"></label>
            <div class="col-sm-8">
                <input type="number" name="hot_icon_day" id="hotIconDay" class="form-control d-inline w-auto" value="{{ $boardMetaData->hot_icon_day ?? old('hot_icon_day') }}" /> 일 이내의 게시물에만 HOT 아이콘이 보입니다.
                <div class="form-text text-muted">
                    0 이면 기간에 상관없이 조회수 기준만으로 HOT 아이콘이 보입니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[hot_icon_day]" id="grpHotIconDay" class="form-check-input" value="1" />
                    <label for="grpHotIconDay" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[hot_icon_day]" id="allHotIconDay" class="form-check-input" value="1" />
                    <label for="allHotIconDay" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="subjectLength" class="col-sm-2 col-form-label">제목 길이</label>
            <div class="col-sm-8">
                <div class="row">
                    <div class="col col-sm-2">
                        <label for="subjectLength" class="form-label">PC</label>
                        <input type="text" name="subject_length" id="subjectLength" class="form-control only-digits-input" value="{{ $boardMetaData->subject_length ?? old('subject_length') }}" />
                    </div>
                    <div class="col col-sm-2">
                        <label for="subjectMobileLength" class="form-label">모바일</label>
                        <input type="text" name="subject_mobile_length" id="subjectMobileLength" class="form-control col-sm-2" value="{{ $boardMetaData->subject_mobile_length ?? old('subject_mobile_length') }}" />
                    </div>
                    <div class="col align-self-center ps-0">
                        글자 이상은 목록에서만 잘려보입니다.
                    </div>
                </div>
                <div class="form-text text-muted">
                    0이면 제목이 모두 보입니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[subject_length]" id="grpSubjectLength" class="form-check-input" value="1" />
                    <label for="grpSubjectLength" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[subject_length]" id="allSubjectLength" class="form-check-input" value="1" />
                    <label for="allSubjectLength" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="exceptNotice_1" class="col-sm-2">공지사항 제외</label>
            <div class="col-sm-8">
                <div class="form-check form-check-inline">
                    <input type="radio" name="except_notice" id="exceptNotice_1" class="form-check-input" value="1" @if($boardMetaData->except_notice ?? old('except_notice')) checked @endif/>
                    <label for="exceptNotice_1" class="form-check-label">예</label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="radio" name="except_notice" id="exceptNotice_0" class="form-check-input" value="0" @if(!($boardMetaData->except_notice ?? old('except_notice'))) checked @endif/>
                    <label for="exceptNotice_0" class="form-check-label">아니오</label>
                </div>
                <div class="form-text text-muted">
                    목록 상단에 늘 나타나는 공지사항을 일반 목록에서 나타나지 않도록 합니다.
                    <br/>공지사항 게시판은 해당되지 않습니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[except_notice]" id="grpExceptNotice" class="form-check-input" value="1" />
                    <label for="grpExceptNotice" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[except_notice]" id="allExceptNotice" class="form-check-input" value="1" />
                    <label for="allExceptNotice" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </div>
        </div>
        <div class="row mb-3">
            <label for="exceptSpeaker_1" class="col-sm-2">전체공지 제외</label>
            <div class="col-sm-8">
                <div class="form-check form-check-inline">
                    <input type="radio" name="except_speaker" id="exceptSpeaker_1" class="form-check-input" value="1" @if($boardMetaData->except_speaker ?? old('except_speaker')) checked @endif/>
                    <label for="exceptSpeaker_1" class="form-check-label">예</label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="radio" name="except_speaker" id="exceptSpeaker_0" class="form-check-input" value="0" @if(!($boardMetaData->except_speaker ?? old('except_speaker'))) checked @endif/>
                    <label for="exceptSpeaker_0" class="form-check-label">아니오</label>
                </div>
                <div class="form-text text-muted">
                    설정하시면 다른 게시판에서 입력한 전체 공지가 이 게시판에서는 보이지 않습니다.
                    <br/>공지사항 게시판은 해당되지 않습니다.
                </div>
            </div>
            <div class="col-sm-2">
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="grp[except_speaker]" id="grpExceptSpeaker" class="form-check-input" value="1" />
                    <label for="grpExceptSpeaker" class="form-check-label">
                        그룹적용
                    </label>
                </div>
                <div class="form-check form-check-inline">
                    <input type="checkbox" name="all[except_speaker]" id="allExceptSpeaker" class="form-check-input" value="1" />
                    <label for="allExceptSpeaker" class="form-check-label">
                        전체적용
                    </label>
                </div>
            </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.board.list.index') }}">취소하기</button>
        </div>
    </form>
</div>

<script type="module">
$("#fAdminWrite").validate({
    rules: {
        board_layout_type: {required: true},
        list_sort_type: {required: true},
        list_per_page: {required: true, number: true, min: 0, max: 50},
        list_mobile_per_page: {required: true, number: true, min: 0, max: 50},
        list_page_count: {required: true, number: true, min: 0, max: 50},
        list_page_mobile_count: {required: true, number: true, min: 0, max: 50},
        always_show_write_button: {required: true},
        show_list_from_view: {required: true},
        new_icon_hour: {required: true, number: true, max: 24},
        hot_icon_hit: {required: true, number: true, max: 999999},
        hot_icon_day: {required: true, number: true, max: 365},
        subject_length: {required: true, number: true, max: 255},
        subject_mobile_length: {required: true, number: true, max: 255},
        except_notice: {required: true},
        except_speaker: {required: true}
    }
});
</script>
@endsection
