zet-lib 1.3.22 → 1.3.23
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/generator.ejs +20 -15
- package/lib/views/generatorjs.ejs +6 -25
- package/lib/zGeneratorRouter.js +48 -9
- package/package.json +1 -1
package/lib/views/generator.ejs
CHANGED
|
@@ -91,10 +91,6 @@
|
|
|
91
91
|
<form id="formfields" method="post" action="/generator/fields">
|
|
92
92
|
<div id="divtablist" class="row"></div>
|
|
93
93
|
<div id="contentfields"></div>
|
|
94
|
-
<div id="divjoinmodules">
|
|
95
|
-
<h4>Join Modules</h4>
|
|
96
|
-
<div class="row" id="joinlist"></div>
|
|
97
|
-
</div>
|
|
98
94
|
<% if(lock==0) {%>
|
|
99
95
|
<div class="text-center mt-4">
|
|
100
96
|
<button class="btn btn-danger btn-reset text-white mr-2" type="button"><i
|
|
@@ -109,7 +105,7 @@
|
|
|
109
105
|
<!-- Basic dropdown -->
|
|
110
106
|
<button class="btn btn-warning m-0 px-3 waves-effect waves-light mr-2"
|
|
111
107
|
data-toggle="modal" data-target="#modal_joins" type="button"><i
|
|
112
|
-
class="fas fa-dice"></i> Join
|
|
108
|
+
class="fas fa-dice"></i> Join Modules</button>
|
|
113
109
|
<button class="btn m-0 px-3 waves-effect waves-light mr-2" data-toggle="modal"
|
|
114
110
|
data-target="#modal_container" type="button"><i class="fa fa-plus"></i> Add
|
|
115
111
|
Container</button>
|
|
@@ -120,13 +116,26 @@
|
|
|
120
116
|
type="button"><i class="fa fa-paper-plane"></i> Save & Generate</button>
|
|
121
117
|
</div>
|
|
122
118
|
<%}%>
|
|
123
|
-
|
|
124
119
|
</form>
|
|
125
120
|
<!-- Default form reply -->
|
|
126
121
|
</div>
|
|
127
122
|
</div>
|
|
128
123
|
<!--/Generator-->
|
|
129
124
|
|
|
125
|
+
<div class="card mb-4 wow fadeIn card-script">
|
|
126
|
+
<div class="card-header font-weight-bold">
|
|
127
|
+
<span> Join Modules</span>
|
|
128
|
+
</div>
|
|
129
|
+
<div class="card-body">
|
|
130
|
+
<div id="divjoinmodules">
|
|
131
|
+
<form id="formjoin">
|
|
132
|
+
<div class="row" id="joinlist"></div>
|
|
133
|
+
</form>
|
|
134
|
+
</div>
|
|
135
|
+
<hr>
|
|
136
|
+
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
130
139
|
|
|
131
140
|
<!-- Card -->
|
|
132
141
|
<div class="card mb-4 wow fadeIn card-script" style="display: none">
|
|
@@ -304,16 +313,12 @@
|
|
|
304
313
|
</div>
|
|
305
314
|
</div>
|
|
306
315
|
<!--/.Card-->
|
|
307
|
-
|
|
308
316
|
</div>
|
|
309
317
|
</div>
|
|
310
318
|
<!--Grid row-->
|
|
311
319
|
</section>
|
|
312
320
|
<!--Section: Post-->
|
|
313
321
|
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
322
|
<!-- Modal -->
|
|
318
323
|
<div class="modal fade" id="add_table" tabindex="-1" aria-labelledby="add_table" aria-hidden="true">
|
|
319
324
|
<div class="modal-dialog">
|
|
@@ -445,7 +450,6 @@
|
|
|
445
450
|
</div>
|
|
446
451
|
|
|
447
452
|
|
|
448
|
-
|
|
449
453
|
<div class="modal fade" id="modal_tab" tabindex="-1" aria-labelledby="modal_setting" aria-hidden="true">
|
|
450
454
|
<div class="modal-dialog">
|
|
451
455
|
<div class="modal-content">
|
|
@@ -473,7 +477,7 @@
|
|
|
473
477
|
<div class="modal-dialog">
|
|
474
478
|
<div class="modal-content">
|
|
475
479
|
<div class="modal-header">
|
|
476
|
-
<h5 class="modal-title"
|
|
480
|
+
<h5 class="modal-title">Import zfield File</h5>
|
|
477
481
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i>
|
|
478
482
|
</button>
|
|
479
483
|
</div>
|
|
@@ -501,7 +505,7 @@
|
|
|
501
505
|
<div class="modal-dialog">
|
|
502
506
|
<div class="modal-content">
|
|
503
507
|
<div class="modal-header">
|
|
504
|
-
<h5 class="modal-title"
|
|
508
|
+
<h5 class="modal-title">Add Container</h5>
|
|
505
509
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i class="fa fa-times"></i>
|
|
506
510
|
</button>
|
|
507
511
|
</div>
|
|
@@ -534,8 +538,9 @@
|
|
|
534
538
|
<div class="modal-dialog">
|
|
535
539
|
<div class="modal-content">
|
|
536
540
|
<div class="modal-header">
|
|
537
|
-
<h5 class="modal-title"
|
|
538
|
-
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><i
|
|
541
|
+
<h5 class="modal-title">Join Module</h5>
|
|
542
|
+
<button type="button" class="close" id="closejoin" data-dismiss="modal" aria-label="Close"><i
|
|
543
|
+
class="fa fa-times"></i>
|
|
539
544
|
</button>
|
|
540
545
|
</div>
|
|
541
546
|
<div class="modal-body">
|
|
@@ -270,7 +270,7 @@
|
|
|
270
270
|
let html = ``
|
|
271
271
|
let time = new Date().getTime()
|
|
272
272
|
let col_md = `col-md-${12 / columncount}`
|
|
273
|
-
container_time = `container_${time}`
|
|
273
|
+
let container_time = `container_${time}`
|
|
274
274
|
html += `<li class="container-nav"><i class="fa fa-arrows icon-float"></i><div class="row mt-1 mb-1">`
|
|
275
275
|
for (let i = 1; i <= columncount; i++) {
|
|
276
276
|
html += `<div class="${col_md}" style="background-color: rgba(0,0,0,.03)" ><ol class="divboxlittle container-box"><li><i data-container="${container_time}" data-id="${i}" data-split="${columncount}" data-column="ONE_COLUMN" class="fa fa-plus-circle fa-2x add-container text-success"></i></li></ol> </div>`
|
|
@@ -406,6 +406,7 @@
|
|
|
406
406
|
approvers: approvers,
|
|
407
407
|
knowings: knowings,
|
|
408
408
|
others: JSON.stringify(others),
|
|
409
|
+
joins: $('#formjoin').serializeArray(),
|
|
409
410
|
},
|
|
410
411
|
function (data) {
|
|
411
412
|
if (data.status == 0) {
|
|
@@ -815,26 +816,6 @@
|
|
|
815
816
|
})
|
|
816
817
|
})
|
|
817
818
|
}
|
|
818
|
-
/* let myobj = {}
|
|
819
|
-
let isContainer = Object.keys(obj).length ? true : false;
|
|
820
|
-
if(isContainer) {
|
|
821
|
-
for(let key in obj) {
|
|
822
|
-
let arr = obj[key] || [];
|
|
823
|
-
if(arr.length) {
|
|
824
|
-
arr.forEach(function (item) {
|
|
825
|
-
if(Array.isArray(item)) {
|
|
826
|
-
let length = item.length;
|
|
827
|
-
if(isEmpty(item)) {
|
|
828
|
-
obj[key].splice(0,1);
|
|
829
|
-
}
|
|
830
|
-
console.log(length)
|
|
831
|
-
}
|
|
832
|
-
})
|
|
833
|
-
}
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
console.log(JSON.stringify(obj))*/
|
|
837
|
-
|
|
838
819
|
others = obj
|
|
839
820
|
return obj
|
|
840
821
|
}
|
|
@@ -877,10 +858,11 @@
|
|
|
877
858
|
)
|
|
878
859
|
}
|
|
879
860
|
})
|
|
861
|
+
|
|
880
862
|
$("#modal-joins-save").on("click", function (e) {
|
|
881
863
|
let table_join = $('#select_module_joins').val();
|
|
882
864
|
let table = $('#table').val()
|
|
883
|
-
if (table ==
|
|
865
|
+
if (table == table_join) {
|
|
884
866
|
toastr.error("Your selected module is equal with current module");
|
|
885
867
|
return;
|
|
886
868
|
}
|
|
@@ -894,6 +876,7 @@
|
|
|
894
876
|
toastrForm(dt);
|
|
895
877
|
if (dt.status == 1) {
|
|
896
878
|
$("#joinlist").html(dt.html);
|
|
879
|
+
$("#closejoin").click();
|
|
897
880
|
}
|
|
898
881
|
}
|
|
899
882
|
)
|
|
@@ -937,9 +920,7 @@
|
|
|
937
920
|
table_join: table_join
|
|
938
921
|
},
|
|
939
922
|
function (dt) {
|
|
940
|
-
|
|
941
|
-
location.href = '';
|
|
942
|
-
}
|
|
923
|
+
location.reload();
|
|
943
924
|
}
|
|
944
925
|
)
|
|
945
926
|
}
|
package/lib/zGeneratorRouter.js
CHANGED
|
@@ -266,6 +266,7 @@ router.post('/save_and_generate', csrfProtection, async (req, res) => {
|
|
|
266
266
|
if (nots.includes(req.body.table)) {
|
|
267
267
|
return res.json(Util.flashError('Table is locked'))
|
|
268
268
|
}
|
|
269
|
+
//console.log(JSON.stringify(req.body))
|
|
269
270
|
const json = await generate(req, res)
|
|
270
271
|
res.json(json)
|
|
271
272
|
} catch (e) {
|
|
@@ -1015,6 +1016,7 @@ router.post('/load-form', async (req, res) => {
|
|
|
1015
1016
|
res.json(json)
|
|
1016
1017
|
})
|
|
1017
1018
|
|
|
1019
|
+
//save to table zfields
|
|
1018
1020
|
var saveToZFields = async (body) => {
|
|
1019
1021
|
const table = body.table
|
|
1020
1022
|
let is_approval = body.is_approval
|
|
@@ -1049,6 +1051,29 @@ var saveToZFields = async (body) => {
|
|
|
1049
1051
|
others: body.others,
|
|
1050
1052
|
}
|
|
1051
1053
|
|
|
1054
|
+
let joinsTables = {}
|
|
1055
|
+
let bodyJoins = body.joins || []
|
|
1056
|
+
let bodyJoinsObj = {}
|
|
1057
|
+
if (bodyJoins.length > 0) {
|
|
1058
|
+
bodyJoins.map((item) => {
|
|
1059
|
+
bodyJoinsObj[item.name] = item.value
|
|
1060
|
+
})
|
|
1061
|
+
}
|
|
1062
|
+
for (let key in bodyJoinsObj) {
|
|
1063
|
+
if (key.includes('joins_checks___')) {
|
|
1064
|
+
let tablekeys = key.split('___')
|
|
1065
|
+
let keyName = key.replace('joins_checks___', '')
|
|
1066
|
+
if (!joinsTables[tablekeys[1]]) {
|
|
1067
|
+
joinsTables[tablekeys[1]] = []
|
|
1068
|
+
}
|
|
1069
|
+
joinsTables[tablekeys[1]].push({ key: keyName, value: bodyJoinsObj[`joins_labels___${keyName}`] })
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
//console.log(joinsTables);
|
|
1073
|
+
if (Object.keys(joinsTables).length > 0) {
|
|
1074
|
+
data.joins = JSON.stringify(joinsTables)
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1052
1077
|
await connection.update({
|
|
1053
1078
|
table: 'zfields',
|
|
1054
1079
|
data: data,
|
|
@@ -1406,7 +1431,7 @@ router.post('/joins', async (req, res) => {
|
|
|
1406
1431
|
})
|
|
1407
1432
|
let resultJoins = result.joins || {}
|
|
1408
1433
|
resultJoins[table_join] = {}
|
|
1409
|
-
await connection.update({
|
|
1434
|
+
let myzfield = await connection.update({
|
|
1410
1435
|
table: 'zfields',
|
|
1411
1436
|
data: {
|
|
1412
1437
|
joins: JSON.stringify(resultJoins),
|
|
@@ -1416,7 +1441,7 @@ router.post('/joins', async (req, res) => {
|
|
|
1416
1441
|
},
|
|
1417
1442
|
})
|
|
1418
1443
|
jsonNotif.json = resultJoins
|
|
1419
|
-
html = await joinHTML(resultJoins)
|
|
1444
|
+
html = await joinHTML(resultJoins, myzfield)
|
|
1420
1445
|
} catch (e) {
|
|
1421
1446
|
console.log(e)
|
|
1422
1447
|
jsonNotif = Util.flashError(e + '')
|
|
@@ -1428,6 +1453,8 @@ router.post('/joins', async (req, res) => {
|
|
|
1428
1453
|
async function loadJoins(table) {
|
|
1429
1454
|
let html = ''
|
|
1430
1455
|
try {
|
|
1456
|
+
/* let sql = `select ${table}.* from ${table} `;
|
|
1457
|
+
console.log(sql)*/
|
|
1431
1458
|
let result = await connection.result({
|
|
1432
1459
|
table: 'zfields',
|
|
1433
1460
|
where: {
|
|
@@ -1435,7 +1462,7 @@ async function loadJoins(table) {
|
|
|
1435
1462
|
},
|
|
1436
1463
|
})
|
|
1437
1464
|
let joinsObj = result.joins || {}
|
|
1438
|
-
html = await joinHTML(joinsObj)
|
|
1465
|
+
html = await joinHTML(joinsObj, result)
|
|
1439
1466
|
} catch (e) {
|
|
1440
1467
|
console.log(e)
|
|
1441
1468
|
html = e + ''
|
|
@@ -1443,7 +1470,7 @@ async function loadJoins(table) {
|
|
|
1443
1470
|
return html
|
|
1444
1471
|
}
|
|
1445
1472
|
|
|
1446
|
-
async function joinHTML(json) {
|
|
1473
|
+
async function joinHTML(json, myzfield) {
|
|
1447
1474
|
let html = ``
|
|
1448
1475
|
try {
|
|
1449
1476
|
let zfields = await connection.results({
|
|
@@ -1452,8 +1479,8 @@ async function joinHTML(json) {
|
|
|
1452
1479
|
let zfieldsObj = Util.arrayToObject(zfields, 'table')
|
|
1453
1480
|
for (let key in json) {
|
|
1454
1481
|
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])
|
|
1482
|
+
html += `<h5>${zfieldsObj[key].name} <button type="button" class="btn btn-danger" onclick="removeJoins('${key}')"><i class="fa fa-trash "></i> </button></h5>`
|
|
1483
|
+
html += fieldHTML(zfieldsObj[key], myzfield)
|
|
1457
1484
|
html += `</div>`
|
|
1458
1485
|
}
|
|
1459
1486
|
} catch (e) {
|
|
@@ -1462,17 +1489,29 @@ async function joinHTML(json) {
|
|
|
1462
1489
|
return html
|
|
1463
1490
|
}
|
|
1464
1491
|
|
|
1465
|
-
function fieldHTML(obj) {
|
|
1492
|
+
function fieldHTML(obj, myzfield) {
|
|
1466
1493
|
let html = ``
|
|
1467
1494
|
try {
|
|
1468
1495
|
let labels = obj.labels
|
|
1469
1496
|
let table = obj.table
|
|
1497
|
+
let myzfieldJoins = myzfield.joins || {}
|
|
1470
1498
|
for (let key in labels) {
|
|
1499
|
+
let mylabel = labels[key]
|
|
1500
|
+
let selected = ''
|
|
1501
|
+
if (myzfieldJoins[table]) {
|
|
1502
|
+
let arr = myzfieldJoins[table] || []
|
|
1503
|
+
arr.map((item) => {
|
|
1504
|
+
if (item.key == `${table}___${key}`) {
|
|
1505
|
+
selected = ` checked `
|
|
1506
|
+
mylabel = item.value
|
|
1507
|
+
}
|
|
1508
|
+
})
|
|
1509
|
+
}
|
|
1471
1510
|
html += `<div class="input-group">
|
|
1472
1511
|
<div class="input-group-prepend">
|
|
1473
|
-
<span class="input-group-text"><input type="checkbox" name=""></span>
|
|
1512
|
+
<span class="input-group-text"><input type="checkbox" ${selected} name="joins_checks___${table}___${key}"></span>
|
|
1474
1513
|
<span class="input-group-text">${key}</span>
|
|
1475
|
-
<input type="text" class="form-control" name="
|
|
1514
|
+
<input type="text" class="form-control" name="joins_labels___${table}___${key}" id="joins___${table}___${key}" value="${mylabel}">
|
|
1476
1515
|
</div>
|
|
1477
1516
|
</div>`
|
|
1478
1517
|
}
|