zet-lib 1.0.84 → 1.0.86
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 +19 -3
- package/lib/zdataTable.js +26 -5
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -211,6 +211,14 @@ zRoute.post = (req, res, MYMODEL, routeName, body) => {
|
|
|
211
211
|
if (widgetTables[k].name == 'number') {
|
|
212
212
|
item[k] = Util.toNumber(item[k])
|
|
213
213
|
}
|
|
214
|
+
if (widgetTables[k].name == 'dropdown_multi') {
|
|
215
|
+
//console.log(post[routeName][key]);
|
|
216
|
+
let cleaningdm
|
|
217
|
+
if (Array.isArray(item[k])) {
|
|
218
|
+
cleaningdm = item[k] ? item[k].filter((myitem) => myitem) : null
|
|
219
|
+
}
|
|
220
|
+
item[k] = cleaningdm
|
|
221
|
+
}
|
|
214
222
|
if (widgetTables[k].name == 'file' || widgetTables[k].name == 'image') {
|
|
215
223
|
var fileImageName = `${MYMODEL.table}[${key}][${i}][${k}]`
|
|
216
224
|
if (reqfiles && Object.hasOwn(reqfiles, fileImageName)) {
|
|
@@ -302,9 +310,17 @@ zRoute.attributeData = async (res, MYMODEL, obj) => {
|
|
|
302
310
|
res.locals.visibles = visibles
|
|
303
311
|
res.locals.invisibles = invisibles
|
|
304
312
|
res.locals.gridFilter = filter
|
|
305
|
-
res.locals.visiblesObj = visibles.reduce((result, item) => {
|
|
313
|
+
/* res.locals.visiblesObj = visibles.reduce((result, item) => {
|
|
306
314
|
return { ...result, [item]: MYMODEL.labels[item] }
|
|
307
|
-
},
|
|
315
|
+
}, [])*/
|
|
316
|
+
let visiblesObj = []
|
|
317
|
+
visibles.map((item) => {
|
|
318
|
+
visiblesObj.push({
|
|
319
|
+
key: item,
|
|
320
|
+
name: MYMODEL.labels[item],
|
|
321
|
+
})
|
|
322
|
+
})
|
|
323
|
+
res.locals.visiblesObj = visiblesObj
|
|
308
324
|
}
|
|
309
325
|
|
|
310
326
|
/*
|
|
@@ -633,6 +649,7 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
633
649
|
let types = {}
|
|
634
650
|
let dataTable = {}
|
|
635
651
|
let options
|
|
652
|
+
console.log('fields', fields)
|
|
636
653
|
for (let key in fields) {
|
|
637
654
|
let html = ''
|
|
638
655
|
const value = filterObject.hasOwnProperty(key) ? filterObject[key] : ''
|
|
@@ -1578,7 +1595,6 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
|
|
|
1578
1595
|
if (objData.hasOwnProperty('whereArray')) {
|
|
1579
1596
|
whereArray.push(objData['whereArray'])
|
|
1580
1597
|
}
|
|
1581
|
-
|
|
1582
1598
|
whereArray.push({
|
|
1583
1599
|
field: 'company_id',
|
|
1584
1600
|
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}`
|