FAISP/src/main/resources/static/js/ivsgt/majorStatus.js

196 lines
6.3 KiB
JavaScript
Raw Normal View History

2023-01-05 06:26:05 +00:00
$(function(){
$("#dateSelectorDiv").datepicker({
format: "yyyy-mm-dd",
language: "ko",
autoclose: true
});
})
// $(document).on('click', '#commentSaveBtn', function (){
// if(!$("#comment").val()) {
// alert("댓글을 입력해주세요.")
// }else{
// if (confirm("등록하시겠습니까?")) {
// contentFade("in")
// const formData = new FormData($("#commentForm")[0]);
// $.ajax({
// type : 'POST',
// data : formData,
// url : "/publicBoard/saveComment",
// processData: false,
// contentType: false,
// dataType:"html",
// beforeSend: function (xhr){
// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
// },
// success : function(html) {
// const parentComment = $("#parentComment");
// if(!parentComment.val()){
// $("#commentDiv").append(html)
// }else{
// $("#childComment"+parentComment.val()).append(html);
// }
// commentFormReset();
// alert("저장되었습니다.");
// contentFade("out");
// },
// error : function(xhr, status) {
// alert("저장에 실패하였습니다.")
// contentFade("out");
// }
// })
// }
// }
// })
// $(document).on('click', '.childCommentBtn', function (){
// const childCommentFormDiv = $(this).parents(".commentRow").find(".childCommentFormDiv")
// childCommentFormDiv.show();
// $("#parentComment").val($(this).parents(".commentRow").find(".commentKey").val());
// $("#childFormRemoveBtn").show();
// childCommentFormDiv.empty().append($("#commentForm"))
// })
// $(document).on('click', '#childFormRemoveBtn', function (){
// commentFormReset();
// })
// $(document).on('click', '.deleteCommentBtn', function (){
// const commentRow = $(this).parents(".commentRow");
// const publicKey = Number(commentRow.find(".publicKey").val());
// const commentKey = Number(commentRow.find(".commentKey").val());
// $.ajax({
// type : 'POST',
// data : JSON.stringify({publicKey: publicKey, commentKey: commentKey}),
// url : "/publicBoard/deleteComment",
// contentType: 'application/json',
// beforeSend: function (xhr){
// xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
// },
// success : function(result) {
// commentRow.remove();
// $("#childComment"+commentKey).remove();
// alert("삭제되었습니다.");
// contentFade("out");
// },
// error : function(xhr, status) {
// alert("삭제를 실패하였습니다.")
// contentFade("out");
// }
// })
// })
function getEditModal(majorKey, majorType){
$.ajax({
url: '/ivsgt/majorEditModal',
data: {majorKey: majorKey, majorType:majorType},
type: 'GET',
dataType:"html",
success: function(html){
$("#editContent").empty().append(html)
setUploadDiv();
setEditor('editor', '570');
$("#majorEditModal").modal('show');
},
error:function(){
}
});
}
function getViewModal(majorKey, majorType){
$.ajax({
url: '/ivsgt/majorViewModal',
data: {majorKey: majorKey, majorType: majorType},
type: 'GET',
dataType:"html",
success: function(html){
$("#viewContent").empty().append(html)
$("#majorViewModal").modal('show');
},
error:function(){
}
});
}
function saveContent(formId, majorType){
if(contentCheck(formId)){
if(confirm("저장하시겠습니까?")){
contentFade("in");
$("#content").val("");
const formData = new FormData($("#"+formId)[0]);
for(const file of files) {
if(!file.isDelete)
formData.append('uploadFiles', file, file.name);
}
$(".text-decoration-line-through").each(function (idx, el){
formData.append('fileSeq', $(el).attr("data-fileseq"));
})
formData.append('content', CrossEditor.GetBodyValue());
$.ajax({
type : 'POST',
data : formData,
url : "/ivsgt/saveContent",
processData: false,
contentType: false,
success : function(result) {
alert("저장되었습니다.");
contentFade("out");
$("#editModal").modal('hide');
getViewModal(result, majorType);
},
error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
}
})
}
}
}
function contentCheck(formId){
let flag = true;
if(!$("#title").val()){
alert("제목을 입력해주세요.")
flag = false;
}
if($("#majorType").val()==="PLB003"){
if(!$("#tabStatus").val()){
alert("분류를 선택해주세요.")
flag = false;
}
}
flag = fileCheck(flag, files);
return flag;
}
function commentFormReset(){
const commentForm = $("#commentForm");
commentForm[0].reset();
$("#childFormRemoveBtn").hide();
$("#parentComment").val('');
$("#commentFormHome").append(commentForm)
}
$(document).on('click', '#addMajorBtn', function (){
getEditModal(null)
})
$(document).on('click', '.planTr', function (){
$(".trChkBox").prop("checked", false);
$(this).find(".trChkBox").prop("checked", true);
getViewModal(Number($(this).find(".planKey").val()));
})
$(document).on('click', '#saveBtn', function (){
savePublicBoard("boardEditForm")
})
$(document).on('click', '#editBtn', function (){
$("#MajorStatusViewModal").modal('hide')
getEditModal($(this).attr("data-ciwkey"));
})