cfmgrv4 init...1
This commit is contained in:
parent
a17b53d010
commit
39b87db614
@ -10,7 +10,8 @@
|
|||||||
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
|
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
|
||||||
<div class="index_body">
|
<div class="index_body">
|
||||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
|
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
|
||||||
<table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
|
<table class="index_table data table table-bordered table-hover table-striped"
|
||||||
|
data-rtc-resizable-table="reisze_table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="index_head_short_column">번호</th>
|
<th class="index_head_short_column">번호</th>
|
||||||
@ -43,7 +44,7 @@
|
|||||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
|
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
|
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||||
<div class="index_bottom"><?= $this->include("templates/common/modal_iframe"); ?></div>
|
<div class="index_bottom"><?= $this->include("templates/common/modal_fetch"); ?></div>
|
||||||
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
|
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
|
||||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
|
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -10,7 +10,8 @@
|
|||||||
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
|
<link href="/css/common/resizeTable.css" media="screen" rel="stylesheet" type="text/css" />
|
||||||
<div class="index_body">
|
<div class="index_body">
|
||||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
|
<?= $this->include("templates/{$viewDatas['layout']}/index_content_top"); ?>
|
||||||
<table class="index_table data table table-bordered table-hover table-striped" data-rtc-resizable-table="reisze_table">
|
<table class="index_table data table table-bordered table-hover table-striped"
|
||||||
|
data-rtc-resizable-table="reisze_table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="index_head_short_column">번호</th>
|
<th class="index_head_short_column">번호</th>
|
||||||
@ -43,7 +44,7 @@
|
|||||||
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
|
<?= $this->include("templates/{$viewDatas['layout']}/index_content_batchjob"); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
|
<div class=" index_pagination"><?= $viewDatas['pagination'] ?></div>
|
||||||
<div class="index_bottom"><?= $this->include("templates/common/modal_iframe"); ?></div>
|
<div class="index_bottom"><?= $this->include("templates/common/modal_fetch"); ?></div>
|
||||||
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
|
<script type="text/javascript" src="/js/common/resizeTable.js"></script>
|
||||||
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
|
<script type="text/javascript" src="/js/<?= $viewDatas['layout'] ?>/index.js"></script>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
105
app/Views/templates/common/modal_fetch.php
Normal file
105
app/Views/templates/common/modal_fetch.php
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
<!-- 처음 호출할때 사용법
|
||||||
|
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="시작URL">시작</button>
|
||||||
|
-->
|
||||||
|
<!-- 동적으로 ifram src 바꾸고싶을때
|
||||||
|
<span data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="바꾸고싶은URL" style="cursor:pointer;">바꾸기</span>
|
||||||
|
-->
|
||||||
|
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="modal_label"
|
||||||
|
aria-hidden="true">
|
||||||
|
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title" id="modal_label">
|
||||||
|
<h4> <?= ICONS['DESKTOP'] ?> <?= $viewDatas['title'] ?> </h4>
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body" id="modal-body-content">
|
||||||
|
<!-- 여기에 동적으로 콘텐츠가 로드됩니다 -->
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">닫기</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const modal = document.getElementById('index_action_form');
|
||||||
|
const modalBody = document.getElementById('modal-body-content');
|
||||||
|
|
||||||
|
async function loadContent(url) {
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP 오류! 상태: ${response.status}`);
|
||||||
|
}
|
||||||
|
const content = await response.text();
|
||||||
|
modalBody.innerHTML = content;
|
||||||
|
setupFormSubmission();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('콘텐츠 로드 중 오류 발생:', error);
|
||||||
|
modalBody.innerHTML = '<p>콘텐츠를 로드하는 중 오류가 발생했습니다. 다시 시도해 주세요.</p>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupFormSubmission() {
|
||||||
|
const form = modalBody.querySelector('form');
|
||||||
|
if (form) {
|
||||||
|
form.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
const formData = new FormData(form);
|
||||||
|
try {
|
||||||
|
const response = await fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
const contentType = response.headers.get("content-type");
|
||||||
|
if (contentType && contentType.indexOf("application/json") !== -1) {
|
||||||
|
const result = await response.json();
|
||||||
|
if (result.success) {
|
||||||
|
modalBody.innerHTML = '<p>데이터가 성공적으로 저장되었습니다.</p>';
|
||||||
|
setTimeout(() => {
|
||||||
|
bootstrap.Modal.getInstance(modal).hide();
|
||||||
|
window.location.reload();
|
||||||
|
}, 2000);
|
||||||
|
} else {
|
||||||
|
modalBody.innerHTML = result.html;
|
||||||
|
setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// HTML 응답 처리
|
||||||
|
const htmlContent = await response.text();
|
||||||
|
modalBody.innerHTML = htmlContent;
|
||||||
|
|
||||||
|
// HTML에 포함된 스크립트 실행
|
||||||
|
const scripts = modalBody.getElementsByTagName('script');
|
||||||
|
for (let script of scripts) {
|
||||||
|
eval(script.innerHTML);
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFormSubmission(); // 새로운 폼에 대해 다시 이벤트 리스너 설정
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('폼 제출 중 오류 발생:', error);
|
||||||
|
modalBody.innerHTML = '<p>데이터 저장 중 오류가 발생했습니다. 다시 시도해 주세요.</p>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
modal.addEventListener('show.bs.modal', (event) => {
|
||||||
|
const button = event.relatedTarget;
|
||||||
|
const url = button.getAttribute('data-src');
|
||||||
|
if (url) {
|
||||||
|
loadContent(url);
|
||||||
|
} else {
|
||||||
|
console.error('data-src 속성이 없습니다.');
|
||||||
|
modalBody.innerHTML = '<p>URL을 찾을 수 없습니다. 다시 시도해 주세요.</p>';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
modal.addEventListener('hidden.bs.modal', () => {
|
||||||
|
modalBody.innerHTML = '';
|
||||||
|
});
|
||||||
|
</script>
|
||||||
@ -1,46 +0,0 @@
|
|||||||
<!--
|
|
||||||
처음 호출할때 사용법
|
|
||||||
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="시작URL">시작</button>
|
|
||||||
번호를 누르면 바꾸고싶은URL로 이동
|
|
||||||
<label data-bs-toggle="modal" data-bs-target="#index_action_form" data-src="바꾸고싶은URL">번호</label>
|
|
||||||
-->
|
|
||||||
<div id="index_action_form" class="index_action_form modal fade" tabindex="-1" aria-labelledby="target_modal_label" aria-hidden="true">
|
|
||||||
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable"> <!-- modal-lg는 모달 크기를 크게 설정 -->
|
|
||||||
<div class="modal-content">
|
|
||||||
<div class="modal-header">
|
|
||||||
<h5 class="modal-title" id="target_modal_label">
|
|
||||||
<h4> <?= ICONS['DESKTOP'] ?> <?= $viewDatas['title'] ?> </h4>
|
|
||||||
</h5>
|
|
||||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
||||||
</div>
|
|
||||||
<div id="form-container" class="modal-body"></div>
|
|
||||||
<div class="modal-footer">
|
|
||||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Modal이 열릴 때 iframe의 src를 설정 -->
|
|
||||||
<script>
|
|
||||||
// 모달이 열릴 때 이벤트 리스너 추가
|
|
||||||
document.getElementById('index_action_form').addEventListener('show.bs.modal', function(event) {
|
|
||||||
// 모달을 트리거한 버튼 요소 가져오기
|
|
||||||
var button = event.relatedTarget;
|
|
||||||
// data-src 속성에서 URL 가져오기
|
|
||||||
var url = button.getAttribute('data-src');
|
|
||||||
// URL로 loadActionForm 함수 호출
|
|
||||||
if (url) {
|
|
||||||
fetch(url)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(data => {
|
|
||||||
document.getElementById('form-container').innerHTML = data;
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.error('콘텐츠 로딩 오류:', error);
|
|
||||||
alert('콘텐츠를 로드하는 중 오류가 발생했습니다.');
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
alert('data-src 속성이 없습니다.');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
Loading…
Reference in New Issue
Block a user