ninegrid2 6.1386.0 → 6.1388.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.cjs.js +81 -31
- package/dist/bundle.esm.js +81 -31
- package/dist/nx/_nxDiv.js +81 -31
- package/package.json +1 -1
- package/src/nx/_nxDiv.js +81 -31
package/dist/bundle.cjs.js
CHANGED
|
@@ -28474,33 +28474,6 @@ class nxDiv extends HTMLElement {
|
|
|
28474
28474
|
return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]", this.#root);
|
|
28475
28475
|
}
|
|
28476
28476
|
|
|
28477
|
-
getData = () => {
|
|
28478
|
-
const jsonData = {};
|
|
28479
|
-
this.#getElements().forEach(el => {
|
|
28480
|
-
const key = el.name;
|
|
28481
|
-
if (!key) return;
|
|
28482
|
-
|
|
28483
|
-
let value;
|
|
28484
|
-
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
28485
|
-
let t = el.getAttribute("true-value") || "Y";
|
|
28486
|
-
let f = el.getAttribute("false-value") || "N";
|
|
28487
|
-
value = el.checked ? t : f;
|
|
28488
|
-
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
28489
|
-
value = el.value;
|
|
28490
|
-
} else {
|
|
28491
|
-
value = el.value;
|
|
28492
|
-
}
|
|
28493
|
-
|
|
28494
|
-
if (jsonData[key]) {
|
|
28495
|
-
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
28496
|
-
jsonData[key].push(value);
|
|
28497
|
-
} else {
|
|
28498
|
-
jsonData[key] = value;
|
|
28499
|
-
}
|
|
28500
|
-
});
|
|
28501
|
-
return jsonData;
|
|
28502
|
-
};
|
|
28503
|
-
|
|
28504
28477
|
// [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
|
|
28505
28478
|
#updateElement(el, value) {
|
|
28506
28479
|
const tagName = el.tagName.toUpperCase();
|
|
@@ -28528,21 +28501,98 @@ class nxDiv extends HTMLElement {
|
|
|
28528
28501
|
return isChanged;
|
|
28529
28502
|
}
|
|
28530
28503
|
|
|
28504
|
+
// [공통 로직 2] 이벤트 리스너 일괄 등록
|
|
28505
|
+
#refreshListeners() {
|
|
28506
|
+
this.#getElements().forEach(el => {
|
|
28507
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
28508
|
+
el.addEventListener("input", this.#changeHandler);
|
|
28509
|
+
});
|
|
28510
|
+
}
|
|
28511
|
+
|
|
28512
|
+
getData = () => {
|
|
28513
|
+
const jsonData = {};
|
|
28514
|
+
this.#getElements().forEach(el => {
|
|
28515
|
+
const key = el.name;
|
|
28516
|
+
if (!key) return;
|
|
28517
|
+
|
|
28518
|
+
let value;
|
|
28519
|
+
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
28520
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
28521
|
+
let f = el.getAttribute("false-value") || "N";
|
|
28522
|
+
value = el.checked ? t : f;
|
|
28523
|
+
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
28524
|
+
value = el.value;
|
|
28525
|
+
} else {
|
|
28526
|
+
value = el.value;
|
|
28527
|
+
}
|
|
28528
|
+
|
|
28529
|
+
if (jsonData[key]) {
|
|
28530
|
+
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
28531
|
+
jsonData[key].push(value);
|
|
28532
|
+
} else {
|
|
28533
|
+
jsonData[key] = value;
|
|
28534
|
+
}
|
|
28535
|
+
});
|
|
28536
|
+
return jsonData;
|
|
28537
|
+
};
|
|
28538
|
+
|
|
28531
28539
|
// 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
|
|
28540
|
+
clearData = (jsonData = {}) => {
|
|
28541
|
+
this.#refreshListeners();
|
|
28542
|
+
this.#getElements().forEach(el => {
|
|
28543
|
+
const key = el.name;
|
|
28544
|
+
if (!key) return;
|
|
28545
|
+
const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
|
|
28546
|
+
this.#updateElement(el, val);
|
|
28547
|
+
});
|
|
28548
|
+
this.#changed(false);
|
|
28549
|
+
};
|
|
28550
|
+
|
|
28532
28551
|
setData = (jsonData) => {
|
|
28552
|
+
this.#getElements().forEach(el => {
|
|
28553
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
28554
|
+
el.addEventListener("input", this.#changeHandler);
|
|
28555
|
+
});
|
|
28556
|
+
|
|
28533
28557
|
if (!jsonData || typeof jsonData !== 'object') return;
|
|
28534
|
-
this.#refreshListeners();
|
|
28535
28558
|
|
|
28536
28559
|
let bChanged = false;
|
|
28537
28560
|
this.#getElements().forEach(el => {
|
|
28538
28561
|
const key = el.name;
|
|
28562
|
+
//console.log(el.tagName, key, el.name);
|
|
28563
|
+
|
|
28539
28564
|
if (!key || !jsonData.hasOwnProperty(key)) return;
|
|
28540
28565
|
|
|
28541
|
-
|
|
28542
|
-
|
|
28566
|
+
const value = jsonData[key];
|
|
28567
|
+
const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
|
|
28568
|
+
|
|
28569
|
+
if (inputTags.includes(el.tagName)) {
|
|
28570
|
+
if (el.type === "checkbox") {
|
|
28571
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
28572
|
+
el.getAttribute("false-value") || "N";
|
|
28573
|
+
const isChecked = (t === String(value));
|
|
28574
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
28575
|
+
el.checked = isChecked;
|
|
28576
|
+
} else if (el.type === "radio") {
|
|
28577
|
+
const isChecked = (String(el.value) === String(value));
|
|
28578
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
28579
|
+
el.checked = value;
|
|
28580
|
+
} else {
|
|
28581
|
+
if (el.value !== value) bChanged = true;
|
|
28582
|
+
el.value = value;
|
|
28583
|
+
}
|
|
28584
|
+
} else {
|
|
28585
|
+
if (el.textContent !== value) bChanged = true;
|
|
28586
|
+
el.textContent = value;
|
|
28543
28587
|
}
|
|
28544
28588
|
});
|
|
28545
|
-
if (bChanged) this.#changed(
|
|
28589
|
+
if (bChanged) this.#changed(bChanged);
|
|
28590
|
+
};
|
|
28591
|
+
|
|
28592
|
+
clearData = (bChanged) => {
|
|
28593
|
+
|
|
28594
|
+
|
|
28595
|
+
this.#changed(false);
|
|
28546
28596
|
};
|
|
28547
28597
|
|
|
28548
28598
|
initData = (jsonData) => {
|
package/dist/bundle.esm.js
CHANGED
|
@@ -28470,33 +28470,6 @@ class nxDiv extends HTMLElement {
|
|
|
28470
28470
|
return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]", this.#root);
|
|
28471
28471
|
}
|
|
28472
28472
|
|
|
28473
|
-
getData = () => {
|
|
28474
|
-
const jsonData = {};
|
|
28475
|
-
this.#getElements().forEach(el => {
|
|
28476
|
-
const key = el.name;
|
|
28477
|
-
if (!key) return;
|
|
28478
|
-
|
|
28479
|
-
let value;
|
|
28480
|
-
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
28481
|
-
let t = el.getAttribute("true-value") || "Y";
|
|
28482
|
-
let f = el.getAttribute("false-value") || "N";
|
|
28483
|
-
value = el.checked ? t : f;
|
|
28484
|
-
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
28485
|
-
value = el.value;
|
|
28486
|
-
} else {
|
|
28487
|
-
value = el.value;
|
|
28488
|
-
}
|
|
28489
|
-
|
|
28490
|
-
if (jsonData[key]) {
|
|
28491
|
-
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
28492
|
-
jsonData[key].push(value);
|
|
28493
|
-
} else {
|
|
28494
|
-
jsonData[key] = value;
|
|
28495
|
-
}
|
|
28496
|
-
});
|
|
28497
|
-
return jsonData;
|
|
28498
|
-
};
|
|
28499
|
-
|
|
28500
28473
|
// [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
|
|
28501
28474
|
#updateElement(el, value) {
|
|
28502
28475
|
const tagName = el.tagName.toUpperCase();
|
|
@@ -28524,21 +28497,98 @@ class nxDiv extends HTMLElement {
|
|
|
28524
28497
|
return isChanged;
|
|
28525
28498
|
}
|
|
28526
28499
|
|
|
28500
|
+
// [공통 로직 2] 이벤트 리스너 일괄 등록
|
|
28501
|
+
#refreshListeners() {
|
|
28502
|
+
this.#getElements().forEach(el => {
|
|
28503
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
28504
|
+
el.addEventListener("input", this.#changeHandler);
|
|
28505
|
+
});
|
|
28506
|
+
}
|
|
28507
|
+
|
|
28508
|
+
getData = () => {
|
|
28509
|
+
const jsonData = {};
|
|
28510
|
+
this.#getElements().forEach(el => {
|
|
28511
|
+
const key = el.name;
|
|
28512
|
+
if (!key) return;
|
|
28513
|
+
|
|
28514
|
+
let value;
|
|
28515
|
+
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
28516
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
28517
|
+
let f = el.getAttribute("false-value") || "N";
|
|
28518
|
+
value = el.checked ? t : f;
|
|
28519
|
+
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
28520
|
+
value = el.value;
|
|
28521
|
+
} else {
|
|
28522
|
+
value = el.value;
|
|
28523
|
+
}
|
|
28524
|
+
|
|
28525
|
+
if (jsonData[key]) {
|
|
28526
|
+
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
28527
|
+
jsonData[key].push(value);
|
|
28528
|
+
} else {
|
|
28529
|
+
jsonData[key] = value;
|
|
28530
|
+
}
|
|
28531
|
+
});
|
|
28532
|
+
return jsonData;
|
|
28533
|
+
};
|
|
28534
|
+
|
|
28527
28535
|
// 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
|
|
28536
|
+
clearData = (jsonData = {}) => {
|
|
28537
|
+
this.#refreshListeners();
|
|
28538
|
+
this.#getElements().forEach(el => {
|
|
28539
|
+
const key = el.name;
|
|
28540
|
+
if (!key) return;
|
|
28541
|
+
const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
|
|
28542
|
+
this.#updateElement(el, val);
|
|
28543
|
+
});
|
|
28544
|
+
this.#changed(false);
|
|
28545
|
+
};
|
|
28546
|
+
|
|
28528
28547
|
setData = (jsonData) => {
|
|
28548
|
+
this.#getElements().forEach(el => {
|
|
28549
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
28550
|
+
el.addEventListener("input", this.#changeHandler);
|
|
28551
|
+
});
|
|
28552
|
+
|
|
28529
28553
|
if (!jsonData || typeof jsonData !== 'object') return;
|
|
28530
|
-
this.#refreshListeners();
|
|
28531
28554
|
|
|
28532
28555
|
let bChanged = false;
|
|
28533
28556
|
this.#getElements().forEach(el => {
|
|
28534
28557
|
const key = el.name;
|
|
28558
|
+
//console.log(el.tagName, key, el.name);
|
|
28559
|
+
|
|
28535
28560
|
if (!key || !jsonData.hasOwnProperty(key)) return;
|
|
28536
28561
|
|
|
28537
|
-
|
|
28538
|
-
|
|
28562
|
+
const value = jsonData[key];
|
|
28563
|
+
const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
|
|
28564
|
+
|
|
28565
|
+
if (inputTags.includes(el.tagName)) {
|
|
28566
|
+
if (el.type === "checkbox") {
|
|
28567
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
28568
|
+
el.getAttribute("false-value") || "N";
|
|
28569
|
+
const isChecked = (t === String(value));
|
|
28570
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
28571
|
+
el.checked = isChecked;
|
|
28572
|
+
} else if (el.type === "radio") {
|
|
28573
|
+
const isChecked = (String(el.value) === String(value));
|
|
28574
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
28575
|
+
el.checked = value;
|
|
28576
|
+
} else {
|
|
28577
|
+
if (el.value !== value) bChanged = true;
|
|
28578
|
+
el.value = value;
|
|
28579
|
+
}
|
|
28580
|
+
} else {
|
|
28581
|
+
if (el.textContent !== value) bChanged = true;
|
|
28582
|
+
el.textContent = value;
|
|
28539
28583
|
}
|
|
28540
28584
|
});
|
|
28541
|
-
if (bChanged) this.#changed(
|
|
28585
|
+
if (bChanged) this.#changed(bChanged);
|
|
28586
|
+
};
|
|
28587
|
+
|
|
28588
|
+
clearData = (bChanged) => {
|
|
28589
|
+
|
|
28590
|
+
|
|
28591
|
+
this.#changed(false);
|
|
28542
28592
|
};
|
|
28543
28593
|
|
|
28544
28594
|
initData = (jsonData) => {
|
package/dist/nx/_nxDiv.js
CHANGED
|
@@ -41,33 +41,6 @@ export class nxDiv extends HTMLElement {
|
|
|
41
41
|
return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]", this.#root);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
getData = () => {
|
|
45
|
-
const jsonData = {};
|
|
46
|
-
this.#getElements().forEach(el => {
|
|
47
|
-
const key = el.name;
|
|
48
|
-
if (!key) return;
|
|
49
|
-
|
|
50
|
-
let value;
|
|
51
|
-
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
52
|
-
let t = el.getAttribute("true-value") || "Y";
|
|
53
|
-
let f = el.getAttribute("false-value") || "N";
|
|
54
|
-
value = el.checked ? t : f;
|
|
55
|
-
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
56
|
-
value = el.value;
|
|
57
|
-
} else {
|
|
58
|
-
value = el.value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (jsonData[key]) {
|
|
62
|
-
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
63
|
-
jsonData[key].push(value);
|
|
64
|
-
} else {
|
|
65
|
-
jsonData[key] = value;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return jsonData;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
44
|
// [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
|
|
72
45
|
#updateElement(el, value) {
|
|
73
46
|
const tagName = el.tagName.toUpperCase();
|
|
@@ -95,21 +68,98 @@ export class nxDiv extends HTMLElement {
|
|
|
95
68
|
return isChanged;
|
|
96
69
|
}
|
|
97
70
|
|
|
71
|
+
// [공통 로직 2] 이벤트 리스너 일괄 등록
|
|
72
|
+
#refreshListeners() {
|
|
73
|
+
this.#getElements().forEach(el => {
|
|
74
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
75
|
+
el.addEventListener("input", this.#changeHandler);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getData = () => {
|
|
80
|
+
const jsonData = {};
|
|
81
|
+
this.#getElements().forEach(el => {
|
|
82
|
+
const key = el.name;
|
|
83
|
+
if (!key) return;
|
|
84
|
+
|
|
85
|
+
let value;
|
|
86
|
+
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
87
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
88
|
+
let f = el.getAttribute("false-value") || "N";
|
|
89
|
+
value = el.checked ? t : f;
|
|
90
|
+
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
91
|
+
value = el.value;
|
|
92
|
+
} else {
|
|
93
|
+
value = el.value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (jsonData[key]) {
|
|
97
|
+
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
98
|
+
jsonData[key].push(value);
|
|
99
|
+
} else {
|
|
100
|
+
jsonData[key] = value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return jsonData;
|
|
104
|
+
};
|
|
105
|
+
|
|
98
106
|
// 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
|
|
107
|
+
clearData = (jsonData = {}) => {
|
|
108
|
+
this.#refreshListeners();
|
|
109
|
+
this.#getElements().forEach(el => {
|
|
110
|
+
const key = el.name;
|
|
111
|
+
if (!key) return;
|
|
112
|
+
const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
|
|
113
|
+
this.#updateElement(el, val);
|
|
114
|
+
});
|
|
115
|
+
this.#changed(false);
|
|
116
|
+
};
|
|
117
|
+
|
|
99
118
|
setData = (jsonData) => {
|
|
119
|
+
this.#getElements().forEach(el => {
|
|
120
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
121
|
+
el.addEventListener("input", this.#changeHandler);
|
|
122
|
+
});
|
|
123
|
+
|
|
100
124
|
if (!jsonData || typeof jsonData !== 'object') return;
|
|
101
|
-
this.#refreshListeners();
|
|
102
125
|
|
|
103
126
|
let bChanged = false;
|
|
104
127
|
this.#getElements().forEach(el => {
|
|
105
128
|
const key = el.name;
|
|
129
|
+
//console.log(el.tagName, key, el.name);
|
|
130
|
+
|
|
106
131
|
if (!key || !jsonData.hasOwnProperty(key)) return;
|
|
107
132
|
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
const value = jsonData[key];
|
|
134
|
+
const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
|
|
135
|
+
|
|
136
|
+
if (inputTags.includes(el.tagName)) {
|
|
137
|
+
if (el.type === "checkbox") {
|
|
138
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
139
|
+
let f = el.getAttribute("false-value") || "N";
|
|
140
|
+
const isChecked = (t === String(value));
|
|
141
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
142
|
+
el.checked = isChecked;
|
|
143
|
+
} else if (el.type === "radio") {
|
|
144
|
+
const isChecked = (String(el.value) === String(value));
|
|
145
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
146
|
+
el.checked = value;
|
|
147
|
+
} else {
|
|
148
|
+
if (el.value !== value) bChanged = true;
|
|
149
|
+
el.value = value;
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
if (el.textContent !== value) bChanged = true;
|
|
153
|
+
el.textContent = value;
|
|
110
154
|
}
|
|
111
155
|
});
|
|
112
|
-
if (bChanged) this.#changed(
|
|
156
|
+
if (bChanged) this.#changed(bChanged);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
clearData = (bChanged) => {
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
this.#changed(false);
|
|
113
163
|
};
|
|
114
164
|
|
|
115
165
|
initData = (jsonData) => {
|
package/package.json
CHANGED
package/src/nx/_nxDiv.js
CHANGED
|
@@ -41,33 +41,6 @@ export class nxDiv extends HTMLElement {
|
|
|
41
41
|
return ninegrid.querySelectorAll("input[name], textarea[name], select[name], nx-editor[name]", this.#root);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
getData = () => {
|
|
45
|
-
const jsonData = {};
|
|
46
|
-
this.#getElements().forEach(el => {
|
|
47
|
-
const key = el.name;
|
|
48
|
-
if (!key) return;
|
|
49
|
-
|
|
50
|
-
let value;
|
|
51
|
-
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
52
|
-
let t = el.getAttribute("true-value") || "Y";
|
|
53
|
-
let f = el.getAttribute("false-value") || "N";
|
|
54
|
-
value = el.checked ? t : f;
|
|
55
|
-
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
56
|
-
value = el.value;
|
|
57
|
-
} else {
|
|
58
|
-
value = el.value;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (jsonData[key]) {
|
|
62
|
-
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
63
|
-
jsonData[key].push(value);
|
|
64
|
-
} else {
|
|
65
|
-
jsonData[key] = value;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
return jsonData;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
44
|
// [공통 로직 1] 특정 요소에 값을 쓰거나 초기화하는 핵심 함수
|
|
72
45
|
#updateElement(el, value) {
|
|
73
46
|
const tagName = el.tagName.toUpperCase();
|
|
@@ -95,21 +68,98 @@ export class nxDiv extends HTMLElement {
|
|
|
95
68
|
return isChanged;
|
|
96
69
|
}
|
|
97
70
|
|
|
71
|
+
// [공통 로직 2] 이벤트 리스너 일괄 등록
|
|
72
|
+
#refreshListeners() {
|
|
73
|
+
this.#getElements().forEach(el => {
|
|
74
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
75
|
+
el.addEventListener("input", this.#changeHandler);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
getData = () => {
|
|
80
|
+
const jsonData = {};
|
|
81
|
+
this.#getElements().forEach(el => {
|
|
82
|
+
const key = el.name;
|
|
83
|
+
if (!key) return;
|
|
84
|
+
|
|
85
|
+
let value;
|
|
86
|
+
if (el.tagName === "INPUT" && el.type === "checkbox") {
|
|
87
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
88
|
+
let f = el.getAttribute("false-value") || "N";
|
|
89
|
+
value = el.checked ? t : f;
|
|
90
|
+
} else if (el.tagName === "INPUT" && el.type === "radio") {
|
|
91
|
+
value = el.value;
|
|
92
|
+
} else {
|
|
93
|
+
value = el.value;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (jsonData[key]) {
|
|
97
|
+
if (!Array.isArray(jsonData[key])) jsonData[key] = [jsonData[key]];
|
|
98
|
+
jsonData[key].push(value);
|
|
99
|
+
} else {
|
|
100
|
+
jsonData[key] = value;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
return jsonData;
|
|
104
|
+
};
|
|
105
|
+
|
|
98
106
|
// 파라미터가 있으면 해당 값으로, 없으면 전체 공백 초기화
|
|
107
|
+
clearData = (jsonData = {}) => {
|
|
108
|
+
this.#refreshListeners();
|
|
109
|
+
this.#getElements().forEach(el => {
|
|
110
|
+
const key = el.name;
|
|
111
|
+
if (!key) return;
|
|
112
|
+
const val = (jsonData && jsonData[key] !== undefined) ? jsonData[key] : "";
|
|
113
|
+
this.#updateElement(el, val);
|
|
114
|
+
});
|
|
115
|
+
this.#changed(false);
|
|
116
|
+
};
|
|
117
|
+
|
|
99
118
|
setData = (jsonData) => {
|
|
119
|
+
this.#getElements().forEach(el => {
|
|
120
|
+
el.removeEventListener("input", this.#changeHandler);
|
|
121
|
+
el.addEventListener("input", this.#changeHandler);
|
|
122
|
+
});
|
|
123
|
+
|
|
100
124
|
if (!jsonData || typeof jsonData !== 'object') return;
|
|
101
|
-
this.#refreshListeners();
|
|
102
125
|
|
|
103
126
|
let bChanged = false;
|
|
104
127
|
this.#getElements().forEach(el => {
|
|
105
128
|
const key = el.name;
|
|
129
|
+
//console.log(el.tagName, key, el.name);
|
|
130
|
+
|
|
106
131
|
if (!key || !jsonData.hasOwnProperty(key)) return;
|
|
107
132
|
|
|
108
|
-
|
|
109
|
-
|
|
133
|
+
const value = jsonData[key];
|
|
134
|
+
const inputTags = ["INPUT", "TEXTAREA", "SELECT", "NX-EDITOR"];
|
|
135
|
+
|
|
136
|
+
if (inputTags.includes(el.tagName)) {
|
|
137
|
+
if (el.type === "checkbox") {
|
|
138
|
+
let t = el.getAttribute("true-value") || "Y";
|
|
139
|
+
let f = el.getAttribute("false-value") || "N";
|
|
140
|
+
const isChecked = (t === String(value));
|
|
141
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
142
|
+
el.checked = isChecked;
|
|
143
|
+
} else if (el.type === "radio") {
|
|
144
|
+
const isChecked = (String(el.value) === String(value));
|
|
145
|
+
if (el.checked !== isChecked) bChanged = true;
|
|
146
|
+
el.checked = value;
|
|
147
|
+
} else {
|
|
148
|
+
if (el.value !== value) bChanged = true;
|
|
149
|
+
el.value = value;
|
|
150
|
+
}
|
|
151
|
+
} else {
|
|
152
|
+
if (el.textContent !== value) bChanged = true;
|
|
153
|
+
el.textContent = value;
|
|
110
154
|
}
|
|
111
155
|
});
|
|
112
|
-
if (bChanged) this.#changed(
|
|
156
|
+
if (bChanged) this.#changed(bChanged);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
clearData = (bChanged) => {
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
this.#changed(false);
|
|
113
163
|
};
|
|
114
164
|
|
|
115
165
|
initData = (jsonData) => {
|