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", () => {