zet-lib 1.3.30 → 1.3.32
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 +34 -7
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -1138,6 +1138,10 @@ zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
|
|
|
1138
1138
|
myvalue = value ? JSON.stringify(value).replaceAll('","', '", "') : ''
|
|
1139
1139
|
break
|
|
1140
1140
|
|
|
1141
|
+
case 'dropdown_checkbox':
|
|
1142
|
+
myvalue = value ? value.reduce((acc, item) => `${acc} <u>${item}</u> `, '') : ''
|
|
1143
|
+
break
|
|
1144
|
+
|
|
1141
1145
|
case 'array':
|
|
1142
1146
|
myvalue = value ? JSON.stringify(value).replaceAll('","', '", "') : ''
|
|
1143
1147
|
break
|
|
@@ -2174,13 +2178,7 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
|
|
|
2174
2178
|
if (MYMODEL.widgets[key].name == 'datepicker') {
|
|
2175
2179
|
asDate.push(key)
|
|
2176
2180
|
}
|
|
2177
|
-
if (MYMODEL.widgets[key].name == 'dropdown_multi') {
|
|
2178
|
-
asJSONb.push(key)
|
|
2179
|
-
}
|
|
2180
|
-
if (MYMODEL.widgets[key].name == 'dragdrop') {
|
|
2181
|
-
asJSONb.push(key)
|
|
2182
|
-
}
|
|
2183
|
-
if (MYMODEL.widgets[key].name == 'dropdown_checkbox') {
|
|
2181
|
+
if (MYMODEL.widgets[key].name == 'dropdown_multi' || MYMODEL.widgets[key].name == 'dragdrop' || MYMODEL.widgets[key].name == 'dropdown_checkbox') {
|
|
2184
2182
|
asJSONb.push(key)
|
|
2185
2183
|
}
|
|
2186
2184
|
if (MYMODEL.widgets[key].name == 'json_array' || MYMODEL.widgets[key].name == 'array' || MYMODEL.widgets[key].name == 'dropzone') {
|
|
@@ -4104,6 +4102,8 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
4104
4102
|
if (results[0].lock == 1) {
|
|
4105
4103
|
throw Error('Data is locked')
|
|
4106
4104
|
} else {
|
|
4105
|
+
//delete all files
|
|
4106
|
+
zRoute.deleteFiles(table, results[0])
|
|
4107
4107
|
await connection.delete({ table: table, where: where })
|
|
4108
4108
|
zRoute.modelsCacheRenew(table, company_id)
|
|
4109
4109
|
}
|
|
@@ -4116,6 +4116,33 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
4116
4116
|
}
|
|
4117
4117
|
}
|
|
4118
4118
|
|
|
4119
|
+
zRoute.deleteFiles = (table, result) => {
|
|
4120
|
+
try {
|
|
4121
|
+
//check if has files then remove it
|
|
4122
|
+
const MYMODELS = myCache.get('MYMODELS')
|
|
4123
|
+
const MYMODEL = MYMODELS[table]
|
|
4124
|
+
const widgets = MYMODEL.widgets
|
|
4125
|
+
for (let key in widgets) {
|
|
4126
|
+
if (widgets[key].name == 'dropzone') {
|
|
4127
|
+
if (result[key]) {
|
|
4128
|
+
let dir = `${dirRoot}/public/uploads/${table}/${key}/`
|
|
4129
|
+
result[key].map((item) => {
|
|
4130
|
+
fs.remove(dir + item, () => {})
|
|
4131
|
+
})
|
|
4132
|
+
}
|
|
4133
|
+
}
|
|
4134
|
+
if (widgets[key].name == 'image' || widgets[key].name == 'file') {
|
|
4135
|
+
if (result[key]) {
|
|
4136
|
+
let dir = `${dirRoot}/public/uploads/${table}/`
|
|
4137
|
+
fs.remove(dir + result[key], () => {})
|
|
4138
|
+
}
|
|
4139
|
+
}
|
|
4140
|
+
}
|
|
4141
|
+
} catch (e) {
|
|
4142
|
+
console.log(e)
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
|
|
4119
4146
|
//for import
|
|
4120
4147
|
zRoute.import = async (req, res, MYMODEL) => {
|
|
4121
4148
|
const cacheRole = myCache.get('ROLES')[res.locals.roleId].params
|