From 19c7d519a527f820737eade0901b1ee4d97fcbfd Mon Sep 17 00:00:00 2001 From: leebeomjun Date: Tue, 19 Mar 2024 15:33:14 +0900 Subject: [PATCH] =?UTF-8?q?=EC=82=AC=EC=9C=A0=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=EC=B0=BD=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 | 39 +++++++++++++++---- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/main/webapp/resources/js/base/base-fims.js b/src/main/webapp/resources/js/base/base-fims.js index 78e7888d..79c6b6da 100644 --- a/src/main/webapp/resources/js/base/base-fims.js +++ b/src/main/webapp/resources/js/base/base-fims.js @@ -9,12 +9,21 @@ async function alert2(msg){ return await dialog2(msg, "alert"); } +async function prompt2(msg){ + return await dialog2(msg, "prompt"); +} + 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(); var container = "
{content}
"; - content = container.replace(/{content}/g, msg); + if(type == "prompt"){ + var rsn = '
'; + content = container.replace(/{content}/g, msg + rsn); + } else { + content = container.replace(/{content}/g, msg); + } var backdropID = dlgId + "-backdrop"; var tmpl = template.replace(/{id}/g, dlgId).replace(/{title}/g, "").replace(/{size}/, "").replace("",""); tmpl = tmpl.replace("modal-dialog", "modal-dialog-centered modal-dialog"); @@ -22,8 +31,8 @@ async function dialog2(msg, type, buttons){ 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" || type == "alert"){ - if(type == "confirm"){ + if(type == "confirm" || type == "alert" || type == "prompt"){ + if(type == "confirm" || type == "prompt"){ dlg.find(".modal-footer").append(''); } } else { @@ -54,17 +63,31 @@ async function dialog2(msg, type, buttons){ setDialogZindex(); return new Promise(resolve => { - if(type == "confirm" || type == "alert"){ - dlg[0].querySelector(".btn-ok").addEventListener("click", () => { - dlg.modal("hide"); - resolve(true); - }); + if(type == "confirm" || type == "alert" || type == "prompt"){ + if(type == "prompt"){ + dlg[0].querySelector(".btn-ok").addEventListener("click", () => { + dlg.modal("hide"); + resolve($("#rsn").val()); + }); + } else { + dlg[0].querySelector(".btn-ok").addEventListener("click", () => { + dlg.modal("hide"); + resolve(true); + }); + } + if(type == "confirm"){ dlg[0].querySelector(".btn-cancel").addEventListener("click", () => { dlg.modal("hide"); resolve(false); }); } + if(type == "prompt"){ + dlg[0].querySelector(".btn-cancel").addEventListener("click", () => { + dlg.modal("hide"); + resolve(null); + }); + } } else { dlg.find(".btn-custom").each(function(){ this.addEventListener("click", () => {