<!DOCTYPE html>
<html lang="ko"
	xmlns:th="http://www.thymeleaf.org">
<!--
 *******************************************************************************
 * @source  : FaqForm.html
 * @desc    : FAQ Page
 *============================================================================
 * STYLE24
 * Copyright(C) 2020 TSIT, All rights reserved.
 *============================================================================
 * VER  DATE         AUTHOR      DESCRIPTION
 * ===  ===========  ==========  =============================================
 * 1.0  2020.11.03   gagamel     최초 작성
 *******************************************************************************
 -->
	<div id="main">
		<!-- 메인타이틀 영역 -->
		<div class="main-title">
		</div>
		<!-- //메인타이틀 영역 -->
		
		<!-- 메뉴 설명 -->
		<div class="infoBox menu-desc">
		</div>
		<!-- //메뉴 설명 -->
		
		<!-- 검색조건 영역 -->
		<div class="panelStyle">
			<form id="searchForm" name="searchForm" action="#" th:action="@{'/board/faq/list'}" onsubmit="$('#btnSearch').trigger('click'); return false;">
				<table class="frmStyle" aria-describedby="검색조건">
					<colgroup>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col style="width:15%;"/>
						<col style="width:10%;"/>
						<col/>
					</colgroup>
					<tr>
						<th>사이트</th>
						<td>
							<select name="siteCd">
								<option th:if="${siteList}" th:each="oneData, status : ${siteList}" th:value="${oneData.cd}" th:text="|[${oneData.cd}] ${oneData.cdNm}|"></option>
							</select>
						</td>
						<th>FAQ유형</th>
						<td>
							<select name="faqType">
								<option value="">[선택]</option>
								<option th:if="${faqTypeList}" th:each="oneData, status : ${faqTypeList}" th:value="${oneData.cd}" th:text="${'[' + oneData.cd + '] ' + oneData.cdNm}"></option>
							</select>
						</td>
						<th>검색어</th>
						<td>
							<input type="text" name="searchTxt" placeholder="질문 or 내용" maxlength="50"/>
						</td>
						<th>사용여부</th>
						<td>
							<select name="useYn">
								<option value="">[전체]</option>
								<option value="Y">[Y] Yes</option>
								<option value="N">[N] No</option>
							</select>
						</td>
					</tr>
				</table>
				
				<ul class="panelBar">
					<li class="center">
						<button type="button" class="btn btn-base btn-lg" id="btnSearch">조회</button>
						<button type="button" class="btn btn-gray btn-lg" onclick="$('#searchForm')[0].reset();">초기화</button>
					</li>
				</ul>
			</form>
		</div>
		<!-- //검색조건 영역 -->
		
		<!-- 리스트 영역 -->
		<div class="panelStyle">
			<!-- 버튼 배치 영역 -->
			<ul class="panelBar">
				<li class="right">
					<button type="button" class="btn btn-info btn-lg" onclick="fnOpenFaqPopup('N');">등록</button>
				</li>
			</ul>
			<!-- //버튼 배치 영역 -->
			
			<div id="gridList" style="width: 100%; height: 570px" class="ag-theme-balham"></div>
		</div>
		<!-- //리스트 영역 -->
	</div>

<script th:inline="javascript">
/*<![CDATA[*/
	let siteList = gagajf.convertToArray([[${siteList}]]);
	let faqTypeList = gagajf.convertToArray([[${faqTypeList}]]);
	
	// specify the columns
	let columnDefs = [
		{
			headerName: "No", width: 60, cellClass: 'text-center',
			valueGetter: function(params) { return params.node.rowIndex + 1 }
		},
		{
			headerName: "사이트", field: "siteCd", width: 150, cellClass: 'text-center',
			valueGetter: function (params) { return gagaAgGrid.lookupValue(siteList, params.data.siteCd); }
		},
		{
			headerName: "FAQ유형", field: "faqType", width: 150, cellClass: 'text-center',
			valueGetter: function (params) { return gagaAgGrid.lookupValue(faqTypeList, params.data.faqType); }
		},
		{
			headerName: "질문", field: "question", width: 400,
			cellRenderer: function(params) { return '<a href="javascript:void(0);">' + params.value + '</a>'; }
		},
		{
			headerName: "조회수", field: "readCnt", width: 100, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
		},
		{headerName: "사용여부", field: "useYn", width: 80, cellClass: 'text-center'},
		{
			headerName: "표시순서", field: "dispOrd", width: 100, cellClass: 'text-center',
			cellRenderer: function (params) { return gagaAgGrid.toAddComma(params.value); }
		},
		{headerName: "등록자", field: "regNm" , width: 100, cellClass: 'text-center'},
		{
			headerName: "등록일시", field: "regDt", width: 150, cellClass: 'text-center',
			cellRenderer: function(params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		},
		{headerName: "수정자", field: "updNm", width: 100, cellClass: 'text-center'},
		{
			headerName: "수정일시", field: "updDt", width: 150, cellClass: 'text-center',
			cellRenderer: function(params) { return gagaAgGrid.toDateTimeFormat(params.value); }
		}
	];
	
	// Get GridOptions
	let gridOptions = gagaAgGrid.getGridOptions(columnDefs);
	
	// 셀 클릭 이벤트
	gridOptions.onCellClicked = function(event) {
		if (event.colDef.field != 'question')
			return;
		
		fnOpenFaqPopup('U', event.data.faqSq);
	}
	
	// 조회
	$('#btnSearch').on('click', function() {
		// Fetch data
		gagaAgGrid.fetch($('#searchForm').prop('action'), gridOptions, '#searchForm');
	});
	
	// 등록/상세 팝업
	var fnOpenFaqPopup = function(mode, faqSq) {
		var actionUrl = '/board/faq/detail/form' + '?mode=' + mode;
		if (!gagajf.isNull(faqSq)) actionUrl += '&faqSq=' + faqSq;
		cfnOpenModalPopup(actionUrl, 'popupFaq');
	}
	
	$(document).ready(function() {
		// Create a agGrid
		gagaAgGrid.createGrid('gridList', gridOptions);
	});
/*]]>*/
</script>

</html>
