zet-lib 1.2.39 → 1.2.41
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 +31 -1
- package/lib/Util.js +3 -1
- package/lib/zAppRouter.js +78 -0
- package/lib/zRole.js +1 -1
- package/lib/zRoute.js +128 -82
- package/lib/zdataTable.js +30 -5
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -854,8 +854,38 @@ Form.modal = (obj, LANGUAGE = {}) => {
|
|
|
854
854
|
<img src="/assets/icons/send.svg" class="icons-bg-white"> ${LANGUAGE.apply || 'Apply'}
|
|
855
855
|
</button>`,
|
|
856
856
|
})
|
|
857
|
+
|
|
858
|
+
let modalFields2 = `
|
|
859
|
+
<div class="modal fade" id="grid-lock" tabindex="-1" aria-labelledby="grid-lock-label" aria-hidden="true">
|
|
860
|
+
<div class="modal-dialog">
|
|
861
|
+
<div class="modal-content">
|
|
862
|
+
<div class="modal-header">
|
|
863
|
+
<h1 class="modal-title fs-5" id="exampleModalLabel">Lock/Unlock</h1>
|
|
864
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
865
|
+
</div>
|
|
866
|
+
<div class="modal-body">
|
|
867
|
+
<form>
|
|
868
|
+
<fieldset>
|
|
869
|
+
<div class="mb-3">
|
|
870
|
+
<div class="form-check">
|
|
871
|
+
<input class="form-check-input" type="checkbox" id="check-all-grid">
|
|
872
|
+
<label class="form-check-label" for="check-all-grid">
|
|
873
|
+
Lock/UnLock All
|
|
874
|
+
</label>
|
|
875
|
+
</div>
|
|
876
|
+
</div>
|
|
877
|
+
</fieldset>
|
|
878
|
+
</form>
|
|
879
|
+
|
|
880
|
+
</div>
|
|
881
|
+
<div class="modal-footer">
|
|
882
|
+
<button type="button" class="btn btn-primary btn-save-lock"> ${LANGUAGE.apply || 'Apply'}</button>
|
|
883
|
+
</div>
|
|
884
|
+
</div>
|
|
885
|
+
</div>
|
|
886
|
+
</div>`
|
|
857
887
|
try {
|
|
858
|
-
return modalFields
|
|
888
|
+
return modalFields + modalFields2
|
|
859
889
|
} catch (err) {
|
|
860
890
|
console.log(err)
|
|
861
891
|
}
|
package/lib/Util.js
CHANGED
|
@@ -1124,7 +1124,7 @@ Util.userAvatar = (img = '') => {
|
|
|
1124
1124
|
MYSQL HELPER
|
|
1125
1125
|
*/
|
|
1126
1126
|
Util.selectParser = (fields = [], MYMODEL = {}) => {
|
|
1127
|
-
fields = fields.filter((e) => e !== 'actionColumn')
|
|
1127
|
+
//fields = fields.filter((e) => e !== 'actionColumn')
|
|
1128
1128
|
let virtuals = []
|
|
1129
1129
|
let select = ''
|
|
1130
1130
|
for (var key in MYMODEL.widgets) {
|
|
@@ -1138,6 +1138,8 @@ Util.selectParser = (fields = [], MYMODEL = {}) => {
|
|
|
1138
1138
|
select += MYMODEL.widgets[item].fields + ','
|
|
1139
1139
|
} else if (item === 'no') {
|
|
1140
1140
|
arr.push('id')
|
|
1141
|
+
} else if (item === 'actionColumn') {
|
|
1142
|
+
arr.push('lock')
|
|
1141
1143
|
} else {
|
|
1142
1144
|
arr.push(item)
|
|
1143
1145
|
}
|
package/lib/zAppRouter.js
CHANGED
|
@@ -1296,4 +1296,82 @@ router.get('/zdownload/zgenerator/:table', async (req, res) => {
|
|
|
1296
1296
|
})
|
|
1297
1297
|
})
|
|
1298
1298
|
|
|
1299
|
+
router.post('/zlock-unlock/:table', async (req, res) => {
|
|
1300
|
+
let json = Util.jsonSuccess('Success')
|
|
1301
|
+
var table = req.params.table
|
|
1302
|
+
let cacheRoles = myCache.get('ROLES')
|
|
1303
|
+
let roleId = res.locals.roleId
|
|
1304
|
+
let myrole = cacheRoles[roleId]
|
|
1305
|
+
let tableRole = myrole.params[table] || []
|
|
1306
|
+
let hasAccess = tableRole.includes('lock') ? true : false
|
|
1307
|
+
if (hasAccess) {
|
|
1308
|
+
let datas = req.body.datas || []
|
|
1309
|
+
if (datas.length > 0) {
|
|
1310
|
+
for (const data of datas) {
|
|
1311
|
+
let id = data.name.replace('lock[', '').replace(']', '')
|
|
1312
|
+
let value = data.value
|
|
1313
|
+
await connection.update({
|
|
1314
|
+
table: table,
|
|
1315
|
+
data: {
|
|
1316
|
+
lock: value,
|
|
1317
|
+
},
|
|
1318
|
+
where: {
|
|
1319
|
+
id: id,
|
|
1320
|
+
},
|
|
1321
|
+
})
|
|
1322
|
+
}
|
|
1323
|
+
} else {
|
|
1324
|
+
json = Util.flashError('No Data')
|
|
1325
|
+
}
|
|
1326
|
+
} else {
|
|
1327
|
+
json = Util.flashError('No Access')
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
res.json(json)
|
|
1331
|
+
})
|
|
1332
|
+
|
|
1333
|
+
router.get('/addlock-fields', async (req, res) => {
|
|
1334
|
+
let tables = await connection.query(connection.showTables)
|
|
1335
|
+
for (const table of tables) {
|
|
1336
|
+
let tablename = table.tablename
|
|
1337
|
+
let sql = `ALTER TABLE ${tablename} ADD COLUMN "lock" smallint DEFAULT 0 `
|
|
1338
|
+
try {
|
|
1339
|
+
await connection.query(sql)
|
|
1340
|
+
} catch (e) {
|
|
1341
|
+
console.log(e)
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
res.send(tables)
|
|
1345
|
+
})
|
|
1346
|
+
|
|
1347
|
+
router.get('/addlock-models', async (req, res) => {
|
|
1348
|
+
let text = ''
|
|
1349
|
+
let results = await connection.results({
|
|
1350
|
+
table: 'zfields',
|
|
1351
|
+
})
|
|
1352
|
+
for (const result of results) {
|
|
1353
|
+
let labels = result.labels
|
|
1354
|
+
let arr = Object.keys(labels)
|
|
1355
|
+
if (!Util.in_array('lock', arr)) {
|
|
1356
|
+
text += result.id + ' tidak ada'
|
|
1357
|
+
labels.lock = 'Lock/Unlock'
|
|
1358
|
+
try {
|
|
1359
|
+
await connection.update({
|
|
1360
|
+
table: 'zfields',
|
|
1361
|
+
data: {
|
|
1362
|
+
labels: JSON.stringify(labels),
|
|
1363
|
+
},
|
|
1364
|
+
where: {
|
|
1365
|
+
id: result.id,
|
|
1366
|
+
},
|
|
1367
|
+
})
|
|
1368
|
+
} catch (err) {
|
|
1369
|
+
console.log(err)
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
|
|
1374
|
+
res.send(text)
|
|
1375
|
+
})
|
|
1376
|
+
|
|
1299
1377
|
module.exports = router
|
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']
|
|
26
|
+
a.actions = ['index', 'create', 'update', 'delete', 'view', 'import', 'export', 'approval', 'lock']
|
|
27
27
|
|
|
28
28
|
/*
|
|
29
29
|
all in table roles
|
package/lib/zRoute.js
CHANGED
|
@@ -859,88 +859,94 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
859
859
|
return dataTable
|
|
860
860
|
}
|
|
861
861
|
|
|
862
|
-
zRoute.dataTableData = (key, value, MYMODEL, relations) => {
|
|
862
|
+
zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
|
|
863
863
|
relations = relations || {}
|
|
864
864
|
var keyFields = key + 'Fields'
|
|
865
865
|
var keyObject = key + 'Object'
|
|
866
866
|
let myvalue = value
|
|
867
867
|
var widgetName = MYMODEL.widgets[key] ? MYMODEL.widgets[key].name : ''
|
|
868
|
-
if (
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
868
|
+
if (key == 'lock') {
|
|
869
|
+
let selected1 = value != 1 ? 'selected' : ''
|
|
870
|
+
let selected2 = value == 1 ? 'selected' : ''
|
|
871
|
+
myvalue = `<select name="lock[${myid}]" class="lockdatagrid" id="lock${myid}"><option value="0" ${selected1}>Unlock</option><option value="1" ${selected2}>Lock</option></select>`
|
|
872
|
+
} else {
|
|
873
|
+
if (widgetName) {
|
|
874
|
+
switch (widgetName) {
|
|
875
|
+
case 'switch':
|
|
876
|
+
myvalue = relations[keyFields][value] || ''
|
|
877
|
+
break
|
|
873
878
|
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
879
|
+
case 'color':
|
|
880
|
+
myvalue = `<input type="color" value="${value}">`
|
|
881
|
+
break
|
|
877
882
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
883
|
+
case 'relation':
|
|
884
|
+
myvalue = relations[keyObject][value] || ''
|
|
885
|
+
break
|
|
881
886
|
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
887
|
+
case 'dropdown_multi':
|
|
888
|
+
let arr = value ? value : []
|
|
889
|
+
if (arr.length) {
|
|
890
|
+
let myarr = []
|
|
891
|
+
arr.forEach(function (item) {
|
|
892
|
+
myarr.push(relations[keyObject][item])
|
|
893
|
+
})
|
|
894
|
+
myvalue = myarr.length ? myarr.join(', ') : ''
|
|
895
|
+
}
|
|
896
|
+
break
|
|
892
897
|
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
898
|
+
case 'dropdown_chain':
|
|
899
|
+
myvalue = relations[key][value] || ''
|
|
900
|
+
break
|
|
896
901
|
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
902
|
+
case 'select':
|
|
903
|
+
myvalue = relations[keyFields][value] || ''
|
|
904
|
+
break
|
|
900
905
|
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
906
|
+
case 'radio':
|
|
907
|
+
myvalue = relations[keyFields][value] || ''
|
|
908
|
+
break
|
|
904
909
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
910
|
+
case 'typeahead':
|
|
911
|
+
myvalue = relations[keyObject][value] || ''
|
|
912
|
+
break
|
|
908
913
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
914
|
+
case 'datetime':
|
|
915
|
+
myvalue = Util.timeSql(moment(value).utc(false))
|
|
916
|
+
break
|
|
912
917
|
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
918
|
+
case 'datepicker':
|
|
919
|
+
myvalue = Util.dateFormat(value, MYMODEL.widgets[key].format)
|
|
920
|
+
break
|
|
916
921
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
922
|
+
case 'number':
|
|
923
|
+
myvalue = Util.formatNumber(value)
|
|
924
|
+
break
|
|
920
925
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
926
|
+
case 'integer':
|
|
927
|
+
myvalue = value + ''
|
|
928
|
+
break
|
|
924
929
|
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
930
|
+
case 'image':
|
|
931
|
+
myvalue = Util.fileView('/uploads/' + MYMODEL.routeName + '/', value, { width: 60 })
|
|
932
|
+
break
|
|
928
933
|
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
934
|
+
case 'file':
|
|
935
|
+
myvalue = Util.fileView('/uploads/' + MYMODEL.routeName + '/', value)
|
|
936
|
+
break
|
|
932
937
|
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
938
|
+
case 'password':
|
|
939
|
+
myvalue = 'xxxxxx'
|
|
940
|
+
break
|
|
936
941
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
942
|
+
case 'json':
|
|
943
|
+
myvalue = value ? JSON.stringify(value).replaceAll('","', '", "') : ''
|
|
944
|
+
break
|
|
940
945
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
946
|
+
default:
|
|
947
|
+
value = value || ''
|
|
948
|
+
myvalue = value.length > 50 ? value.substring(0, 50) : value
|
|
949
|
+
}
|
|
944
950
|
}
|
|
945
951
|
}
|
|
946
952
|
return myvalue
|
|
@@ -1819,7 +1825,7 @@ zRoute.listDataTable = async (req, res, objData = {}) => {
|
|
|
1819
1825
|
let buttons = objData.hasOwnProperty('actionButtons') ? objData.actionButtons(levels, row, MYMODEL.table) : zRoute.actionButtons(levels, row, MYMODEL.table)
|
|
1820
1826
|
arr.push(buttons)
|
|
1821
1827
|
} else {
|
|
1822
|
-
let data = objData.hasOwnProperty('datas') ? objData.data(item, row[item], MYMODEL, relations) : zRoute.dataTableData(item, row[item], MYMODEL, relations)
|
|
1828
|
+
let data = objData.hasOwnProperty('datas') ? objData.data(item, row[item], MYMODEL, relations) : zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id)
|
|
1823
1829
|
arr.push(data)
|
|
1824
1830
|
}
|
|
1825
1831
|
})
|
|
@@ -1929,7 +1935,7 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
|
|
|
1929
1935
|
let buttons = !actionButtonsFn(levels, row, MYMODEL.table) ? zRoute.actionButtons(levels, row, MYMODEL.table) : actionButtonsFn(levels, row, MYMODEL.table)
|
|
1930
1936
|
arr.push(buttons)
|
|
1931
1937
|
} else {
|
|
1932
|
-
arr.push(zRoute.dataTableData(item, row[item], MYMODEL, relations))
|
|
1938
|
+
arr.push(zRoute.dataTableData(item, row[item], MYMODEL, relations, row.id))
|
|
1933
1939
|
}
|
|
1934
1940
|
})
|
|
1935
1941
|
datas.push(arr)
|
|
@@ -1953,14 +1959,30 @@ zRoute.actionButtons = (levels, row, table, callback = null) => {
|
|
|
1953
1959
|
let arr = []
|
|
1954
1960
|
let obj = {}
|
|
1955
1961
|
if (levels.delete) {
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1962
|
+
if (row.hasOwnProperty('lock')) {
|
|
1963
|
+
if (row.lock != 1) {
|
|
1964
|
+
let icon_delete = `<span class="icon-small icons-danger" title="${LANGUAGE.delete}" ><img data-id="${row.id}" class="icons-bg-white griddelete icon-image" src="/assets/icons/trash-filled.svg"></span>`
|
|
1965
|
+
arr.push(icon_delete)
|
|
1966
|
+
obj['delete'] = icon_delete
|
|
1967
|
+
}
|
|
1968
|
+
} else {
|
|
1969
|
+
let icon_delete = `<span class="icon-small icons-danger" title="${LANGUAGE.delete}" ><img data-id="${row.id}" class="icons-bg-white griddelete icon-image" src="/assets/icons/trash-filled.svg"></span>`
|
|
1970
|
+
arr.push(icon_delete)
|
|
1971
|
+
obj['delete'] = icon_delete
|
|
1972
|
+
}
|
|
1959
1973
|
}
|
|
1960
1974
|
if (levels.update) {
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1975
|
+
if (row.hasOwnProperty('lock')) {
|
|
1976
|
+
if (row.lock != 1) {
|
|
1977
|
+
let icon_update = `<span class="icon-small icons-primary" title="${LANGUAGE.update}" ><img data-id="${row.id}" class="icons-bg-white gridupdate icon-image" src="/assets/icons/edit.svg"></span>`
|
|
1978
|
+
arr.push(icon_update)
|
|
1979
|
+
obj['update'] = icon_update
|
|
1980
|
+
}
|
|
1981
|
+
} else {
|
|
1982
|
+
let icon_update = `<span class="icon-small icons-primary" title="${LANGUAGE.update}" ><img data-id="${row.id}" class="icons-bg-white gridupdate icon-image" src="/assets/icons/edit.svg"></span>`
|
|
1983
|
+
arr.push(icon_update)
|
|
1984
|
+
obj['update'] = icon_update
|
|
1985
|
+
}
|
|
1964
1986
|
}
|
|
1965
1987
|
if (levels.view) {
|
|
1966
1988
|
let icon_view = `<span class="icon-small icons-light" title="${LANGUAGE.view}" ><img data-id="${row.id}" class="icons-bg-black gridview icon-image" src="/assets/icons/eye.svg"></span>`
|
|
@@ -3325,6 +3347,7 @@ zRoute.insertSQL = async (req, res, table, data) => {
|
|
|
3325
3347
|
if (fields.includes('created_at')) data.created_at = Util.now()
|
|
3326
3348
|
if (fields.includes('updated_by')) data.updated_by = res.locals.userId || 1
|
|
3327
3349
|
if (fields.includes('created_by')) data.created_by = res.locals.userId || 1
|
|
3350
|
+
delete data.lock
|
|
3328
3351
|
const result = await connection.insert({ table: table, data: data })
|
|
3329
3352
|
zRoute.modelsCacheRenew(table, res.locals.companyId)
|
|
3330
3353
|
return result
|
|
@@ -3357,11 +3380,11 @@ zRoute.updateSQL = async (req, res, table, data, whereData) => {
|
|
|
3357
3380
|
}
|
|
3358
3381
|
}
|
|
3359
3382
|
}
|
|
3383
|
+
let result = await connection.result({
|
|
3384
|
+
table: MYMODEL.table,
|
|
3385
|
+
where: whereData,
|
|
3386
|
+
})
|
|
3360
3387
|
if (hasImages) {
|
|
3361
|
-
let result = await connection.result({
|
|
3362
|
-
table: MYMODEL.table,
|
|
3363
|
-
where: whereData,
|
|
3364
|
-
})
|
|
3365
3388
|
tables.forEach((item) => {
|
|
3366
3389
|
let dataTables = data[item] ? JSON.parse(data[item]) : []
|
|
3367
3390
|
let temp = []
|
|
@@ -3386,9 +3409,14 @@ zRoute.updateSQL = async (req, res, table, data, whereData) => {
|
|
|
3386
3409
|
}
|
|
3387
3410
|
delete data.created_at
|
|
3388
3411
|
delete data.created_by
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3412
|
+
delete data.lock
|
|
3413
|
+
if (result.lock != 1) {
|
|
3414
|
+
const myresult = await connection.update({ table: table, where: whereData, data: data })
|
|
3415
|
+
zRoute.modelsCacheRenew(table, res.locals.companyId)
|
|
3416
|
+
return myresult
|
|
3417
|
+
} else {
|
|
3418
|
+
return result
|
|
3419
|
+
}
|
|
3392
3420
|
}
|
|
3393
3421
|
|
|
3394
3422
|
zRoute.deleteSQL = async (table, id, company_id) => {
|
|
@@ -3402,14 +3430,18 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
3402
3430
|
where: where,
|
|
3403
3431
|
})
|
|
3404
3432
|
if (results.length) {
|
|
3405
|
-
|
|
3406
|
-
|
|
3433
|
+
if (results[0].lock == 1) {
|
|
3434
|
+
throw Error('Data is locked')
|
|
3435
|
+
} else {
|
|
3436
|
+
await connection.delete({ table: table, where: where })
|
|
3437
|
+
zRoute.modelsCacheRenew(table, company_id)
|
|
3438
|
+
}
|
|
3407
3439
|
} else {
|
|
3408
3440
|
throw Error('Data not found')
|
|
3409
3441
|
}
|
|
3410
3442
|
return results[0]
|
|
3411
3443
|
} catch (e) {
|
|
3412
|
-
throw Error(e
|
|
3444
|
+
throw Error(e + '')
|
|
3413
3445
|
}
|
|
3414
3446
|
}
|
|
3415
3447
|
|
|
@@ -3542,19 +3574,33 @@ zRoute.import = async (req, res, MYMODEL) => {
|
|
|
3542
3574
|
if (Util.in_array('created_by', fields)) data.created_by = res.locals.userId
|
|
3543
3575
|
if (Util.in_array('updated_at', fields)) data.updated_at = Util.now()
|
|
3544
3576
|
if (Util.in_array('updated_by', fields)) data.updated_by = res.locals.userId
|
|
3577
|
+
delete data.lock
|
|
3545
3578
|
await connection.insert({ table: MYMODEL.table, data: data })
|
|
3546
3579
|
} else {
|
|
3547
3580
|
if (Util.in_array('updated_at', fields)) data.updated_at = Util.now()
|
|
3548
3581
|
if (Util.in_array('updated_by', fields)) data.updated_by = res.locals.userId
|
|
3549
|
-
|
|
3582
|
+
delete data.lock
|
|
3583
|
+
//check data is lock
|
|
3584
|
+
let mydatas = await connection.result({
|
|
3585
|
+
select: 'id,lock',
|
|
3550
3586
|
table: MYMODEL.table,
|
|
3551
|
-
data: data,
|
|
3552
3587
|
where: {
|
|
3553
3588
|
id: data.id,
|
|
3554
3589
|
},
|
|
3555
3590
|
})
|
|
3591
|
+
if (mydatas.lock == 1) {
|
|
3592
|
+
hd += `<td class='text text-success'>Data is locked</td>`
|
|
3593
|
+
} else {
|
|
3594
|
+
var update = await connection.update({
|
|
3595
|
+
table: MYMODEL.table,
|
|
3596
|
+
data: data,
|
|
3597
|
+
where: {
|
|
3598
|
+
id: data.id,
|
|
3599
|
+
},
|
|
3600
|
+
})
|
|
3601
|
+
}
|
|
3602
|
+
hd += `<td class='text text-success'>${LANGUAGE['success']}</td>`
|
|
3556
3603
|
}
|
|
3557
|
-
hd += `<td class='text text-success'>${LANGUAGE['success']}</td>`
|
|
3558
3604
|
} catch (err) {
|
|
3559
3605
|
hd += `<td class='text text-danger'>${err + ''}</td>`
|
|
3560
3606
|
io.to(room).emit('error', err + '' + ' ')
|
package/lib/zdataTable.js
CHANGED
|
@@ -86,8 +86,11 @@ class dataTable {
|
|
|
86
86
|
if (this.levels.create) {
|
|
87
87
|
html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd image-button boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/plus.svg" class="icons-bg-black"> ${LANGUAGE.create}</button>`
|
|
88
88
|
}
|
|
89
|
-
if (this.levels.
|
|
90
|
-
html += `<button title="
|
|
89
|
+
if (this.levels.lock) {
|
|
90
|
+
html += `<button title="Lock/Unlock" style="background-color: #3B71CA; color:white" class="btn btn-danger buttons-lock buttons-html5 copy gridlock boxy-small dimens2x image-button" tabindex="0" data-bs-toggle="modal" data-bs-target="#grid-lock" type="button"><img src="/assets/icons/cloud-lock.svg" class="icons-bg-white"> Lock/Unlock</span></span></button>`
|
|
91
|
+
}
|
|
92
|
+
if (this.levels.lock) {
|
|
93
|
+
html += `<button title="Lock/Unlock" style="background-color: #3B71CA; color:white" class="btn btn-danger buttons-lock buttons-html5 copy gridlock boxy-small dimens2x image-button" tabindex="0" style="color: " type="button"><img src="/assets/icons/cloud-lock.svg" class="icons-bg-white"> Lock/Unlock</span></span></button>`
|
|
91
94
|
}
|
|
92
95
|
html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" aria-controls="DataTables_Table_0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`
|
|
93
96
|
html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`
|
|
@@ -117,9 +120,12 @@ class dataTable {
|
|
|
117
120
|
html += `<button title="${LANGUAGE.create_info}" class="btn create gridadd image-button boxy-small dimens2x" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/plus.svg" class="icons-bg-black"> ${LANGUAGE.create}</button>`
|
|
118
121
|
}
|
|
119
122
|
if (this.levels.import) {
|
|
120
|
-
html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0"
|
|
123
|
+
html += `<button title="${LANGUAGE.import_info}" class="btn buttons-copy buttons-html5 copy gridimport boxy-small dimens2x image-button" tabindex="0" type="button"><img src="/assets/icons/database-import.svg" class="icons-bg-black"> ${LANGUAGE.import}</span></span></button>`
|
|
121
124
|
}
|
|
122
|
-
|
|
125
|
+
if (this.levels.lock) {
|
|
126
|
+
html += `<button title="Lock/Unlock" style="background-color: #3B71CA; color:white" class="btn btn-danger buttons-lock buttons-html5 copy gridlock boxy-small dimens2x image-button" tabindex="0" data-bs-toggle="modal" data-bs-target="#grid-lock" type="button"><img src="/assets/icons/cloud-lock.svg" class="icons-bg-white"> Lock/Unlock</span></span></button>`
|
|
127
|
+
}
|
|
128
|
+
html += `<button title="${LANGUAGE.settings}" class="btn buttons-excel buttons-html5 setting gridsettings boxy-small dimens2x image-button" tabindex="0" type="button" data-bs-toggle="modal" data-bs-target="#grid-modal"><img src="/assets/icons/settings.svg" class="icons-bg-black"> ${LANGUAGE.settings}</button>`
|
|
123
129
|
html += `<button class="btn refresh gridreload boxy-small dimens2x image-button" title="${LANGUAGE.grid_refresh}" tabindex="0" aria-controls="DataTables_Table_0" type="button"><img src="/assets/icons/refresh.svg" class="icons-bg-black"></button>`
|
|
124
130
|
if (this.levels.export) {
|
|
125
131
|
html += `<div class="btn-group" role="group">
|
|
@@ -173,10 +179,29 @@ class dataTable {
|
|
|
173
179
|
`
|
|
174
180
|
}
|
|
175
181
|
}
|
|
176
|
-
|
|
177
182
|
if (typeaheadScript) {
|
|
178
183
|
script += `<script type="text/javascript">$(function () {${typeaheadScript}})</script>${Util.newLine}`
|
|
179
184
|
}
|
|
185
|
+
script += `<script type="text/javascript">
|
|
186
|
+
function checkthisgrid() {$(".lockdatagrid").val("1");}
|
|
187
|
+
function uncheckthisgrid() {$(".lockdatagrid").val("0");}
|
|
188
|
+
$(function () {$("#check-all-grid").on('click', function () {
|
|
189
|
+
if($(this).is(':checked')) {
|
|
190
|
+
checkthisgrid();
|
|
191
|
+
} else {
|
|
192
|
+
uncheckthisgrid();
|
|
193
|
+
}
|
|
194
|
+
})
|
|
195
|
+
$(".btn-save-lock").on("click", function () {
|
|
196
|
+
ajaxPost('/zlock-unlock/${this.MYMODEL.table}', {
|
|
197
|
+
datas: $(".lockdatagrid").serializeArray()
|
|
198
|
+
}, function (data) {
|
|
199
|
+
toastrForm(data);
|
|
200
|
+
if(data.status ==1) {
|
|
201
|
+
location.href='';
|
|
202
|
+
}
|
|
203
|
+
})
|
|
204
|
+
})})</script>${Util.newLine}`
|
|
180
205
|
|
|
181
206
|
return script
|
|
182
207
|
}
|