.not-used 추가

master
mjkhan21 4 days ago
parent c9704d1cb0
commit eb6978b03e

@ -145,4 +145,11 @@ ul.nav-tabs > li.nav-item {
width: auto; width: auto;
} }
.not-used, tr.not-used td {color: lightgrey;} .not-used, tr.not-used td {color: lightgrey;}
.resizer {
position: absolute; top: 0; right: 0;
width: 5px; height: 100%;
cursor: col-resize; user-select: none;
background-color: transparent;
}

@ -67,20 +67,31 @@ class TableSupport extends DatasetSupport {
if (this.tr) { if (this.tr) {
let template = this.find(this.tr); let template = this.find(this.tr);
this.tr = (template || {}).innerHTML || ""; this.tr = (template || {}).innerHTML;
} }
if (this.notFound) { if (this.notFound) {
let template = this.find(this.notFound); let template = this.find(this.notFound);
this.notFound = (template || {}).innerHTML || ""; this.notFound = (template || {}).innerHTML;
} }
if (!this.tr && !this.notFound) { if (!this.tr && !this.notFound) {
let templates = this.findAll(this.selector + " template"); let templates = this.findAll(this.selector + " template");
if (templates.length < 1)
log("WARNING: ", this.selector + " must have a template for a data row");
this.tr = (templates[0] || {}).innerHTML; this.tr = (templates[0] || {}).innerHTML;
if (!this.tr)
throw this.selector + " must have a template for a data row";
this.notFound = (templates[1] || {}).innerHTML; this.notFound = (templates[1] || {}).innerHTML;
} }
if (!this.notFound) {
let length = (this.tr.match(/<td/gi) || []).length,
name = this.ctrl.prefixName || "정보";
if (!name.endsWith("정보"))
name += " 정보";
this.notFound = '<tr><td valign="top" colspan="{length}" class="text-center">{name}를 찾지 못했습니다</td></tr>'
.replace(/{length}/g, length)
.replace(/{name}/g, name);
}
this.setLoadNext(); this.setLoadNext();
@ -159,8 +170,10 @@ class TableSupport extends DatasetSupport {
if (!this.selectionToggler) return; if (!this.selectionToggler) return;
let toggler = this.find(this.selectionToggler); let toggler = this.find(this.selectionToggler);
toggler.checked = false; if (toggler) {
toggler.disabled = empty; toggler.checked = false;
toggler.disabled = empty;
}
} }
/**Handler called back on the current change event. /**Handler called back on the current change event.
@ -220,6 +233,51 @@ TableSupport.cssClass = {
asc: "sort-asc", asc: "sort-asc",
desc: "sort-desc" desc: "sort-desc"
}; };
TableSupport.resizableColumns = table => {
if ("string" == typeof(table))
table = document.querySelector(table);
let cols = table.querySelectorAll('th');
cols.forEach(col => {
let resizer = document.createElement('div');
resizer.className = 'resizer';
col.appendChild(resizer);
let startX, startWidth;
resizer.addEventListener('mousedown', (e) => {
e.preventDefault();
startX = e.pageX;
startWidth = col.offsetWidth;
document.body.style.cursor = 'col-resize';
document.body.style.userSelect = 'none';
// 마우스 이동 이벤트 리스너 추가
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
});
function onMouseMove(e) {
let width = startWidth + (e.pageX - startX);
if (width >= 50) { // 최소 너비 50px
if (col.style.width.endsWith("rem")) {
col.style.width = rem.fromPx(width);
} else {
col.style.width = width + 'px';
}
}
}
function onMouseUp() {
document.body.style.cursor = 'default';
document.body.style.userSelect = 'auto';
document.removeEventListener('mousemove', onMouseMove);
document.removeEventListener('mouseup', onMouseUp);
}
});
}
class CurrentDataSupport extends DatasetSupport { class CurrentDataSupport extends DatasetSupport {
constructor(conf) { constructor(conf) {

@ -306,9 +306,11 @@ class DataItem {
if (formatter) { if (formatter) {
str = formatter(str, this); str = formatter(str, this);
} }
let empty = Object.entries(this.data).length < 1
let data = this.data,
empty = Object.entries(data).length < 1
if (!empty) if (!empty)
for (let p in this.data) { for (let p in data) {
let regexp = this._formats.regexp(p); let regexp = this._formats.regexp(p);
str = str.replace(regexp, this.getValue(p)); str = str.replace(regexp, this.getValue(p));
} }
@ -316,9 +318,23 @@ class DataItem {
.replace(/{data-no}/gi, this.no); .replace(/{data-no}/gi, this.no);
if (empty) if (empty)
str = str.replace(/{([^}]+)}/g, ""); return str.replace(/{([^}]+)}/g, "");
let notUsed = "N" == data.USE_YN || "Y" == data.DEL_YN;
if (!notUsed)
return str;
let head = str.match(/<tr[^>]*>/)[0],
tr = "";
if (head.includes('class=')) {
let pattern = /class=["']([^"']*)["']/,
match = head.match(pattern);
tr = head.replace(pattern, 'class="' + match[1] + ' not-used"');
} else {
tr = head.replace('>', ' class="not-used">');
}
return str; return str.replace(head, tr);
} }
} }

Loading…
Cancel
Save