zet-lib 1.0.21 → 1.0.23
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/Form.js +7 -7
- package/lib/zPage.js +2 -1
- package/lib/zRoute.js +30 -2
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -371,7 +371,7 @@ Form.field = (obj) => {
|
|
|
371
371
|
}
|
|
372
372
|
let btnAdd = '';
|
|
373
373
|
if (!obj.isAddButton && !obj.viewOnly) {
|
|
374
|
-
btnAdd = `<th><
|
|
374
|
+
btnAdd = `<th><img id="add${obj.id}" src="/assets/icons/plus.svg" class="icons-bg-black boxy-small" ></th>`;
|
|
375
375
|
}
|
|
376
376
|
obj.btnAdd = btnAdd;
|
|
377
377
|
obj.html = html;
|
|
@@ -557,12 +557,12 @@ Form.breadcrumbImport = (routeName) => {
|
|
|
557
557
|
|
|
558
558
|
Form.breadcrumbApproval = (routeName, id) => {
|
|
559
559
|
return Form.breadcrumbs( [
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
560
|
+
{text: LANGUAGE['home'], href: "/dashboard"},
|
|
561
|
+
{text: LANGUAGE['grid_list'],href: "/" + routeName},
|
|
562
|
+
{text: LANGUAGE['update'], href: '/' + routeName + '/update/' + id},
|
|
563
|
+
{text: LANGUAGE['create'],href: '/' + routeName + '/create'},
|
|
564
|
+
{text: "Approval", active: true}
|
|
565
|
+
]);
|
|
566
566
|
}
|
|
567
567
|
|
|
568
568
|
Form.grid = (type, obj) => {
|
package/lib/zPage.js
CHANGED
|
@@ -54,7 +54,7 @@ const csrfProtection = csrf({cookie: true});
|
|
|
54
54
|
const fs = require('fs-extra');
|
|
55
55
|
const qs = require('qs');
|
|
56
56
|
const axios = require('axios');
|
|
57
|
-
const {
|
|
57
|
+
const { connection, Util, io, zCache, myCache, zDebug, zDataTable, moduleLib, zFunction, zFn, zMail, zRoute, zRole} = require('zet-lib');
|
|
58
58
|
|
|
59
59
|
`;
|
|
60
60
|
};
|
|
@@ -159,6 +159,7 @@ zpage.buildLayout = async (obj) => {
|
|
|
159
159
|
minifyCSS:true,
|
|
160
160
|
collapseWhitespace: true
|
|
161
161
|
});
|
|
162
|
+
console.log(dirRoot + "/views/layouts/" + name + ".ejs");
|
|
162
163
|
fs.writeFileSync(dirRoot + "/views/layouts/" + name + ".ejs", html, 'utf-8');
|
|
163
164
|
if (process.env.NODE_ENV === "production") {
|
|
164
165
|
setTimeout(function () {
|
package/lib/zRoute.js
CHANGED
|
@@ -51,6 +51,34 @@ zRoute.ROUTES = () => {
|
|
|
51
51
|
return arr;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
+
//translate render and optimize so javascript can direct inject
|
|
55
|
+
zRoute.renderHTML = (datas)=> {
|
|
56
|
+
let renderBody=renderEnd=bodyHTML=endHTML='';
|
|
57
|
+
if(datas.hasOwnProperty('renderBody')) {
|
|
58
|
+
renderBody = datas.renderBody.replaceAll('/','_').replaceAll('.','_');
|
|
59
|
+
if(myCache.has(renderBody)){
|
|
60
|
+
bodyHTML = myCache.get(renderBody);
|
|
61
|
+
} else {
|
|
62
|
+
bodyHTML = Util.readFile(`${dirRoot}/views/${datas.renderBody}`);
|
|
63
|
+
myCache.set(renderBody, bodyHTML);
|
|
64
|
+
}
|
|
65
|
+
delete datas.renderBody;
|
|
66
|
+
}
|
|
67
|
+
if(datas.hasOwnProperty('renderEnd')) {
|
|
68
|
+
renderEnd = datas.renderEnd.replaceAll('/','_').replaceAll('.','_');
|
|
69
|
+
if(myCache.has(renderEnd)){
|
|
70
|
+
endHTML = myCache.get(renderEnd);
|
|
71
|
+
} else {
|
|
72
|
+
endHTML = Util.readFile(`${dirRoot}/views/${datas.renderEnd}`);
|
|
73
|
+
myCache.set(renderEnd, endHTML);
|
|
74
|
+
}
|
|
75
|
+
delete datas.renderEnd;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
datas.bodyHTML = ejs.render(bodyHTML,datas);
|
|
79
|
+
datas.endHTML = ejs.render(endHTML,datas);
|
|
80
|
+
return datas;
|
|
81
|
+
}
|
|
54
82
|
/*
|
|
55
83
|
Auto updated_at,created_at,company_id,created_by,updated_by
|
|
56
84
|
*/
|
|
@@ -2722,7 +2750,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = "", data = {}) => {
|
|
|
2722
2750
|
trtd += `<td class="td_${key}_${MYMODEL.widgets[keys].table}">${cForm.field(obj)}</td>`;
|
|
2723
2751
|
}
|
|
2724
2752
|
|
|
2725
|
-
trtd += `<td style="vertical-align:top"><span class="
|
|
2753
|
+
trtd += `<td style="vertical-align:top"><span class="icon-small icons-danger ${trash}" title="Delete"><img class="icons-bg-white griddelete icon-image" src="/assets/icons/trash-filled.svg"></span></td></tr>`;
|
|
2726
2754
|
let subname = MYMODEL.table + "_" + keys;
|
|
2727
2755
|
scriptForm += `$("table").on("click", ".${trash}", function () {$(this).closest('tr').remove();});`;
|
|
2728
2756
|
scriptForm += Util.newLine;
|
|
@@ -3312,7 +3340,7 @@ zRoute.makeFunctionsSystem = () => {
|
|
|
3312
3340
|
content += Util.newLine;
|
|
3313
3341
|
}
|
|
3314
3342
|
}
|
|
3315
|
-
let templateSystem = `const {
|
|
3343
|
+
let templateSystem = `const { connection, Util, io, zCache, myCache, zDebug, zDataTable, moduleLib, zFunction, zFn, zMail, zRoute, zRole} = require('zet-lib');
|
|
3316
3344
|
module.exports = (req, res, next) => {`;
|
|
3317
3345
|
let fileSystem = `${dirRoot}/components/zFunctionsSystem.js`;
|
|
3318
3346
|
templateSystem += content;
|