zet-lib 1.0.85 → 1.0.87
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/lib/zRoute.js +22 -4
- package/lib/zdataTable.js +26 -5
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -304,15 +304,33 @@ zRoute.attributeData = async (res, MYMODEL, obj) => {
|
|
|
304
304
|
filter = null
|
|
305
305
|
}
|
|
306
306
|
attributeData.labels = MYMODEL.labels
|
|
307
|
+
invisibles = invisibles.filter(Util.arrayUnique)
|
|
308
|
+
visibles = visibles.filter(Util.arrayUnique)
|
|
309
|
+
//check custom code
|
|
310
|
+
let customs = []
|
|
311
|
+
for (var key in MYMODEL.widgets) {
|
|
312
|
+
if (MYMODEL.widgets[key].name == 'custom') {
|
|
313
|
+
customs.push(key)
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
if (customs.length) {
|
|
317
|
+
visibles = visibles.filter((item) => !customs.includes(item))
|
|
318
|
+
invisibles = invisibles.filter((item) => !customs.includes(item))
|
|
319
|
+
}
|
|
307
320
|
|
|
308
321
|
res.locals.routeName = routeName
|
|
309
322
|
res.locals.attributeData = attributeData
|
|
310
323
|
res.locals.visibles = visibles
|
|
311
324
|
res.locals.invisibles = invisibles
|
|
312
325
|
res.locals.gridFilter = filter
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
326
|
+
let visiblesObj = []
|
|
327
|
+
visibles.map((item) => {
|
|
328
|
+
visiblesObj.push({
|
|
329
|
+
key: item,
|
|
330
|
+
name: MYMODEL.labels[item],
|
|
331
|
+
})
|
|
332
|
+
})
|
|
333
|
+
res.locals.visiblesObj = visiblesObj
|
|
316
334
|
}
|
|
317
335
|
|
|
318
336
|
/*
|
|
@@ -641,6 +659,7 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
641
659
|
let types = {}
|
|
642
660
|
let dataTable = {}
|
|
643
661
|
let options
|
|
662
|
+
console.log('fields', fields)
|
|
644
663
|
for (let key in fields) {
|
|
645
664
|
let html = ''
|
|
646
665
|
const value = filterObject.hasOwnProperty(key) ? filterObject[key] : ''
|
|
@@ -1586,7 +1605,6 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
|
|
|
1586
1605
|
if (objData.hasOwnProperty('whereArray')) {
|
|
1587
1606
|
whereArray.push(objData['whereArray'])
|
|
1588
1607
|
}
|
|
1589
|
-
|
|
1590
1608
|
whereArray.push({
|
|
1591
1609
|
field: 'company_id',
|
|
1592
1610
|
option: '=',
|
package/lib/zdataTable.js
CHANGED
|
@@ -18,6 +18,7 @@ class dataTable {
|
|
|
18
18
|
this.routeName
|
|
19
19
|
this.types = {}
|
|
20
20
|
this.levels = {}
|
|
21
|
+
this.visiblesKey = visibles.map((item) => item.key)
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
// for filter html
|
|
@@ -31,20 +32,40 @@ class dataTable {
|
|
|
31
32
|
delete obj.TYPES
|
|
32
33
|
this.searchColumns = obj
|
|
33
34
|
}
|
|
35
|
+
set buttons(html) {
|
|
36
|
+
return html
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set buttons2(html) {
|
|
40
|
+
return html
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
get columns() {
|
|
36
44
|
if (this.setColumns) return this.setColumns
|
|
37
45
|
let html = ''
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
if (Array.isArray(this.visibles)) {
|
|
47
|
+
this.visibles.map((item) => {
|
|
48
|
+
html += `<th id="data_${item.key}_label">${item.name || ''}</th>`
|
|
49
|
+
})
|
|
50
|
+
} else {
|
|
51
|
+
for (const key in this.visibles) {
|
|
52
|
+
html += `<th id="data_${key}_label">${this.visibles[key]}</th>`
|
|
53
|
+
}
|
|
40
54
|
}
|
|
55
|
+
|
|
41
56
|
return html
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
get columnsFilter() {
|
|
45
60
|
let html = '<tr class="filters">'
|
|
46
|
-
|
|
47
|
-
|
|
61
|
+
if (Array.isArray(this.visibles)) {
|
|
62
|
+
this.visibles.map((item) => {
|
|
63
|
+
html += `<th id="data_${item.key}_label">${this.searchColumns[item.key]}</th>`
|
|
64
|
+
})
|
|
65
|
+
} else {
|
|
66
|
+
for (const key in this.visibles) {
|
|
67
|
+
html += `<th id="data_${key}">${this.searchColumns[key]}</th>`
|
|
68
|
+
}
|
|
48
69
|
}
|
|
49
70
|
html += '</tr>'
|
|
50
71
|
return html
|
|
@@ -123,7 +144,7 @@ class dataTable {
|
|
|
123
144
|
get scripts() {
|
|
124
145
|
let script = `<script type="text/javascript" src="${this.srcScript}"></script>`
|
|
125
146
|
script += `<script>${Util.newLine}`
|
|
126
|
-
script += `var dataTableFields = ${JSON.stringify(
|
|
147
|
+
script += `var dataTableFields = ${JSON.stringify(this.visiblesKey, null, 2)};${Util.newLine}`
|
|
127
148
|
script += `var dataTableTypes = ${JSON.stringify(this.types, null, 2)};${Util.newLine}`
|
|
128
149
|
script += `var dataTableRoute = "${this.routeName}";${Util.newLine}`
|
|
129
150
|
script += `</script>${Util.newLine}`
|