zet-lib 1.0.59 → 1.0.60

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.
Files changed (2) hide show
  1. package/lib/zRoute.js +19 -23
  2. package/package.json +1 -1
package/lib/zRoute.js CHANGED
@@ -1566,29 +1566,25 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
1566
1566
  const columns = Object.prototype.hasOwnProperty.call(objData, 'columns') ? objData.columns : body.columns
1567
1567
  let whereArray = []
1568
1568
  if (objData.hasOwnProperty('whereArray')) {
1569
- if (typeof objData.whereArray === 'object') {
1570
- whereArray = objData.whereArray
1571
- } else if (typeof objData.whereArray) {
1572
- whereArray = objData.whereArray(req, res)
1573
- }
1574
- } else {
1575
- whereArray.push({
1576
- field: 'company_id',
1577
- option: '=',
1578
- value: res.locals.companyId,
1579
- operator: 'AND',
1580
- })
1581
- columns.forEach(function (item) {
1582
- if (item.search.value) {
1583
- whereArray.push({
1584
- field: fields[item.data],
1585
- option: MYMODEL.options[fields[item.data]],
1586
- value: item.search.value,
1587
- operator: 'AND',
1588
- })
1589
- }
1590
- })
1569
+ whereArray.push(objData['whereArray'])
1591
1570
  }
1571
+
1572
+ whereArray.push({
1573
+ field: 'company_id',
1574
+ option: '=',
1575
+ value: res.locals.companyId,
1576
+ operator: 'AND',
1577
+ })
1578
+ columns.forEach(function (item) {
1579
+ if (item.search.value) {
1580
+ whereArray.push({
1581
+ field: fields[item.data],
1582
+ option: MYMODEL.options[fields[item.data]],
1583
+ value: item.search.value,
1584
+ operator: 'AND',
1585
+ })
1586
+ }
1587
+ })
1592
1588
  const orderColumn = fields[body.order[0].column] == 'actionColumn' ? 'id' : fields[body.order[0].column] == 'no' ? 'id' : fields[body.order[0].column] == 'actionColum' ? 'id' : fields[body.order[0].column]
1593
1589
  const rows = await connection.results({
1594
1590
  select: select,
@@ -1604,7 +1600,7 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
1604
1600
  whereArray: whereArray,
1605
1601
  })
1606
1602
  let datas = []
1607
- const zRole = objData.zRole || {}
1603
+ const zRole = objData.zRole || require('./zRole')
1608
1604
  const levels = objData.hasOwnProperty('levels') ? objData.levels : zRole.myLevel(req, res, MYMODEL.table)
1609
1605
  if (objData.hasOwnProperty('datas')) {
1610
1606
  datas = objData.datas(body, rows, fields, relations, levels)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"