ajax 저장, 수정 동작 시 클릭 방지&안내 문구 추가.

master
강석 최 2022-01-21 17:06:54 +09:00
parent dfd4250f47
commit 5f36826de4
11 changed files with 129 additions and 72 deletions

View File

@ -31,3 +31,21 @@
/*왜 안돌까?*/ /*왜 안돌까?*/
/*transform: rotate(90deg);*/ /*transform: rotate(90deg);*/
} }
#fadeDiv{
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
background-color: #00000050;
z-index: 1090;
}
#fadeDiv > div{
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
}

View File

@ -96,6 +96,7 @@ $(document).on('click', '#saveCategoryBtn', function (){
}) })
if(saveList.length !== 0) { if(saveList.length !== 0) {
if (confirm(saveList.length + "건을 저장하시겠습니까?")) { if (confirm(saveList.length + "건을 저장하시겠습니까?")) {
contentFade("in");
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : "/admin/insertCategory2", url : "/admin/insertCategory2",
@ -109,7 +110,8 @@ $(document).on('click', '#saveCategoryBtn', function (){
sessionReload(); sessionReload();
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }

View File

@ -44,6 +44,7 @@ $(document).on('click', '#allValueCheckBox', function (event){
$(document).on('click', '#saveBtn', function (){ $(document).on('click', '#saveBtn', function (){
if(valueCheck()){ if(valueCheck()){
if(confirm("저장하시겠습니까?")){ if(confirm("저장하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#commonCodeForm")[0]); const formData = new FormData($("#commonCodeForm")[0]);
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
@ -55,9 +56,11 @@ $(document).on('click', '#saveBtn', function (){
alert("저장되었습니다.") alert("저장되었습니다.")
$("#closeModalBtn").click(); $("#closeModalBtn").click();
categoryCheck(data.category); categoryCheck(data.category);
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }
@ -76,6 +79,7 @@ $(document).on('click', '#deleteCommonCodeBtn', function (){
}) })
if(codeList.length !== 0){ if(codeList.length !== 0){
if(confirm(codeList.length+"건을 삭제하시겠습니까?")){ if(confirm(codeList.length+"건을 삭제하시겠습니까?")){
contentFade("in");
$.ajax({ $.ajax({
type : 'PUT', type : 'PUT',
url : "/admin/deleteCode", url : "/admin/deleteCode",
@ -85,11 +89,12 @@ $(document).on('click', '#deleteCommonCodeBtn', function (){
xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val()); xhr.setRequestHeader($("[name='_csrf_header']").val(), $("[name='_csrf']").val());
}, },
success : function(data) { success : function(data) {
alert("삭제되었습니다."); alert("저장되었습니다.");
getValues($(".categoryCheckBox:checked").val()); getValues($(".categoryCheckBox:checked").val());
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }

View File

@ -41,6 +41,7 @@ $(document).on('change', '#passwordUpdateFlag', function (){
$(document).on('click', '#saveBtn', function (){ $(document).on('click', '#saveBtn', function (){
if(valueCheck("userInfoInsert")){ if(valueCheck("userInfoInsert")){
if(confirm("저장하시겠습니까?")){ if(confirm("저장하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#userInfoInsert")[0]); const formData = new FormData($("#userInfoInsert")[0]);
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
@ -56,9 +57,11 @@ $(document).on('click', '#saveBtn', function (){
$("#closeModalBtn").click(); $("#closeModalBtn").click();
$("#searchBtn").click(); $("#searchBtn").click();
} }
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }
@ -68,6 +71,7 @@ $(document).on('click', '#saveBtn', function (){
$(document).on('click', '#updateBtn', function (){ $(document).on('click', '#updateBtn', function (){
if(valueCheck("userInfoUpdate")){ if(valueCheck("userInfoUpdate")){
if(confirm("저장하시겠습니까?")){ if(confirm("저장하시겠습니까?")){
contentFade("in");
const formData = new FormData($("#userInfoUpdate")[0]); const formData = new FormData($("#userInfoUpdate")[0]);
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
@ -78,9 +82,11 @@ $(document).on('click', '#updateBtn', function (){
success : function(data) { success : function(data) {
alert("저장되었습니다.") alert("저장되었습니다.")
$("#searchBtn").click(); $("#searchBtn").click();
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }
@ -102,6 +108,7 @@ $(document).on('click', '#saveCategoryRoleBtn', function (){
categoryRole: 'T' categoryRole: 'T'
}); });
}) })
contentFade("in");
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : "/admin/insertCategoryRole", url : "/admin/insertCategoryRole",
@ -112,9 +119,11 @@ $(document).on('click', '#saveCategoryRoleBtn', function (){
}, },
success : function(data) { success : function(data) {
alert("저장되었습니다."); alert("저장되었습니다.");
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
}) })

View File

@ -66,6 +66,7 @@ $(document).on('click', '#zipDownBtn', function (){
$(document).on('click', '#deleteBtn', function (){ $(document).on('click', '#deleteBtn', function (){
if(confirm("이 게시물을 삭제하시겠습니까?\n되돌릴 수 없습니다.")){ if(confirm("이 게시물을 삭제하시겠습니까?\n되돌릴 수 없습니다.")){
contentFade("in");
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
url : "/board/deleteContent", url : "/board/deleteContent",
@ -78,7 +79,8 @@ $(document).on('click', '#deleteBtn', function (){
location.reload(); location.reload();
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다");
contentFade("out")
} }
}) })
} }

View File

@ -86,6 +86,7 @@ $(document).on('click', '#saveBtn', function (){
formData.append('fileSeq', $(el).attr("data-fileseq")); formData.append('fileSeq', $(el).attr("data-fileseq"));
}) })
} }
contentFade("in");
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
data : formData, data : formData,
@ -97,9 +98,11 @@ $(document).on('click', '#saveBtn', function (){
alert("저장되었습니다."); alert("저장되었습니다.");
location.href = "/board/contentList?categorySeq="+$("#categorySeq").val(); location.href = "/board/contentList?categorySeq="+$("#categorySeq").val();
} }
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }

View File

@ -9,6 +9,14 @@ $(document).on('click', '#moveLeftBtn', function (){
$(document).on('click', '.contentWriteBtn', function (){ $(document).on('click', '.contentWriteBtn', function (){
location.href="/board/contentWrite"+(categorySeq!==undefined?("?categorySeq="+categorySeq):""); location.href="/board/contentWrite"+(categorySeq!==undefined?("?categorySeq="+categorySeq):"");
}) })
function sessionReload(){
$.ajax({
url: '/refreshSession',
type: 'GET',
success: function(){location.reload();},
error:function(){}
});
}
function moveCategorySelectBody(direction){ function moveCategorySelectBody(direction){
const categorySelectBody = $("#categorySelectBody"); const categorySelectBody = $("#categorySelectBody");
const nowX = categorySelectBody.scrollLeft(); const nowX = categorySelectBody.scrollLeft();
@ -34,3 +42,11 @@ function openMenu(parentSeq){
openMenu(target.attr("data-parentseq")); openMenu(target.attr("data-parentseq"));
} }
} }
function contentFade(action){
if(action === "in"){
$("#fadeDiv").show()
}else{
$("#fadeDiv").hide()
}
}

View File

@ -5,6 +5,7 @@ $(function (){
$(document).on('click', '#savePasswordBtn', function (){ $(document).on('click', '#savePasswordBtn', function (){
if(passwordCheck()){ if(passwordCheck()){
const formData = new FormData($("#modifyPasswordForm")[0]); const formData = new FormData($("#modifyPasswordForm")[0]);
contentFade("in")
$.ajax({ $.ajax({
type : 'PUT', type : 'PUT',
data : formData, data : formData,
@ -13,14 +14,16 @@ $(document).on('click', '#savePasswordBtn', function (){
contentType: false, contentType: false,
success : function(result) { success : function(result) {
if(result==="OK"){ if(result==="OK"){
alert("수정되었습니다."); alert("저장되었습니다.");
$("#passwordModifyModal").find(".btn-close").click(); $("#passwordModifyModal").find(".btn-close").click();
}else if(result==="passwordNotMatch"){ }else if(result==="passwordNotMatch"){
alert("현재 비밀번호가 맞지 않습니다."); alert("현재 비밀번호가 맞지 않습니다.");
} }
contentFade("out");
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.");
contentFade("out");
} }
}) })
} }

View File

@ -48,6 +48,7 @@ $(document).on('click', '#approvalBtn', function (){
}) })
function modifyRequestStatusChange(data){ function modifyRequestStatusChange(data){
contentFade("in");
$.ajax({ $.ajax({
type: "PUT", type: "PUT",
url: '/info/modifyRequestStateChange', url: '/info/modifyRequestStateChange',
@ -60,7 +61,8 @@ function modifyRequestStatusChange(data){
location.reload() location.reload()
}, },
error: function () { error: function () {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}); });
} }

View File

@ -32,6 +32,7 @@ $(document).on('change', '.parentSeq', function (){
function saveModifyRequest(){ function saveModifyRequest(){
const formData = new FormData($("#requestForm")[0]); const formData = new FormData($("#requestForm")[0]);
contentFade("in");
$.ajax({ $.ajax({
type : 'POST', type : 'POST',
data : formData, data : formData,
@ -45,7 +46,8 @@ function saveModifyRequest(){
} }
}, },
error : function(xhr, status) { error : function(xhr, status) {
alert("저장에 실패하였습니다.")
contentFade("out");
} }
}) })
} }

View File

@ -3,7 +3,7 @@
xmlns:th="http://www.thymeleaf.org" xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"> xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>해양경찰청 파일관리 시스템</title> <title>해양경찰청 파일관리 시스템</title>
@ -44,18 +44,10 @@
sessionReload() sessionReload()
} }
}) })
function sessionReload(){
$.ajax({
url: '/refreshSession',
type: 'GET',
success: function(){location.reload();},
error:function(){}
});
}
</script> </script>
</th:block> </th:block>
</head> </head>
<body class="d-flex flex-column h-100"> <body class="d-flex flex-column h-100">
<header th:replace="fragments/header :: headerFragment"></header> <header th:replace="fragments/header :: headerFragment"></header>
<div class="h-100" sec:authorize="isAnonymous()" layout:fragment="content"></div> <div class="h-100" sec:authorize="isAnonymous()" layout:fragment="content"></div>
<div sec:authorize="isAuthenticated()" class="row mx-0"> <div sec:authorize="isAuthenticated()" class="row mx-0">
@ -67,5 +59,8 @@
</div> </div>
</div> </div>
<footer th:replace="fragments/footer :: footerFragment"></footer> <footer th:replace="fragments/footer :: footerFragment"></footer>
</body> <div id="fadeDiv" style="display: none;">
<div class="p-5 rounded"><h1>저장중입니다.</h1></div>
</div>
</body>
</html> </html>