zet-lib 1.3.31 → 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 +30 -1
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -1139,7 +1139,7 @@ zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
|
|
|
1139
1139
|
break
|
|
1140
1140
|
|
|
1141
1141
|
case 'dropdown_checkbox':
|
|
1142
|
-
myvalue = value ? value.reduce((acc,item)=> `${acc} <u>${item}</u> `, '') : ''
|
|
1142
|
+
myvalue = value ? value.reduce((acc, item) => `${acc} <u>${item}</u> `, '') : ''
|
|
1143
1143
|
break
|
|
1144
1144
|
|
|
1145
1145
|
case 'array':
|
|
@@ -4102,6 +4102,8 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
4102
4102
|
if (results[0].lock == 1) {
|
|
4103
4103
|
throw Error('Data is locked')
|
|
4104
4104
|
} else {
|
|
4105
|
+
//delete all files
|
|
4106
|
+
zRoute.deleteFiles(table, results[0])
|
|
4105
4107
|
await connection.delete({ table: table, where: where })
|
|
4106
4108
|
zRoute.modelsCacheRenew(table, company_id)
|
|
4107
4109
|
}
|
|
@@ -4114,6 +4116,33 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
4114
4116
|
}
|
|
4115
4117
|
}
|
|
4116
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
|
+
|
|
4117
4146
|
//for import
|
|
4118
4147
|
zRoute.import = async (req, res, MYMODEL) => {
|
|
4119
4148
|
const cacheRole = myCache.get('ROLES')[res.locals.roleId].params
|