zet-lib 1.3.34 → 1.3.36
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 +15 -1
- package/lib/moduleLib.js +24 -0
- package/lib/zAppRouter.js +31 -0
- package/lib/zRole.js +1 -1
- package/lib/zRoute.js +13 -3
- package/lib/zdataTable.js +18 -1
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -968,9 +968,23 @@ Form.modal = (obj, LANGUAGE = {}) => {
|
|
|
968
968
|
</div>
|
|
969
969
|
</div>
|
|
970
970
|
</div>
|
|
971
|
+
</div>`
|
|
972
|
+
let modalFields4 = `
|
|
973
|
+
<div class="modal fade" id="grid-delete-all" tabindex="-1" aria-labelledby="grid-delete-all-label" aria-hidden="true">
|
|
974
|
+
<div class="modal-dialog">
|
|
975
|
+
<div class="modal-content">
|
|
976
|
+
<div class="modal-header">
|
|
977
|
+
<h1 class="modal-title fs-5">Delete selected data</h1>
|
|
978
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
979
|
+
</div>
|
|
980
|
+
<div class="modal-body">
|
|
981
|
+
<button title="Delete All" style="background-color: #DC4C64; color:white" class="btn btn-save-delete-selected boxy-small dimens2x image-button" type="button"><img src="/assets/icons/http-delete.svg" class="icons-bg-white"> Delete selected data</button>
|
|
982
|
+
</div>
|
|
983
|
+
</div>
|
|
984
|
+
</div>
|
|
971
985
|
</div>`
|
|
972
986
|
try {
|
|
973
|
-
return modalFields + modalFields2 + modalFields3
|
|
987
|
+
return modalFields + modalFields2 + modalFields3 + modalFields4
|
|
974
988
|
} catch (err) {
|
|
975
989
|
console.log(err)
|
|
976
990
|
}
|
package/lib/moduleLib.js
CHANGED
|
@@ -63,6 +63,30 @@ m.datepicker = function (req, res, elem) {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
//module for selectize
|
|
67
|
+
//https://selectize.dev
|
|
68
|
+
//https://github.com/selectize/selectize.js
|
|
69
|
+
m.selectize = function (req, res, elem) {
|
|
70
|
+
let script = ''
|
|
71
|
+
let head = ``
|
|
72
|
+
let end = ``
|
|
73
|
+
elem = elem || '.selectize'
|
|
74
|
+
head += '<link href="/modules/selectizejs/css/selectize.bootstrap5.css" rel="stylesheet">'
|
|
75
|
+
end += '<script src="/modules/selectizejs/js/selectize.min.js"></script>'
|
|
76
|
+
|
|
77
|
+
script += `$(() => {
|
|
78
|
+
$('${elem}').selectize({
|
|
79
|
+
sortField: 'text'
|
|
80
|
+
});
|
|
81
|
+
});`
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
head: head,
|
|
85
|
+
end: end,
|
|
86
|
+
script: script,
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
66
90
|
//module for dropzone
|
|
67
91
|
m.dropzone = function (req, res, elem) {
|
|
68
92
|
let script = ''
|
package/lib/zAppRouter.js
CHANGED
|
@@ -1280,6 +1280,37 @@ router.post('/zlock-unlock/:table', async (req, res) => {
|
|
|
1280
1280
|
res.json(json)
|
|
1281
1281
|
})
|
|
1282
1282
|
|
|
1283
|
+
router.post('/zdeleted-selected/:table', async (req, res) => {
|
|
1284
|
+
let json = Util.jsonSuccess('Success')
|
|
1285
|
+
let table = req.params.table
|
|
1286
|
+
let cacheRoles = myCache.get('ROLES')
|
|
1287
|
+
let roleId = res.locals.roleId
|
|
1288
|
+
let myrole = cacheRoles[roleId]
|
|
1289
|
+
let tableRole = myrole.params[table] || []
|
|
1290
|
+
let hasAccess = tableRole.includes('lock') ? true : false
|
|
1291
|
+
if (hasAccess) {
|
|
1292
|
+
let type = req.body.type
|
|
1293
|
+
let datas = req.body.datas || []
|
|
1294
|
+
if (datas.length > 0) {
|
|
1295
|
+
for (const data of datas) {
|
|
1296
|
+
let id = data.name.replace('ck[', '').replace(']', '')
|
|
1297
|
+
await connection.delete({
|
|
1298
|
+
table: table,
|
|
1299
|
+
where: {
|
|
1300
|
+
id: id,
|
|
1301
|
+
},
|
|
1302
|
+
})
|
|
1303
|
+
}
|
|
1304
|
+
} else {
|
|
1305
|
+
json = Util.flashError('No Data')
|
|
1306
|
+
}
|
|
1307
|
+
} else {
|
|
1308
|
+
json = Util.flashError('No Access')
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
res.json(json)
|
|
1312
|
+
})
|
|
1313
|
+
|
|
1283
1314
|
router.post('/zapproval-update/:table', async (req, res) => {
|
|
1284
1315
|
let json = Util.jsonSuccess('Success')
|
|
1285
1316
|
let table = req.params.table
|
package/lib/zRole.js
CHANGED
|
@@ -23,7 +23,7 @@ if (cacheRoutes && cacheRoutes.length) {
|
|
|
23
23
|
Default actions
|
|
24
24
|
you can additional here
|
|
25
25
|
*/
|
|
26
|
-
a.actions = ['index', 'create', 'update', 'delete', 'view', 'import', 'export', 'approval', 'lock']
|
|
26
|
+
a.actions = ['index', 'create', 'update', 'delete', 'delete_all', 'view', 'import', 'export', 'approval', 'lock']
|
|
27
27
|
|
|
28
28
|
/*
|
|
29
29
|
all in table roles
|
package/lib/zRoute.js
CHANGED
|
@@ -3370,6 +3370,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3370
3370
|
let mapKey = ''
|
|
3371
3371
|
let hasAttributes = []
|
|
3372
3372
|
let joinsFields = []
|
|
3373
|
+
let selectize = []
|
|
3373
3374
|
if (MYMODEL.joins) {
|
|
3374
3375
|
joinsFields = MYMODEL.joins.list
|
|
3375
3376
|
}
|
|
@@ -3439,6 +3440,10 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3439
3440
|
if (widgets[key].isAttributes) {
|
|
3440
3441
|
hasAttributes.push(key)
|
|
3441
3442
|
}
|
|
3443
|
+
//add search on select
|
|
3444
|
+
if (widgets[key].isSearch) {
|
|
3445
|
+
selectize.push(key)
|
|
3446
|
+
}
|
|
3442
3447
|
}
|
|
3443
3448
|
}
|
|
3444
3449
|
}
|
|
@@ -3478,9 +3483,14 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3478
3483
|
headObj.datetimepicker = datetimepickerObj.head
|
|
3479
3484
|
endObj.datetimepicker = datetimepickerObj.end
|
|
3480
3485
|
}
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3486
|
+
if (selectize.length > 0) {
|
|
3487
|
+
selectize.map((item) => {
|
|
3488
|
+
let selectizeObj = moduleLib.selectize(req, res, `#${item}`)
|
|
3489
|
+
scriptForm += selectizeObj.script
|
|
3490
|
+
headObj.selectize = selectizeObj.head
|
|
3491
|
+
endObj.selectize = selectizeObj.end
|
|
3492
|
+
})
|
|
3493
|
+
}
|
|
3484
3494
|
if (hasIde) {
|
|
3485
3495
|
let ideCDNObj = moduleLib.ideCDN(req, res)
|
|
3486
3496
|
//scriptForm += ideCDNObj.script;
|
package/lib/zdataTable.js
CHANGED
|
@@ -156,7 +156,10 @@ class dataTable {
|
|
|
156
156
|
html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> </span></span></button>`
|
|
157
157
|
}
|
|
158
158
|
if (this.levels.lock) {
|
|
159
|
-
html += `<button title="Lock/Unlock" style="background-color: #
|
|
159
|
+
html += `<button title="Lock/Unlock" style="background-color: #E4A11B; color:white" class="btn btn-danger buttons-lock buttons-html5 copy gridlock boxy-small dimens2x image-button" data-bs-toggle="modal" data-bs-target="#grid-lock" type="button"><img src="/assets/icons/lock-check.svg" class="icons-bg-white"> </span></span></button>`
|
|
160
|
+
}
|
|
161
|
+
if (this.levels.delete_all) {
|
|
162
|
+
html += `<button title="Lock/Unlock" style="background-color: #DC4C64; color:white" class="btn btn-danger buttons-lock buttons-html5 copy griddeleteall boxy-small dimens2x image-button" data-bs-toggle="modal" data-bs-target="#grid-delete-all" type="button"><img src="/assets/icons/http-delete.svg" class="icons-bg-white"> </span></span></button>`
|
|
160
163
|
}
|
|
161
164
|
if (this.hasLevels) {
|
|
162
165
|
html += `<button title="Approval" style="background-color: #E4A11B; color:white" class="btn buttons-html5 boxy-small dimens2x image-button" data-bs-toggle="modal" data-bs-target="#grid-approval" type="button"><img src="/assets/icons/rubber-stamp.svg" class="icons-bg-white"> </span></span></button>`
|
|
@@ -302,6 +305,20 @@ $(".btn-save-unlock").on("click", function () {
|
|
|
302
305
|
})
|
|
303
306
|
})
|
|
304
307
|
|
|
308
|
+
$(".btn-save-delete-selected").on("click", function () {
|
|
309
|
+
if(window.confirm("sure to delete selected data ?")) {
|
|
310
|
+
ajaxPost('/zdeleted-selected/${this.MYMODEL.table}', {
|
|
311
|
+
type : 1,
|
|
312
|
+
datas: $(".ck").serializeArray()
|
|
313
|
+
}, function (data) {
|
|
314
|
+
toastrForm(data);
|
|
315
|
+
if(data.status ==1) {
|
|
316
|
+
location.href='';
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
}
|
|
320
|
+
})
|
|
321
|
+
|
|
305
322
|
$("#zgrid_default_type").val(${this.gridType});
|
|
306
323
|
|
|
307
324
|
})</script>${Util.newLine}`
|