error 메시지 수정

main
jjh 1 year ago
parent 6bf5b66d76
commit 38ab43f11a

@ -35,7 +35,7 @@ function isEmpty(v) {
|| v == null || v == null
|| v == "null" || v == "null"
) return true; ) return true;
switch (typeof(v)) { switch (typeof(v)) {
case "string": return "" == trim(v); case "string": return "" == trim(v);
case "boolean": if (false == v) return false; case "boolean": if (false == v) return false;
@ -81,13 +81,13 @@ function toQuery(map, encode) {
function uuid() { function uuid() {
var hexDigits = "0123456789abcde", var hexDigits = "0123456789abcde",
result = []; result = [];
for (var i = 0; i < 36; ++i) for (var i = 0; i < 36; ++i)
result[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); result[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
result[14] = "4"; result[14] = "4";
result[19] = hexDigits.substr((result[19] & 0x3) | 0x8, 1); result[19] = hexDigits.substr((result[19] & 0x3) | 0x8, 1);
result[8] = result[13] = result[18] = result[23] = "-"; result[8] = result[13] = result[18] = result[23] = "-";
return result.join(""); return result.join("");
} }
@ -130,15 +130,15 @@ var dialog = {
size = " modal-" + size; size = " modal-" + size;
tmpl = tmpl.replace(/{size}/, size); tmpl = tmpl.replace(/{size}/, size);
dlg = $(tmpl).appendTo("body"); dlg = $(tmpl).appendTo("body");
dlg.find(".modal-body").html(conf.content || "").fadeIn(); dlg.find(".modal-body").html(conf.content || "").fadeIn();
dlg.on("hidden.bs.modal", function() {// on dialog close dlg.on("hidden.bs.modal", function() {// on dialog close
$("#" + id +",#" + backdropID).remove(); // removes the dialog and its backdrop $("#" + id +",#" + backdropID).remove(); // removes the dialog and its backdrop
if (conf.onClose) if (conf.onClose)
conf.onClose(); conf.onClose();
}); });
if (conf.onOK) { if (conf.onOK) {
let footer = dlg.find(".modal-footer"); let footer = dlg.find(".modal-footer");
footer.show(); footer.show();
@ -146,7 +146,7 @@ var dialog = {
if (conf.getData) { if (conf.getData) {
var selected = conf.getData.apply(); var selected = conf.getData.apply();
if (!selected) return; if (!selected) return;
conf.onOK(selected); conf.onOK(selected);
dialog.close(id); dialog.close(id);
} else { } else {
@ -158,14 +158,14 @@ var dialog = {
if (conf.timeout) if (conf.timeout)
setTimeout(function(){dialog.close(id);}, conf.timeout); setTimeout(function(){dialog.close(id);}, conf.timeout);
} }
dlg.draggable().modal("show"); dlg.draggable().modal("show");
$(".modal-backdrop").each(function() { // gives id to its backdrop $(".modal-backdrop").each(function() { // gives id to its backdrop
let backdrop = $(this); let backdrop = $(this);
if (!backdrop.prop("id")) if (!backdrop.prop("id"))
backdrop.prop("id", backdropID); backdrop.prop("id", backdropID);
}); });
if (conf.init) if (conf.init)
conf.init(); conf.init();
}, },
@ -186,11 +186,11 @@ var dialog = {
function onError(xhr, options, error) { function onError(xhr, options, error) {
if (xhr.readyState == 0) if (xhr.readyState == 0)
return dialog.alert("서버에 접근할 수 없습니다."); return dialog.alert("서버에 접근할 수 없습니다.");
var resp = JSON.parse(xhr.responseText); var resp = JSON.parse(xhr.responseText);
if (resp.handler) if (resp.handler)
return eval(resp.handler); return eval(resp.handler);
var msgs = []; var msgs = [];
for (key in resp) for (key in resp)
msgs.push(resp[key]) msgs.push(resp[key])
@ -211,35 +211,35 @@ var ajax = {
if (options.data) if (options.data)
options.type = "POST"; options.type = "POST";
} }
var success = options.success; var success = options.success;
options.success = function(resp) { options.success = function(resp) {
if ("string" == typeof resp) if ("string" == typeof resp)
resp = trim(resp); resp = trim(resp);
var stacktrace = resp.stacktrace; var stacktrace = resp.stacktrace;
delete resp.stacktrace; delete resp.stacktrace;
debug("response", resp); debug("response", resp);
if (!resp.failed) if (!resp.failed)
return success(resp); return success(resp);
dialog.alert({ dialog.alert({
title:resp.title, title:resp.title,
content:resp.message content:[resp.description, resp.message].join("<br />")
}); });
debug("stacktrace", stacktrace); debug("stacktrace", stacktrace);
}; };
var handleError = options.error || onError; var handleError = options.error || onError;
options.error = function(xhr, options, error) { options.error = function(xhr, options, error) {
wait(false); wait(false);
debug("error", xhr, options, error); debug("error", xhr, options, error);
handleError(xhr, options, error); handleError(xhr, options, error);
} }
var handleComplete = options.complete || function(){}; var handleComplete = options.complete || function(){};
options.complete = function() { options.complete = function() {
wait(false); wait(false);
@ -450,14 +450,14 @@ $.fn.getValues = function(propertyMapper) {
key = input.prop("id") || input.prop("name"), key = input.prop("id") || input.prop("name"),
value = input.val(); value = input.val();
if (isEmpty(key) || value === undefined) return; if (isEmpty(key) || value === undefined) return;
var type = input.prop("type"); var type = input.prop("type");
if ("file" == type) { if ("file" == type) {
value = input.get(0).files; value = input.get(0).files;
} else if (["checkbox", "radio"].indexOf(type) > -1) { } else if (["checkbox", "radio"].indexOf(type) > -1) {
if (!input.is(":checked")) return; if (!input.is(":checked")) return;
} }
var stored = inputValues[key]; var stored = inputValues[key];
if (stored === undefined) { if (stored === undefined) {
inputValues[key] = value; inputValues[key] = value;
@ -473,7 +473,7 @@ $.fn.getValues = function(propertyMapper) {
var array = [stored]; var array = [stored];
if (!Array.isArray(value)) if (!Array.isArray(value))
array.push(value); array.push(value);
else else
array = array.concat(value); array = array.concat(value);
inputValues[key] = array; inputValues[key] = array;
} }
@ -492,7 +492,7 @@ $.fn.getValues = function(propertyMapper) {
break; break;
} }
if (value === undefined) continue; if (value === undefined) continue;
delete inputValues[valueProvider]; delete inputValues[valueProvider];
inputValues[property] = value; inputValues[property] = value;
} }
@ -519,10 +519,10 @@ $.fn.getValues = function(propertyMapper) {
function paginate(config) { function paginate(config) {
var rc = config.totalSize || 0; var rc = config.totalSize || 0;
// if (!rc) return ""; // if (!rc) return "";
var fetchCount = config.fetchSize || 0; var fetchCount = config.fetchSize || 0;
// if (!fetchCount) return ""; // if (!fetchCount) return "";
var fetch = { var fetch = {
all:0, all:0,
none:-1, none:-1,
@ -546,7 +546,7 @@ function paginate(config) {
}; };
var lc = fetch.count(rc, fetchCount); var lc = fetch.count(rc, fetchCount);
if (lc < 2) return ""; if (lc < 2) return "";
var links = ifEmpty(config.links, fetch.all), var links = ifEmpty(config.links, fetch.all),
page = fetch.page(ifEmpty(config.start, 0), fetchCount), page = fetch.page(ifEmpty(config.start, 0), fetchCount),
band = fetch.band(page, links), band = fetch.band(page, links),
@ -578,7 +578,7 @@ function paginate(config) {
next:function(bandCount) { next:function(bandCount) {
bandCount = parseInt(bandCount); bandCount = parseInt(bandCount);
if (bandCount - band < 2) return ""; if (bandCount - band < 2) return "";
var nextBand = band + 1, var nextBand = band + 1,
page = nextBand * links, page = nextBand * links,
fromRec = page * fetchCount; fromRec = page * fetchCount;
@ -588,7 +588,7 @@ function paginate(config) {
bandCount = parseInt(bandCount); bandCount = parseInt(bandCount);
var lastBand = bandCount - 1; var lastBand = bandCount - 1;
if (lastBand - band < 2) return ""; if (lastBand - band < 2) return "";
var pages = lastBand * links, var pages = lastBand * links,
fromRec = pages * fetchCount; fromRec = pages * fetchCount;
return tags.link(config.last, fromRec, pages + 1); return tags.link(config.last, fromRec, pages + 1);
@ -664,7 +664,7 @@ $.fn.setPagingInfo = function(config) {
$.fn.setCurrentRow = function(val) { $.fn.setCurrentRow = function(val) {
if (!val) return; if (!val) return;
return this.each(function() { return this.each(function() {
var e = $(this); var e = $(this);
e.find("tr").each(function(){ e.find("tr").each(function(){
@ -673,7 +673,7 @@ $.fn.setCurrentRow = function(val) {
if (current) if (current)
tr.addClass("current-row"); tr.addClass("current-row");
else else
tr.removeClass("current-row"); tr.removeClass("current-row");
}); });
}); });
} }
@ -684,26 +684,26 @@ class FormFields {
this.children = ["input", "select", "textarea"].map(tag => this.selector + " " + tag).join(","); this.children = ["input", "select", "textarea"].map(tag => this.selector + " " + tag).join(",");
this.datamap = []; this.datamap = [];
} }
set(obj) { set(obj) {
document.querySelectorAll(this.children).forEach(input => { document.querySelectorAll(this.children).forEach(input => {
let prop = input.getAttribute("data-map") let prop = input.getAttribute("data-map")
|| input.name || input.name
|| input.id; || input.id;
if (!prop) return; if (!prop) return;
let dataItem = obj instanceof DataItem, let dataItem = obj instanceof DataItem,
value = dataItem ? obj.getValue(prop) : obj[prop]; value = dataItem ? obj.getValue(prop) : obj[prop];
if ("radio" == input.type) { if ("radio" == input.type) {
if (value && value == input.value) if (value && value == input.value)
input.checked = true; input.checked = true;
} else { } else {
input.value = ifEmpty(value, ""); input.value = ifEmpty(value, "");
} }
}); });
} }
get() { get() {
let obj = {}; let obj = {};
document.querySelectorAll(this.children).forEach(input => { document.querySelectorAll(this.children).forEach(input => {
@ -748,7 +748,7 @@ function inputsInRange(fromSource, toSource) {
toVal = to.val() || "", toVal = to.val() || "",
ok = toVal >= fromVal; ok = toVal >= fromVal;
if (ok) return; if (ok) return;
if ($(this)[0] == from[0]) if ($(this)[0] == from[0])
to.val(from.val()) to.val(from.val())
else else

Loading…
Cancel
Save