zet-lib 1.3.35 → 1.3.37
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/zAppRouter.js +31 -0
- package/lib/zRole.js +1 -1
- 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/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/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="Delete selected data" 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}`
|