zet-lib 1.0.85 → 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 CHANGED
@@ -310,9 +310,17 @@ zRoute.attributeData = async (res, MYMODEL, obj) => {
310
310
  res.locals.visibles = visibles
311
311
  res.locals.invisibles = invisibles
312
312
  res.locals.gridFilter = filter
313
- res.locals.visiblesObj = visibles.reduce((result, item) => {
313
+ /* res.locals.visiblesObj = visibles.reduce((result, item) => {
314
314
  return { ...result, [item]: MYMODEL.labels[item] }
315
- }, {})
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
316
324
  }
317
325
 
318
326
  /*
@@ -641,6 +649,7 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
641
649
  let types = {}
642
650
  let dataTable = {}
643
651
  let options
652
+ console.log('fields', fields)
644
653
  for (let key in fields) {
645
654
  let html = ''
646
655
  const value = filterObject.hasOwnProperty(key) ? filterObject[key] : ''
@@ -1586,7 +1595,6 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
1586
1595
  if (objData.hasOwnProperty('whereArray')) {
1587
1596
  whereArray.push(objData['whereArray'])
1588
1597
  }
1589
-
1590
1598
  whereArray.push({
1591
1599
  field: 'company_id',
1592
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
- for (const key in this.visibles) {
39
- html += `<th id="data_${key}_label">${this.visibles[key]}</th>`
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
- for (const key in this.visibles) {
47
- html += `<th id="data_${key}">${this.searchColumns[key]}</th>`
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(Object.keys(this.visibles, null, 2))};${Util.newLine}`
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}`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.85",
3
+ "version": "1.0.86",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"