From 7e35b56842d5d0058589283dd3304147568bb5cb Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 19 Mar 2024 09:50:06 +0900 Subject: [PATCH] =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20=EB=B2=84?= =?UTF-8?q?=ED=8A=BC=20=EB=8B=A4=EC=9D=B4=EC=96=BC=EB=A1=9C=EA=B7=B8=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/resources/js/base/base-fims.js | 45 ++++++++++++++----- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/src/main/webapp/resources/js/base/base-fims.js b/src/main/webapp/resources/js/base/base-fims.js index 2453c3ca..448d31f8 100644 --- a/src/main/webapp/resources/js/base/base-fims.js +++ b/src/main/webapp/resources/js/base/base-fims.js @@ -9,7 +9,7 @@ async function alert2(msg){ return await dialog2(msg, "alert"); } -async function dialog2(msg, type){ +async function dialog2(msg, type, buttons){ var dlgId = "dlg-" + uuid(); var resp = await fetch(wctx.url("/resources/html/dialog.html")); var template = await resp.text(); @@ -18,12 +18,25 @@ async function dialog2(msg, type){ var backdropID = dlgId + "-backdrop"; var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("",""); tmpl = tmpl.replace("data-bs-backdrop=\"static\"", "data-bs-backdrop=\"static\" data-bs-keyboard=\"false\""); - tmpl = tmpl.replace("text-end hidden","text-end"); + tmpl = tmpl.replace("text-end hidden","text-end"); tmpl = tmpl.replace("btn-primary","btn-primary btn-ok"); var dlg = $(tmpl).appendTo("body"); - if(type == "confirm"){ - dlg.find(".modal-footer").append(''); + if(type == "confirm" || type == "alert"){ + if(type == "confirm"){ + dlg.find(".modal-footer").append(''); + } + } else { + dlg.find(".modal-footer").find(".btn-ok").remove(); + + for(var i=0; i < buttons.length; i++){ + dlg.find(".modal-footer").append( + ''); + } + } + dlg.find(".modal-header").remove(); dlg.find(".modal-body").html(content).fadeIn(); dlg.on("hidden.bs.modal", function() { @@ -40,16 +53,26 @@ async function dialog2(msg, type){ setDialogZindex(); return new Promise(resolve => { - dlg[0].querySelector(".btn-ok").addEventListener("click", () => { - dlg.modal("hide"); - resolve(true); - }); - if(type == "confirm"){ - dlg[0].querySelector(".btn-cancel").addEventListener("click", () => { + if(type == "confirm" || type == "alert"){ + dlg[0].querySelector(".btn-ok").addEventListener("click", () => { dlg.modal("hide"); - resolve(false); + resolve(true); }); + if(type == "confirm"){ + dlg[0].querySelector(".btn-cancel").addEventListener("click", () => { + dlg.modal("hide"); + resolve(false); + }); + } + } else { + dlg.find(".btn-custom").each(function(){ + this.addEventListener("click", () => { + dlg.modal("hide"); + resolve(this.dataset.key); + }); + }); } + }); }