zet-lib 1.0.56 → 1.0.57
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 +666 -649
- package/lib/zRoleRouter.js +1 -3
- package/lib/zRoute.js +52 -1
- package/package.json +1 -1
package/lib/zRoleRouter.js
CHANGED
|
@@ -466,9 +466,7 @@ const js = `<script>
|
|
|
466
466
|
table : e.target.getAttribute('data-table')
|
|
467
467
|
},((data) => {
|
|
468
468
|
toastrForm(data);
|
|
469
|
-
|
|
470
|
-
setTimeout(() => {location.href= '';},2000);
|
|
471
|
-
}
|
|
469
|
+
$(".btn-close").click();
|
|
472
470
|
}))
|
|
473
471
|
})
|
|
474
472
|
</script>
|
package/lib/zRoute.js
CHANGED
|
@@ -2494,6 +2494,7 @@ zRoute.moduleLib = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
2494
2494
|
|
|
2495
2495
|
/*
|
|
2496
2496
|
Generate javascript code into runtime folder
|
|
2497
|
+
make it static js
|
|
2497
2498
|
*/
|
|
2498
2499
|
zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
2499
2500
|
//add additional script
|
|
@@ -2510,6 +2511,8 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
2510
2511
|
const MYMODELS = myCache.get('MYMODELS')
|
|
2511
2512
|
let widgets = MYMODEL.widgets,
|
|
2512
2513
|
widgetsArray = Object.keys(widgets) || []
|
|
2514
|
+
|
|
2515
|
+
let hasTabs = MYMODEL.hasOwnProperty('hasTabs') ? MYMODEL.hasTabs : false
|
|
2513
2516
|
let hasDatePicker = false
|
|
2514
2517
|
let hasNumber = false
|
|
2515
2518
|
let hasClockPicker = false
|
|
@@ -2658,6 +2661,39 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
2658
2661
|
}
|
|
2659
2662
|
}
|
|
2660
2663
|
|
|
2664
|
+
//if this module has tabs than call access
|
|
2665
|
+
if (hasTabs) {
|
|
2666
|
+
scriptForm += `$(()=> {
|
|
2667
|
+
ajaxPost('/ztab-access',{table:"${MYMODEL.table}"},(data)=> {
|
|
2668
|
+
let dataTabs = ${MYMODEL.hasOwnProperty('tabs') ? JSON.stringify(MYMODEL.tabs) : []};
|
|
2669
|
+
let viewAccess = data.view || [];
|
|
2670
|
+
let createAccess = data.create || [];
|
|
2671
|
+
let editAccess = data.edit || [];
|
|
2672
|
+
let deleteAccess = data.delete || [];
|
|
2673
|
+
dataTabs.map((_, index)=> {
|
|
2674
|
+
if(!deleteAccess[index]) {
|
|
2675
|
+
setTimeout(function () {$("#arr"+index).find(".icons-danger").remove();},1000)
|
|
2676
|
+
}
|
|
2677
|
+
if(!editAccess[index]) {
|
|
2678
|
+
$("#arr"+index).find("input").attr("disabled",true);
|
|
2679
|
+
$("#arr"+index).find("select").attr("disabled",true);
|
|
2680
|
+
}
|
|
2681
|
+
if(!createAccess[index]) {
|
|
2682
|
+
$("#arr"+index).find(".btn-plus").remove();
|
|
2683
|
+
$("#arr"+index).find("input").attr("disabled",true);
|
|
2684
|
+
$("#arr"+index).find("select").attr("disabled",true);
|
|
2685
|
+
}
|
|
2686
|
+
if(!viewAccess[index]) {
|
|
2687
|
+
$("#arr"+index).remove();
|
|
2688
|
+
$(".arr"+index).remove();
|
|
2689
|
+
}
|
|
2690
|
+
})
|
|
2691
|
+
});
|
|
2692
|
+
})
|
|
2693
|
+
|
|
2694
|
+
`
|
|
2695
|
+
}
|
|
2696
|
+
|
|
2661
2697
|
defaultScript = `${Util.newLine} $(function () {
|
|
2662
2698
|
$(".isfile").each(function (index, value) {
|
|
2663
2699
|
let filename = $(this).attr("data-filename") || "";
|
|
@@ -3164,6 +3200,21 @@ zRoute.buildForm = async (req, res) => {
|
|
|
3164
3200
|
res.send(tabledata)
|
|
3165
3201
|
}
|
|
3166
3202
|
|
|
3203
|
+
/*
|
|
3204
|
+
get tab access from table
|
|
3205
|
+
*/
|
|
3206
|
+
zRoute.tabAccess = async (req, res) => {
|
|
3207
|
+
try {
|
|
3208
|
+
let table = req.body.table
|
|
3209
|
+
let roles = myCache.get('ROLES')
|
|
3210
|
+
let roleId = res.locals.roleId
|
|
3211
|
+
let tabs = roles[roleId].tabs[table] || []
|
|
3212
|
+
res.json(tabs)
|
|
3213
|
+
} catch (e) {
|
|
3214
|
+
console.log(e)
|
|
3215
|
+
}
|
|
3216
|
+
}
|
|
3217
|
+
|
|
3167
3218
|
zRoute.buildFileModel = (json, index = 0) => {
|
|
3168
3219
|
//let text = `module.exports = { ${Util.newLine}`;
|
|
3169
3220
|
let text = ''
|
|
@@ -3351,7 +3402,7 @@ zRoute.modelsCache = async () => {
|
|
|
3351
3402
|
}
|
|
3352
3403
|
} catch (e) {
|
|
3353
3404
|
//debug(req,res,e.toString());
|
|
3354
|
-
console.log('modelsCache :', e
|
|
3405
|
+
console.log('modelsCache :', e + '')
|
|
3355
3406
|
}
|
|
3356
3407
|
|
|
3357
3408
|
return obj
|