Skip to content

Commit 79c93d0

Browse files
committed
1.8.1
1 parent 95d3df5 commit 79c93d0

File tree

1 file changed

+31
-43
lines changed

1 file changed

+31
-43
lines changed

resources/assets/component.js

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var _componentSvg = {
1+
const _componentSvg = {
22
'trash': `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash" viewBox="0 0 16 16">
33
<path d="M5.5 5.5A.5.5 0 0 1 6 6v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm2.5 0a.5.5 0 0 1 .5.5v6a.5.5 0 0 1-1 0V6a.5.5 0 0 1 .5-.5zm3 .5a.5.5 0 0 0-1 0v6a.5.5 0 0 0 1 0V6z"/>
44
<path fill-rule="evenodd" d="M14.5 3a1 1 0 0 1-1 1H13v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V4h-.5a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1H6a1 1 0 0 1 1-1h2a1 1 0 0 1 1 1h3.5a1 1 0 0 1 1 1v1zM4.118 4 4 4.059V13a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1V4.059L11.882 4H4.118zM2.5 3V2h11v1h-11z"/>
@@ -38,7 +38,7 @@ function _componentRequest(url, method = "GET", data = {}, callback = function (
3838
token = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
3939
}
4040
xhr.setRequestHeader("X-CSRF-TOKEN", token);
41-
if (method == 'GET') {
41+
if (method === 'GET') {
4242
xhr.setRequestHeader("Content-type", "application/text;charset=UTF-8");
4343
xhr.responseType = "text";
4444
xhr.send(null);
@@ -48,7 +48,7 @@ function _componentRequest(url, method = "GET", data = {}, callback = function (
4848
xhr.send(data);
4949
}
5050
xhr.onreadystatechange = function () {
51-
if (xhr.readyState == xhr.DONE && xhr.status == 200) {
51+
if (xhr.readyState === xhr.DONE && xhr.status === 200) {
5252
var response = xhr.response;
5353
callback(response);
5454
}
@@ -107,7 +107,7 @@ class ComponentDot {
107107
let selected_dom = '';
108108
let select_dom = '';
109109
for (let i in select) {
110-
if (selected.indexOf(parseInt(i)) != -1) {
110+
if (selected.indexOf(parseInt(i)) !== -1) {
111111
selected_dom += `<div class='dlp dlp-text dlp-label' data-id='${i}' title="${select[i]}">${select[i]}</div>`;
112112
continue;
113113
}
@@ -143,34 +143,34 @@ class ComponentDot {
143143

144144
tagCal(cdom, operate) {
145145
let id = parseInt(cdom.getAttribute('data-id'));
146-
if (operate == this.MODE.insert) {
147-
if (this.select_data.indexOf(id) == -1) {
146+
if (operate === this.MODE.insert) {
147+
if (this.select_data.indexOf(id) === -1) {
148148
this.select_data.push(id);
149149
this.selectInputDOM.value = JSON.stringify(this.select_data);
150150
}
151-
if (this.selected_data.indexOf(id) == -1 && this.insert_data.indexOf(id) == -1) {
151+
if (this.selected_data.indexOf(id) === -1 && this.insert_data.indexOf(id) === -1) {
152152
this.insert_data.push(id);
153153
this.insertInputDOM.value = JSON.stringify(this.insert_data);
154154
}
155155
let index = this.delete_data.indexOf(id);
156-
if (index != -1) {
156+
if (index !== -1) {
157157
this.delete_data.splice(index, 1);
158158
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
159159
}
160160
return;
161161
}
162-
if (operate == this.MODE.delete) {
162+
if (operate === this.MODE.delete) {
163163
let index = this.select_data.indexOf(id);
164-
if (index != -1) {
164+
if (index !== -1) {
165165
this.select_data.splice(index, 1);
166166
this.selectInputDOM.value = JSON.stringify(this.select_data);
167167
}
168-
if (this.selected_data.indexOf(id) != -1 && this.delete_data.indexOf(id) == -1) {
168+
if (this.selected_data.indexOf(id) !== -1 && this.delete_data.indexOf(id) === -1) {
169169
this.delete_data.push(id);
170170
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
171171
}
172172
index = this.insert_data.indexOf(id);
173-
if (index != -1) {
173+
if (index !== -1) {
174174
this.insert_data.splice(index, 1);
175175
this.insertInputDOM.value = JSON.stringify(this.insert_data);
176176
}
@@ -181,11 +181,11 @@ class ComponentDot {
181181
var object = this;
182182
document.querySelector(`#${this.name} .dot-search`).addEventListener('input', function () {
183183
let search = this.value;
184-
if (search == '') {
184+
if (search === '') {
185185
return;
186186
}
187187
for (let element of object.CONTENT_DOM.getElementsByClassName("dlp-label")) {
188-
if (element.innerText.indexOf(search) != -1) {
188+
if (element.innerText.indexOf(search) !== -1) {
189189
object.CONTENT_DOM.insertBefore(element, object.CONTENT_DOM.firstChild);
190190
}
191191
}
@@ -332,10 +332,8 @@ class ComponentCascadeDot {
332332
});
333333
this.selectToChildren(stack + 1, data.nodes);
334334
}
335-
if (Array.isArray(data.parentNodes)) {
336-
for (let stack in data.parentNodes) {
337-
this.selectToParent(data.parentNodes[stack], parseInt(stack), data.parentNodes[stack - 1]);
338-
}
335+
if (Array.isArray(data.parentNodes) && data.parentNodes.length>0) {
336+
this.selectToParent(data.parentNodes);
339337
}
340338
}
341339

@@ -352,29 +350,19 @@ class ComponentCascadeDot {
352350
this.SELECTED_DOM.append(div);
353351
}
354352

355-
selectToParent(node, stack, parent_node, checked) {
353+
selectToParent(nodes) {
354+
let stack = nodes.length - 1;
355+
let node = nodes.pop();
356+
let parentNode = nodes[stack-1];
356357
let currentStackDocuments = this.STACKS[stack].childNodes;
357358
currentStackDocuments.forEach((D, index) => {
358-
/*if (checked == 'true') {
359-
if (node == parseInt(D.getAttribute('data-id'))) {
360-
let check = false;
361-
this.STACKS[stack + 1].childNodes.forEach((D) => {
362-
if (D.querySelector('i')) {
363-
check = true;
364-
}
365-
});
366-
!check && D.querySelector('i') != null && D.querySelector('i').remove();
367-
}
368-
return;
369-
}*/
370-
let parents = JSON.parse(D.getAttribute('data-parent-nodes-id'));
359+
let parents = this.dimensional_data[stack][index].parentNodes;
371360
currentStackDocuments[index].classList.remove('dlp-label-silence');
372-
if (parents.length > 0 && (parents[stack - 1] != parent_node)) {
361+
if (parents.length > 0 && (parents[stack - 1] !== parentNode)) {
373362
let D = currentStackDocuments[index];
374363
D.classList.add('dlp-label-silence');
375364
}
376-
if (node == parseInt(D.getAttribute('data-id'))) {
377-
if (D.getAttribute('checked') == 'true' || (D.querySelector('i') instanceof HTMLElement)) return;
365+
if (node === parseInt(D.getAttribute('data-id'))) {
378366
D.insertAdjacentHTML('beforeend', `<i>${_componentSvg.check_circle}</i>`);
379367
}
380368
});
@@ -405,34 +393,34 @@ class ComponentCascadeDot {
405393
}
406394

407395
tagCal(id, operate) {
408-
if (operate == this.MODE.insert) {
409-
if (this.select_data.indexOf(id) == -1) {
396+
if (operate === this.MODE.insert) {
397+
if (this.select_data.indexOf(id) === -1) {
410398
this.select_data.push(id);
411399
this.selectInputDOM.value = JSON.stringify(this.select_data);
412400
}
413-
if (this.selected_data.indexOf(id) == -1 && this.insert_data.indexOf(id) == -1) {
401+
if (this.selected_data.indexOf(id) === -1 && this.insert_data.indexOf(id) === -1) {
414402
this.insert_data.push(id);
415403
this.insertInputDOM.value = JSON.stringify(this.insert_data);
416404
}
417405
let index = this.delete_data.indexOf(id);
418-
if (index != -1) {
406+
if (index !== -1) {
419407
this.delete_data.splice(index, 1);
420408
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
421409
}
422410
return;
423411
}
424-
if (operate == this.MODE.delete) {
412+
if (operate === this.MODE.delete) {
425413
let index = this.select_data.indexOf(id);
426-
if (index != -1) {
414+
if (index !== -1) {
427415
this.select_data.splice(index, 1);
428416
this.selectInputDOM.value = JSON.stringify(this.select_data);
429417
}
430-
if (this.selected_data.indexOf(id) != -1 && this.delete_data.indexOf(id) == -1) {
418+
if (this.selected_data.indexOf(id) !== -1 && this.delete_data.indexOf(id) === -1) {
431419
this.delete_data.push(id);
432420
this.deleteInputDOM.value = JSON.stringify(this.delete_data);
433421
}
434422
index = this.insert_data.indexOf(id);
435-
if (index != -1) {
423+
if (index !== -1) {
436424
this.insert_data.splice(index, 1);
437425
this.insertInputDOM.value = JSON.stringify(this.insert_data);
438426
}

0 commit comments

Comments
 (0)