zet-lib 1.3.21 → 1.3.22
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/views/generatorjs.ejs +17 -0
- package/lib/zGeneratorRouter.js +117 -87
- package/package.json +1 -1
|
@@ -927,4 +927,21 @@
|
|
|
927
927
|
}
|
|
928
928
|
)
|
|
929
929
|
}
|
|
930
|
+
|
|
931
|
+
function removeJoins(table_join) {
|
|
932
|
+
if (window.confirm('Sure to delete ?')) {
|
|
933
|
+
ajaxPost(
|
|
934
|
+
'/<%- routeName%>/remove-joins',
|
|
935
|
+
{
|
|
936
|
+
table: $('#table').val(),
|
|
937
|
+
table_join: table_join
|
|
938
|
+
},
|
|
939
|
+
function (dt) {
|
|
940
|
+
if (dt.status == 1) {
|
|
941
|
+
location.href = '';
|
|
942
|
+
}
|
|
943
|
+
}
|
|
944
|
+
)
|
|
945
|
+
}
|
|
946
|
+
}
|
|
930
947
|
</script>
|
package/lib/zGeneratorRouter.js
CHANGED
|
@@ -1344,112 +1344,142 @@ const viewsMini = async () => {
|
|
|
1344
1344
|
return notifyObj
|
|
1345
1345
|
}
|
|
1346
1346
|
|
|
1347
|
-
router.post('/load-joins', async(req,res) => {
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1347
|
+
router.post('/load-joins', async (req, res) => {
|
|
1348
|
+
let jsonNotif = Util.jsonSuccess('Success')
|
|
1349
|
+
let html = ''
|
|
1350
|
+
try {
|
|
1351
|
+
let body = req.body
|
|
1352
|
+
console.log(body)
|
|
1353
|
+
let table = body.table
|
|
1354
|
+
html = await loadJoins(table)
|
|
1355
|
+
jsonNotif.html = html
|
|
1356
|
+
} catch (e) {
|
|
1357
|
+
console.log(e)
|
|
1358
|
+
}
|
|
1359
|
+
res.json(jsonNotif)
|
|
1360
1360
|
})
|
|
1361
1361
|
|
|
1362
|
-
router.post('/joins', async(req,res) => {
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1362
|
+
router.post('/remove-joins', async (req, res) => {
|
|
1363
|
+
let jsonNotif = Util.jsonSuccess('Success')
|
|
1364
|
+
let html = ''
|
|
1365
|
+
try {
|
|
1366
|
+
let body = req.body
|
|
1367
|
+
console.log(body)
|
|
1368
|
+
let table = body.table
|
|
1369
|
+
let table_join = body.table_join
|
|
1370
|
+
let result = await connection.result({
|
|
1371
|
+
table: 'zfields',
|
|
1372
|
+
where: {
|
|
1373
|
+
table: table,
|
|
1374
|
+
},
|
|
1375
|
+
})
|
|
1376
|
+
let resultJoins = result.joins || {}
|
|
1377
|
+
delete resultJoins[table_join]
|
|
1378
|
+
await connection.update({
|
|
1379
|
+
table: 'zfields',
|
|
1380
|
+
data: {
|
|
1381
|
+
joins: JSON.stringify(resultJoins),
|
|
1382
|
+
},
|
|
1383
|
+
where: {
|
|
1384
|
+
table: table,
|
|
1385
|
+
},
|
|
1386
|
+
})
|
|
1387
|
+
} catch (e) {
|
|
1388
|
+
console.log(e)
|
|
1389
|
+
}
|
|
1390
|
+
res.json(jsonNotif)
|
|
1391
|
+
})
|
|
1392
|
+
|
|
1393
|
+
router.post('/joins', async (req, res) => {
|
|
1394
|
+
let jsonNotif = Util.jsonSuccess('Success')
|
|
1395
|
+
let html = ''
|
|
1396
|
+
try {
|
|
1397
|
+
let body = req.body
|
|
1398
|
+
console.log(body)
|
|
1399
|
+
let table = body.table
|
|
1400
|
+
let table_join = body.table_join
|
|
1401
|
+
let result = await connection.result({
|
|
1402
|
+
table: 'zfields',
|
|
1403
|
+
where: {
|
|
1404
|
+
table: table,
|
|
1405
|
+
},
|
|
1406
|
+
})
|
|
1407
|
+
let resultJoins = result.joins || {}
|
|
1408
|
+
resultJoins[table_join] = {}
|
|
1409
|
+
await connection.update({
|
|
1410
|
+
table: 'zfields',
|
|
1411
|
+
data: {
|
|
1412
|
+
joins: JSON.stringify(resultJoins),
|
|
1413
|
+
},
|
|
1414
|
+
where: {
|
|
1415
|
+
table: table,
|
|
1416
|
+
},
|
|
1417
|
+
})
|
|
1418
|
+
jsonNotif.json = resultJoins
|
|
1419
|
+
html = await joinHTML(resultJoins)
|
|
1420
|
+
} catch (e) {
|
|
1421
|
+
console.log(e)
|
|
1422
|
+
jsonNotif = Util.flashError(e + '')
|
|
1423
|
+
}
|
|
1424
|
+
jsonNotif.html = html
|
|
1425
|
+
res.json(jsonNotif)
|
|
1395
1426
|
})
|
|
1396
1427
|
|
|
1397
1428
|
async function loadJoins(table) {
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1429
|
+
let html = ''
|
|
1430
|
+
try {
|
|
1431
|
+
let result = await connection.result({
|
|
1432
|
+
table: 'zfields',
|
|
1433
|
+
where: {
|
|
1434
|
+
table: table,
|
|
1435
|
+
},
|
|
1436
|
+
})
|
|
1437
|
+
let joinsObj = result.joins || {}
|
|
1438
|
+
html = await joinHTML(joinsObj)
|
|
1439
|
+
} catch (e) {
|
|
1440
|
+
console.log(e)
|
|
1441
|
+
html = e + ''
|
|
1442
|
+
}
|
|
1443
|
+
return html
|
|
1413
1444
|
}
|
|
1414
1445
|
|
|
1415
1446
|
async function joinHTML(json) {
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
}
|
|
1428
|
-
} catch (e) {
|
|
1429
|
-
html = e+'';
|
|
1447
|
+
let html = ``
|
|
1448
|
+
try {
|
|
1449
|
+
let zfields = await connection.results({
|
|
1450
|
+
table: 'zfields',
|
|
1451
|
+
})
|
|
1452
|
+
let zfieldsObj = Util.arrayToObject(zfields, 'table')
|
|
1453
|
+
for (let key in json) {
|
|
1454
|
+
html += `<div class="joinContainer col-md-4">`
|
|
1455
|
+
html += `<h5>${zfieldsObj[key].name} <button class="btn btn-danger" onclick="removeJoins('${key}')"><i class="fa fa-trash "></i> </button></h5>`
|
|
1456
|
+
html += fieldHTML(zfieldsObj[key])
|
|
1457
|
+
html += `</div>`
|
|
1430
1458
|
}
|
|
1431
|
-
|
|
1459
|
+
} catch (e) {
|
|
1460
|
+
html = e + ''
|
|
1461
|
+
}
|
|
1462
|
+
return html
|
|
1432
1463
|
}
|
|
1433
1464
|
|
|
1434
1465
|
function fieldHTML(obj) {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1466
|
+
let html = ``
|
|
1467
|
+
try {
|
|
1468
|
+
let labels = obj.labels
|
|
1469
|
+
let table = obj.table
|
|
1470
|
+
for (let key in labels) {
|
|
1471
|
+
html += `<div class="input-group">
|
|
1441
1472
|
<div class="input-group-prepend">
|
|
1442
1473
|
<span class="input-group-text"><input type="checkbox" name=""></span>
|
|
1443
1474
|
<span class="input-group-text">${key}</span>
|
|
1444
1475
|
<input type="text" class="form-control" name="joins[${table}][${key}]" id="joins___${table}___${key}" value="${labels[key]}">
|
|
1445
1476
|
</div>
|
|
1446
1477
|
</div>`
|
|
1447
|
-
}
|
|
1448
|
-
} catch (e) {
|
|
1449
|
-
html = e+'';
|
|
1450
1478
|
}
|
|
1451
|
-
|
|
1479
|
+
} catch (e) {
|
|
1480
|
+
html = e + ''
|
|
1481
|
+
}
|
|
1482
|
+
return html
|
|
1452
1483
|
}
|
|
1453
1484
|
|
|
1454
|
-
|
|
1455
1485
|
module.exports = router
|