Files
confirms/app/Views/layouts/partials/datatables_v2_layout_helpers.php

67 lines
2.5 KiB
PHP

<script type="text/javascript">
/**
* DataTables v2 layout topEnd 버튼 헬퍼
* @param {Object} options - 옵션 객체
* @param {boolean} options.showSendButton - 등기부등본 전송 버튼 표시 여부 (기본값: false)
* @param {string} options.sendButtonText - 전송 버튼 텍스트
* @param {boolean} options.showExcelButton - 엑셀 버튼 표시 여부 (기본값: true)
* @param {string} options.excelButtonId - 엑셀 버튼 id
* @param {string} options.excelButtonClass - 엑셀 버튼 class
* @param {string} options.excelButtonHtml - 엑셀 버튼 innerHTML
* @returns {Function} DataTable layout.topEnd 콜백 함수
*/
function v2TopEndButtons(options) {
const opts = options || {};
return function () {
const container = document.createElement('div');
container.className = 'd-flex';
container.style.gap = '8px';
container.style.justifyContent = 'flex-end';
if (opts.showSendButton === true) {
const btnSend = document.createElement('button');
btnSend.className = 'btn btn-sm btn-outline-light';
btnSend.textContent = opts.sendButtonText || '등기부등본 전송';
container.append(btnSend);
}
if (opts.showExcelButton !== false) {
const btnExcel = document.createElement('button');
btnExcel.id = opts.excelButtonId || 'excel-download';
btnExcel.className = opts.excelButtonClass || 'btn btn-sm btn-outline-success';
btnExcel.innerHTML = opts.excelButtonHtml || '<i class="fa fa-fw fa-file-excel-o" aria-hidden="true"></i> 엑셀다운로드';
container.append(btnExcel);
}
return container;
};
}
/**
* DataTables v2 layout bottomStart/bottomEnd 통합 설정
* @param {Object} options - 옵션 객체
* @param {boolean} options.hasPageLength - pageLength 표시 여부 (기본값: true)
* @param {boolean} options.hasInfo - info 표시 여부 (기본값: true)
* @returns {Object} { bottomStart, bottomEnd } 객체
*/
function v2BottomLayout(options) {
const opts = options || {};
const hasPageLength = opts.hasPageLength !== false;
const hasInfo = opts.hasInfo !== false;
const config = {};
if (hasPageLength && hasInfo) {
config.bottomStart = ['pageLength', 'info'];
} else if (hasPageLength) {
config.bottomStart = 'pageLength';
} else if (hasInfo) {
config.bottomStart = 'info';
}
config.bottomEnd = 'paging';
return config;
}
</script>