zet-lib 1.3.15 → 1.3.17

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/Util.js CHANGED
@@ -1310,4 +1310,33 @@ Util.terbilang = (nilai) => {
1310
1310
  return penyimpanan
1311
1311
  }
1312
1312
 
1313
+ Util.tableShowInGrid = (arr) => {
1314
+ try {
1315
+ if (typeof arr != 'object') {
1316
+ arr = []
1317
+ }
1318
+ arr = arr || []
1319
+ let html = ''
1320
+ if (arr.length > 0) {
1321
+ html += `<table class="table table-sm table-striped table-bordered table-hover">`
1322
+ let json = arr[0]
1323
+ arr.map((item) => {
1324
+ html += `<tr>`
1325
+ for (let key in item) {
1326
+ let value = item[key]
1327
+ if (Util.isNumeric(value)) {
1328
+ value = Util.formatNumber(value, '.')
1329
+ }
1330
+ html += `<td>${value}</td>`
1331
+ }
1332
+ html += `</tr>`
1333
+ })
1334
+ html += `</table>`
1335
+ }
1336
+ return html
1337
+ } catch (e) {
1338
+ return e + ''
1339
+ }
1340
+ }
1341
+
1313
1342
  module.exports = Util
package/lib/zRoute.js CHANGED
@@ -1089,6 +1089,10 @@ zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
1089
1089
  myvalue = value ? JSON.stringify(value).replaceAll('","', '", "') : ''
1090
1090
  break
1091
1091
 
1092
+ case 'table':
1093
+ myvalue = Util.tableShowInGrid(value)
1094
+ break
1095
+
1092
1096
  default:
1093
1097
  value = value || ''
1094
1098
  myvalue = value.length > 50 ? value.substring(0, 50) : value
@@ -1985,7 +1989,7 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
1985
1989
  let buttons = objData.hasOwnProperty('actionButtons') ? objData.actionButtons(levels, row, MYMODEL.table) : zRoute.actionButtons(levels, row, MYMODEL.table)
1986
1990
  arr.push(buttons)
1987
1991
  } else {
1988
- let data = objData.hasOwnProperty('dataTableData') ? objData.dataTableData(item, row[item], MYMODEL, relations) : zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id)
1992
+ let data = objData.hasOwnProperty('dataTableData') ? objData.dataTableData(item, row[item], MYMODEL, relations, row.id) : zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id)
1989
1993
  arr.push(data)
1990
1994
  }
1991
1995
  })
@@ -2013,6 +2017,7 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
2013
2017
  try {
2014
2018
  actionButtonsFn = actionButtonsFn || function () {}
2015
2019
  const relations = await zRoute.relations(req, res, MYMODEL.table)
2020
+ //console.log(JSON.stringify(relations))
2016
2021
  const body = req.body
2017
2022
  const fields = body.fields
2018
2023
  const select = Util.selectParser(fields, MYMODEL)
@@ -2113,7 +2118,8 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
2113
2118
  let buttons = !actionButtonsFn(levels, row, MYMODEL.table) ? zRoute.actionButtons(levels, row, MYMODEL.table) : actionButtonsFn(levels, row, MYMODEL.table)
2114
2119
  arr.push(buttons)
2115
2120
  } else {
2116
- arr.push(zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id))
2121
+ let data = objData.hasOwnProperty('dataTableData') ? objData.dataTableData(item, row[item], MYMODEL, relations) : zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id)
2122
+ arr.push(data)
2117
2123
  }
2118
2124
  })
2119
2125
  datas.push(arr)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zet-lib",
3
- "version": "1.3.15",
3
+ "version": "1.3.17",
4
4
  "description": "zet is a library that part of zet generator.",
5
5
  "engines": {
6
6
  "node": ">=18"