237 lines
9.5 KiB
HTML
237 lines
9.5 KiB
HTML
<!DOCTYPE html>
|
|
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
|
|
layout:decorate="~{layout/layout}">
|
|
|
|
<section layout:fragment="content">
|
|
<form autocomplete="off"
|
|
th:action="@{/communication/notices/create}"
|
|
method="post" class="fw-bold" name="reqForm">
|
|
<input type="hidden" name="id" th:value="${id}">
|
|
<div class="content-inner">
|
|
<!-- 테이블 영역 -->
|
|
<table class="type-form">
|
|
<tbody>
|
|
<tr>
|
|
<th>제목<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
|
<td colspan="3">
|
|
<div class="component-input">
|
|
<div class="input-field">
|
|
<input type="text" name="title" id="title" placeholder="">
|
|
</div>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>내용<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
|
<td colspan="3">
|
|
<textarea class="form-control" id="noticeContent" rows="10" name="content"></textarea>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<th>첨부파일</th>
|
|
<td colspan="3">
|
|
<div class="input-file-group">
|
|
<label for="file" class="input-file-btn">
|
|
<input type="file" name="multipartAttachments" id="file" onchange="uiUtil.uploadFile('NOTICE', this);" >
|
|
<span class="file-txt">파일첨부</span>
|
|
</label>
|
|
<p class="desc">첨부 가능 파일 형식: 문서(pdf, docx, xlsx, pptx, hwp), 이미지(jpg, jpeg, png, gif), 기타(zip,
|
|
csv, txt) / 파일당 최대 5MB까지 등록 가능합니다.</p>
|
|
<ul class="file-list input-group" id="noticeAttachments">
|
|
|
|
</ul>
|
|
</div>
|
|
</td>
|
|
<!-- <td colspan="3">
|
|
<div class="btns-row align-left publicFileInputs">
|
|
<button type="button" class="btn btn-secondary" onclick="addFileInput();">
|
|
<span class="btn-txt">다건 파일 첨부</span>
|
|
</button>
|
|
</div>
|
|
</td>-->
|
|
</tr>
|
|
<tr>
|
|
<th>게시기간<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
|
<td colspan="2">
|
|
<div class="d-flex">
|
|
<div class="component-input">
|
|
<div class="input-field">
|
|
<input id="boardStartDate" class="form-control flatpickr" name="startDate" type="text" placeholder="시작일을 선택해 주세요"/>
|
|
</div>
|
|
</div>-
|
|
<div class="component-input">
|
|
<div class="input-field">
|
|
<input id="boardEndDate" class="form-control flatpickr" name="endDate" type="text" placeholder="종료일을 선택해 주세요"/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
</tr>
|
|
<tr>
|
|
<th>노출여부<i class="ico-required-mark" role="img" aria-label="필수">*</i></th>
|
|
<td>
|
|
<div class="component-select">
|
|
<select class="select-list" name="visible" id="open">
|
|
<option value="true">Y</option>
|
|
<option value="false">N</option>
|
|
</select>
|
|
</div>
|
|
</td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
|
|
<div class="component-btns bottom-btn-group">
|
|
<div class="btns-row align-right">
|
|
<button type="button" class="btn btn-secondary" onclick="gotoList();">
|
|
<span class="btn-txt">취소</span>
|
|
</button>
|
|
<button type="button" class="btn btn-primary" onclick="goSave();">
|
|
<span class="btn-txt">등록</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
|
|
</section>
|
|
|
|
<section layout:fragment="script">
|
|
<script src="/static/library/tinymce/6.0.3/tinymce.min.js" referrerpolicy="origin"></script>
|
|
<script src="/static/ui/editorImageUpload.js"></script>
|
|
|
|
<script th:inline="javascript">
|
|
|
|
$(".flatpickr").flatpickr({
|
|
dateFormat: "Y-m-d\\TH:i",
|
|
// altInput: true,
|
|
// altFormat: "Y-m-d H:i",
|
|
monthSelectorType: 'static',
|
|
enableTime: true,
|
|
time_24hr: true
|
|
});
|
|
|
|
</script>
|
|
|
|
<script th:inline="javascript">
|
|
|
|
|
|
const goPrev = () => {
|
|
history.back();
|
|
}
|
|
|
|
const gotoList = () => {
|
|
location.href = '/communication/notices';
|
|
}
|
|
|
|
/* function addFileInput() {
|
|
const inputGroup = $(`
|
|
<div class="input-group w-50">
|
|
<input class="form-control mb-2" type="file" name="multipartAttachments"
|
|
onchange="uiUtil.uploadFile('NOTICE', this);">
|
|
<div class="invalid-feedback fw-bold">
|
|
에러 메세지
|
|
</div>
|
|
</div>
|
|
`);
|
|
|
|
$('.publicFileInputs').append(inputGroup);
|
|
|
|
return inputGroup;
|
|
|
|
}
|
|
*/
|
|
|
|
const getNotice = () => {
|
|
const f = document.reqForm;
|
|
|
|
$.ajax({
|
|
method: 'GET',
|
|
url: '/api/communication/notices/' + f.id.value,
|
|
success(res) {
|
|
console.log(res);
|
|
|
|
initEditor('#noticeContent', (editor) => {
|
|
editor.on('init', function () {
|
|
setTimeout(() => {
|
|
tinymce.get('noticeContent').setContent(uiUtil.unescapeHtml(res.content));
|
|
}, 0);
|
|
});
|
|
});
|
|
|
|
f.title.value = uiUtil.unescapeHtml(res.title);
|
|
f.startDate.value = res.startDate.substring(0, 16);
|
|
f.endDate.value = res.endDate.substring(0, 16);
|
|
f.visible.value = res.visible;
|
|
|
|
res.uploadFiles.forEach((uploadFile) => {
|
|
let inputGroup = $('#noticeAttachments');
|
|
/* let inputGroup = addFileInput();
|
|
inputGroup.append(`<input type="hidden" name="fileMappingId" value="${uploadFile.id}"/>`);*/
|
|
uiUtil.showFileInfo(inputGroup, uploadFile, false);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
// 상세정보 얻기
|
|
getNotice();
|
|
|
|
const goSave = () => {
|
|
const f = document.reqForm;
|
|
|
|
// tinymce 는 사용자 입력을 받는 순간 몇몇 문자(&)를 escaping 한다.
|
|
// xss 방지를 위한 html escape 는 필터를 통해 자동처리되니 전달시에는 원문 그대로를 던진다.
|
|
f.content.value = uiUtil.unescapeHtml(tinymce.get('noticeContent').getContent());
|
|
|
|
const obj = $(f).serializeObject();
|
|
|
|
if(obj.fileMappingId) {
|
|
if (!Array.isArray(obj.fileMappingId)) {
|
|
obj.fileMappingId = [obj.fileMappingId];
|
|
}
|
|
}
|
|
|
|
const csrfToken = $('meta[name="_csrf"]').attr('content');
|
|
const csrfHeader = $('meta[name="_csrf_header"]').attr('content');
|
|
|
|
$.ajax({
|
|
'method': 'PUT',
|
|
'url': '/api/communication/notices/update',
|
|
contentType: 'application/json',
|
|
data: JSON.stringify(obj),
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader(csrfHeader, csrfToken);
|
|
},
|
|
success: (res) => {
|
|
if (confirm(`'${uiUtil.unescapeHtml(res.title)}' 게시물이 수정되었습니다.\n이전 화면으로 이동하시겠습니까?`)) {
|
|
history.back();
|
|
}
|
|
},
|
|
statusCode: {
|
|
// error
|
|
400: function (res) {
|
|
const resJson = res.responseJSON;
|
|
alert(resJson.message);
|
|
},
|
|
// validation fail
|
|
422: function (res) {
|
|
alert(res.responseJSON[0].defaultMessage);
|
|
// $(res.responseJSON).each((idx, oj) => {
|
|
// let target = $(f).find('[name=' + oj.field + ']');
|
|
// target.addClass('is-invalid');
|
|
//
|
|
// target.parent().find('.invalid-feedback').text(oj.defaultMessage);
|
|
// });
|
|
}
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
</section>
|
|
|
|
</html> |