diff --git a/src/main/webapp/resources/css/styles.css b/src/main/webapp/resources/css/styles.css index 5a98987..aed2dea 100644 --- a/src/main/webapp/resources/css/styles.css +++ b/src/main/webapp/resources/css/styles.css @@ -145,4 +145,11 @@ ul.nav-tabs > li.nav-item { width: auto; } -.not-used, tr.not-used td {color: lightgrey;} \ No newline at end of file +.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; +} diff --git a/src/main/webapp/resources/js/base/dataset-support.js b/src/main/webapp/resources/js/base/dataset-support.js index 2cc173a..d02b8e4 100644 --- a/src/main/webapp/resources/js/base/dataset-support.js +++ b/src/main/webapp/resources/js/base/dataset-support.js @@ -67,20 +67,31 @@ class TableSupport extends DatasetSupport { if (this.tr) { let template = this.find(this.tr); - this.tr = (template || {}).innerHTML || ""; + this.tr = (template || {}).innerHTML; } if (this.notFound) { let template = this.find(this.notFound); - this.notFound = (template || {}).innerHTML || ""; + this.notFound = (template || {}).innerHTML; } if (!this.tr && !this.notFound) { 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; + if (!this.tr) + throw this.selector + " must have a template for a data row"; this.notFound = (templates[1] || {}).innerHTML; } + + if (!this.notFound) { + let length = (this.tr.match(/ { + 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 { constructor(conf) { diff --git a/src/main/webapp/resources/js/base/dataset.js b/src/main/webapp/resources/js/base/dataset.js index b85b092..04693b9 100644 --- a/src/main/webapp/resources/js/base/dataset.js +++ b/src/main/webapp/resources/js/base/dataset.js @@ -306,9 +306,11 @@ class DataItem { if (formatter) { str = formatter(str, this); } - let empty = Object.entries(this.data).length < 1 + + let data = this.data, + empty = Object.entries(data).length < 1 if (!empty) - for (let p in this.data) { + for (let p in data) { let regexp = this._formats.regexp(p); str = str.replace(regexp, this.getValue(p)); } @@ -316,9 +318,23 @@ class DataItem { .replace(/{data-no}/gi, this.no); 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(/]*>/)[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); } }