zet-lib 1.4.24 → 1.4.26
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 +23 -18
- package/lib/zRoute.js +25 -2
- package/package.json +1 -1
package/lib/Util.js
CHANGED
|
@@ -1442,26 +1442,30 @@ Util.tableShowInGrid = (arr, qey, MYMODEL, myCache, companyId) => {
|
|
|
1442
1442
|
arr.map((item) => {
|
|
1443
1443
|
html += `<tr>`;
|
|
1444
1444
|
for (let key in item) {
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1445
|
+
if (mywidget[key]) {
|
|
1446
|
+
if (!mywidget[key].hidden) {
|
|
1447
|
+
var keyFields = key + "Fields";
|
|
1448
|
+
var keyObject = key + "Object";
|
|
1449
|
+
let value = item[key];
|
|
1450
|
+
if (mywidget[key].name == "select") {
|
|
1451
|
+
value = value ? mywidget[key].fields[value] : "";
|
|
1452
|
+
} else if (mywidget[key].name == "relation") {
|
|
1453
|
+
value = value
|
|
1454
|
+
? Util.array_id_to_zname(
|
|
1455
|
+
myCache.get(
|
|
1456
|
+
`${mywidget[key].table}_${MYMODEL.widgets[qey].table}___${key}_${companyId}`
|
|
1457
|
+
)
|
|
1458
|
+
)[value]
|
|
1459
|
+
: "";
|
|
1460
|
+
} else {
|
|
1461
|
+
if (Util.isNumeric(value)) {
|
|
1462
|
+
value = Util.formatNumber(value, ".");
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1466
|
+
html += `<td>${value}</td>`;
|
|
1461
1467
|
}
|
|
1462
1468
|
}
|
|
1463
|
-
|
|
1464
|
-
html += `<td>${value}</td>`;
|
|
1465
1469
|
}
|
|
1466
1470
|
html += `</tr>`;
|
|
1467
1471
|
});
|
|
@@ -1469,6 +1473,7 @@ Util.tableShowInGrid = (arr, qey, MYMODEL, myCache, companyId) => {
|
|
|
1469
1473
|
}
|
|
1470
1474
|
return html;
|
|
1471
1475
|
} catch (e) {
|
|
1476
|
+
console.log(e);
|
|
1472
1477
|
return e + "";
|
|
1473
1478
|
}
|
|
1474
1479
|
};
|
package/lib/zRoute.js
CHANGED
|
@@ -5059,7 +5059,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5059
5059
|
throw Error("Data is locked");
|
|
5060
5060
|
} else {
|
|
5061
5061
|
//delete all files
|
|
5062
|
-
zRoute.deleteFiles(table, results[0]);
|
|
5062
|
+
await zRoute.deleteFiles(table, results[0]);
|
|
5063
5063
|
await connection.delete({ table: table, where: where });
|
|
5064
5064
|
zRoute.modelsCacheRenew(table, company_id);
|
|
5065
5065
|
}
|
|
@@ -5072,7 +5072,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5072
5072
|
}
|
|
5073
5073
|
};
|
|
5074
5074
|
|
|
5075
|
-
zRoute.deleteFiles = (table, result) => {
|
|
5075
|
+
zRoute.deleteFiles = async (table, result) => {
|
|
5076
5076
|
try {
|
|
5077
5077
|
//check if has files then remove it
|
|
5078
5078
|
const MYMODELS = myCache.get("MYMODELS");
|
|
@@ -5093,6 +5093,29 @@ zRoute.deleteFiles = (table, result) => {
|
|
|
5093
5093
|
fs.remove(dir + result[key], () => {});
|
|
5094
5094
|
}
|
|
5095
5095
|
}
|
|
5096
|
+
if (widgets[key].name == "dropbox") {
|
|
5097
|
+
if (result[key]) {
|
|
5098
|
+
let dbx = new Dropbox({
|
|
5099
|
+
accessToken: process.env.DROPBOX_ACCESS_TOKEN,
|
|
5100
|
+
refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
|
|
5101
|
+
clientId: process.env.DROPBOX_CLIENT_ID,
|
|
5102
|
+
clientSecret: process.env.DROPBOX_CLIENT_SECRET,
|
|
5103
|
+
fetch: fetch,
|
|
5104
|
+
});
|
|
5105
|
+
const files = result[key];
|
|
5106
|
+
const dropboxPath = `/${table}/${key}`;
|
|
5107
|
+
for (const file of files) {
|
|
5108
|
+
let filePath = `${dropboxPath}/${file}`;
|
|
5109
|
+
try {
|
|
5110
|
+
await dbx.filesDeleteV2({
|
|
5111
|
+
path: filePath,
|
|
5112
|
+
});
|
|
5113
|
+
} catch (e) {
|
|
5114
|
+
console.log(e);
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5096
5119
|
}
|
|
5097
5120
|
} catch (e) {
|
|
5098
5121
|
console.log(e);
|