zet-lib 1.2.117 → 1.3.0
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 +29 -0
- package/lib/languages/lang_en.js +1 -1
- package/lib/languages/lang_id.js +1 -1
- package/lib/moduleLib.js +36 -0
- package/lib/views/generator_layout.ejs +1 -1
- package/lib/views/generatorjs.ejs +12 -4
- package/lib/zGeneratorRouter.js +1 -1
- package/lib/zRoute.js +176 -41
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -428,6 +428,35 @@ Form.field = (obj) => {
|
|
|
428
428
|
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
429
429
|
break
|
|
430
430
|
|
|
431
|
+
case 'dragdrop':
|
|
432
|
+
//dataObject
|
|
433
|
+
let leftButtons = ``
|
|
434
|
+
let rightButtons = ``
|
|
435
|
+
let all = Object.keys(obj.dataObject)
|
|
436
|
+
all.map((item, index) => {
|
|
437
|
+
if (!value.includes(item)) {
|
|
438
|
+
rightButtons += `<li><button class="btn btn-danger boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='trashx' value="${item}"></button></li>`
|
|
439
|
+
}
|
|
440
|
+
})
|
|
441
|
+
value = value || []
|
|
442
|
+
value.map((item, index) => {
|
|
443
|
+
leftButtons += `<li><button class="btn btn-primary boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='${obj.name}[]' value="${item}"></button></li>`
|
|
444
|
+
})
|
|
445
|
+
|
|
446
|
+
displayForm += `<div id="dragdrop_${obj.id}" class="row contentfields">
|
|
447
|
+
<div class="col-md-6">
|
|
448
|
+
<h5>${obj.attributes.left}</h5>
|
|
449
|
+
<ol class="mydragable${obj.id} divboxlittle" data-type="left" data-name="${obj.name}[]">${leftButtons}</ol>
|
|
450
|
+
</div>
|
|
451
|
+
<div class="col-md-6">
|
|
452
|
+
<h5>${obj.attributes.right}</h5>
|
|
453
|
+
<ol class="mydragable${obj.id} divboxlittle" data-type="right" data-name="trashx">
|
|
454
|
+
${rightButtons}
|
|
455
|
+
</ol>
|
|
456
|
+
</div>
|
|
457
|
+
</div>`
|
|
458
|
+
break
|
|
459
|
+
|
|
431
460
|
case 'array':
|
|
432
461
|
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
433
462
|
break
|
package/lib/languages/lang_en.js
CHANGED
|
@@ -13,7 +13,7 @@ langs['grid_labeling'] = 'Labeling'
|
|
|
13
13
|
langs['grid_configure_field_labeling'] = 'Configure Field Labeling'
|
|
14
14
|
langs['grid_personalize_labeling'] = 'Personalize Labeling'
|
|
15
15
|
langs['grid_personalize_setting'] = 'Personalize grid settings'
|
|
16
|
-
langs['grid_refresh'] = 'Refresh
|
|
16
|
+
langs['grid_refresh'] = 'Refresh / Factory Reset'
|
|
17
17
|
langs.settings = 'Setting'
|
|
18
18
|
langs.settings_info = 'Settings'
|
|
19
19
|
langs.grid_settings = 'Settings Grid'
|
package/lib/languages/lang_id.js
CHANGED
|
@@ -13,7 +13,7 @@ langs['grid_labeling'] = 'Penamaan'
|
|
|
13
13
|
langs['grid_configure_field_labeling'] = 'Configure Field Labeling'
|
|
14
14
|
langs['grid_personalize_labeling'] = 'Personalize Labeling'
|
|
15
15
|
langs['grid_personalize_setting'] = 'Personalize grid settings'
|
|
16
|
-
langs['grid_refresh'] = 'Muat Ulang'
|
|
16
|
+
langs['grid_refresh'] = 'Muat Ulang / Kembali setelan pabrik'
|
|
17
17
|
langs.settings = 'Pengaturan'
|
|
18
18
|
langs.settings_info = 'Pengaturan'
|
|
19
19
|
langs.grid_settings = 'Pengaturan Grid'
|
package/lib/moduleLib.js
CHANGED
|
@@ -79,6 +79,42 @@ m.dropzone = function (req, res, elem) {
|
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
//module for dragdrop
|
|
83
|
+
m.dragdrop = function (req, res, elem) {
|
|
84
|
+
let script = ''
|
|
85
|
+
let head = ``
|
|
86
|
+
let end = ``
|
|
87
|
+
head += '<link href="/modules/drag/drag.css" rel="stylesheet">'
|
|
88
|
+
end += '<script src="/modules/drag/jquery-sortable.js"></script>'
|
|
89
|
+
script += `$(function () {
|
|
90
|
+
$("ol.mydragable${elem}").sortable({
|
|
91
|
+
group: 'mydragable${elem}',
|
|
92
|
+
isValidTarget: function ($item, container) {
|
|
93
|
+
return true;
|
|
94
|
+
},
|
|
95
|
+
onDrop: function ($item, container, _super) {
|
|
96
|
+
var getidname = $item.parents().attr('id') || "";
|
|
97
|
+
var iname = $item.find('input[type=text]').attr('data-name');
|
|
98
|
+
var containertype = $item.parents().data('type');
|
|
99
|
+
var containername = $item.parents().data('name');
|
|
100
|
+
var newname = getidname ? iname + "___" + getidname : iname;
|
|
101
|
+
$item.find('input[type=text]').attr('name', newname);
|
|
102
|
+
$item.find('input[type=hidden]').attr('name', containername);
|
|
103
|
+
$item.find('button').addClass(containertype == "left" ? "btn-primary" : "btn-danger");
|
|
104
|
+
$item.find('button').removeClass(containertype == "right" ? "btn-primary" : "btn-danger");
|
|
105
|
+
_super($item, container);
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
`
|
|
111
|
+
return {
|
|
112
|
+
head: head,
|
|
113
|
+
end: end,
|
|
114
|
+
script: script,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
82
118
|
//module for google map
|
|
83
119
|
m.location = function (req, res, key) {
|
|
84
120
|
let script = ``
|
|
@@ -161,7 +161,7 @@
|
|
|
161
161
|
<a class="dropdown-item" href="/zmenu"><span>Menu Generator</span></a>
|
|
162
162
|
</li>
|
|
163
163
|
<li>
|
|
164
|
-
<a class="dropdown-item" href="/
|
|
164
|
+
<a class="dropdown-item" href="/zreports"><span>Report Generator</span></a>
|
|
165
165
|
</li>
|
|
166
166
|
</ul>
|
|
167
167
|
</li>
|
|
@@ -98,7 +98,6 @@
|
|
|
98
98
|
$('#modal_setting_label').html(`Setting ${label} <span class="badge bg-primary text-dark">${caption}</span>`)
|
|
99
99
|
$('#body_content').html('Loading...')
|
|
100
100
|
$('body').find('#delete_field').attr('data-name', name)
|
|
101
|
-
|
|
102
101
|
ajaxPost(
|
|
103
102
|
'/<%- routeName%>/setting_field',
|
|
104
103
|
{
|
|
@@ -111,6 +110,9 @@
|
|
|
111
110
|
if ($('#relation_table').length) {
|
|
112
111
|
dropdownRelations('relation_table', 'relation_name', 'relation_concat', $('#relation_table').data('value'), $('#relation_name').data('value'), $('#relation_concat').data('value'))
|
|
113
112
|
}
|
|
113
|
+
if ($('#dragdrop_table').length) {
|
|
114
|
+
dropdownRelations('dragdrop_table', 'dragdrop_name', 'dragdrop_concat', $('#dragdrop_table').data('value'), $('#dragdrop_name').data('value'), $('#dragdrop_concat').data('value'))
|
|
115
|
+
}
|
|
114
116
|
if ($('#typeahead_table').length) {
|
|
115
117
|
val = $('body').find('#typeahead_concat').attr('value')
|
|
116
118
|
dropdownRelations('typeahead_table', 'typeahead_name', 'typeahead_concat', $('#typeahead_table').data('value'), $('#typeahead_name').data('value'), val)
|
|
@@ -620,6 +622,12 @@
|
|
|
620
622
|
$('.divconcat').show()
|
|
621
623
|
$('.divfield').hide()
|
|
622
624
|
dropdownRelations()
|
|
625
|
+
} else if ($(this).val() == 'dragdrop') {
|
|
626
|
+
$('.divrelation').show()
|
|
627
|
+
$('.divrelationfield').show()
|
|
628
|
+
$('.divconcat').show()
|
|
629
|
+
$('.divfield').hide()
|
|
630
|
+
dropdownRelations()
|
|
623
631
|
} else {
|
|
624
632
|
$('.divrelation').hide()
|
|
625
633
|
$('.divconcat').hide()
|
|
@@ -871,11 +879,11 @@
|
|
|
871
879
|
table: $('#table').val(),
|
|
872
880
|
others: JSON.stringify(others),
|
|
873
881
|
},
|
|
874
|
-
function (dt) {}
|
|
882
|
+
function (dt) { }
|
|
875
883
|
)
|
|
876
884
|
}
|
|
877
885
|
</script>
|
|
878
886
|
<script>
|
|
879
887
|
//tab draggable
|
|
880
|
-
$(function () {})
|
|
881
|
-
</script>
|
|
888
|
+
$(function () { })
|
|
889
|
+
</script>
|
package/lib/zGeneratorRouter.js
CHANGED
|
@@ -803,7 +803,7 @@ router.delete('/delete-table', csrfProtection, async (req, res) => {
|
|
|
803
803
|
router.post('/add_field', csrfProtection, async (req, res) => {
|
|
804
804
|
try {
|
|
805
805
|
const body = req.body
|
|
806
|
-
|
|
806
|
+
console.log(JSON.stringify(body))
|
|
807
807
|
const table = body.table
|
|
808
808
|
if (nots.includes(table)) {
|
|
809
809
|
return res.json(Util.flashError('Table is locked'))
|
package/lib/zRoute.js
CHANGED
|
@@ -194,6 +194,14 @@ zRoute.post = (req, res, MYMODEL, routeName, body) => {
|
|
|
194
194
|
post[routeName][key] = cleaning ? JSON.stringify(cleaning) : null
|
|
195
195
|
break
|
|
196
196
|
|
|
197
|
+
case 'dragdrop':
|
|
198
|
+
let cleaning2
|
|
199
|
+
if (Array.isArray(post[routeName][key])) {
|
|
200
|
+
cleaning2 = post[routeName][key] ? post[routeName][key].filter((item) => item) : null
|
|
201
|
+
}
|
|
202
|
+
post[routeName][key] = cleaning2 ? JSON.stringify(cleaning2) : null
|
|
203
|
+
break
|
|
204
|
+
|
|
197
205
|
case 'lexical':
|
|
198
206
|
post[routeName][key] = JSON.stringify(post[routeName][key])
|
|
199
207
|
break
|
|
@@ -589,27 +597,6 @@ zRoute.relations = async (req, res, table) => {
|
|
|
589
597
|
relations[keyFields] = widget.fields
|
|
590
598
|
relations[keyObject] = Util.objectToGridFormat(relations[key], true)
|
|
591
599
|
} else if (widgetName == 'relation') {
|
|
592
|
-
let select = widget.fields.join(',') + ' as zname '
|
|
593
|
-
let obj = {
|
|
594
|
-
select: select,
|
|
595
|
-
table: widget.table,
|
|
596
|
-
where: { company_id: company_id },
|
|
597
|
-
order_by: widget.hasOwnProperty('order_by') && widget.order_by ? [`${widget.order_by}`] : ['zname asc'],
|
|
598
|
-
}
|
|
599
|
-
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
600
|
-
delete obj.where
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
if (widget.hasOwnProperty('please_select')) {
|
|
604
|
-
if (widget.please_select != undefined) {
|
|
605
|
-
if (widget.please_select != '') {
|
|
606
|
-
emptyArray = {
|
|
607
|
-
id: '',
|
|
608
|
-
zname: widget.please_select,
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
600
|
let cacheKey = `${widget.table}_${MYMODEL.table}___${key}_${company_id}`
|
|
614
601
|
if (key == 'created_by' || key == 'updated_by') {
|
|
615
602
|
cacheKey = `zuser_${key}_${company_id}`
|
|
@@ -618,6 +605,26 @@ zRoute.relations = async (req, res, table) => {
|
|
|
618
605
|
if (myCache.has(cacheKey)) {
|
|
619
606
|
results = myCache.get(cacheKey)
|
|
620
607
|
} else {
|
|
608
|
+
let select = widget.fields.join(',') + ' as zname '
|
|
609
|
+
let obj = {
|
|
610
|
+
select: select,
|
|
611
|
+
table: widget.table,
|
|
612
|
+
where: { company_id: company_id },
|
|
613
|
+
order_by: widget.hasOwnProperty('order_by') && widget.order_by ? [`${widget.order_by}`] : ['zname asc'],
|
|
614
|
+
}
|
|
615
|
+
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
616
|
+
delete obj.where
|
|
617
|
+
}
|
|
618
|
+
if (widget.hasOwnProperty('please_select')) {
|
|
619
|
+
if (widget.please_select != undefined) {
|
|
620
|
+
if (widget.please_select != '') {
|
|
621
|
+
emptyArray = {
|
|
622
|
+
id: '',
|
|
623
|
+
zname: widget.please_select,
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
}
|
|
621
628
|
results = await connection.results(obj)
|
|
622
629
|
}
|
|
623
630
|
relations[key] = [emptyArray, ...results]
|
|
@@ -628,41 +635,41 @@ zRoute.relations = async (req, res, table) => {
|
|
|
628
635
|
hasAttributes = true
|
|
629
636
|
}
|
|
630
637
|
} else if (widgetName == 'dropdown_chain') {
|
|
631
|
-
const obj = {
|
|
632
|
-
select: widget.fields.join(',') + ' as zname ',
|
|
633
|
-
table: widget.table,
|
|
634
|
-
where: { company_id: company_id },
|
|
635
|
-
orderBy: ['id', 'asc'],
|
|
636
|
-
}
|
|
637
|
-
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
638
|
-
delete obj.where
|
|
639
|
-
}
|
|
640
638
|
const cacheKey = `${widget.table}_${MYMODEL.table}___${key}_${company_id}`
|
|
641
639
|
let results
|
|
642
640
|
if (myCache.has(cacheKey)) {
|
|
643
641
|
results = myCache.get(cacheKey)
|
|
644
642
|
} else {
|
|
643
|
+
const obj = {
|
|
644
|
+
select: widget.fields.join(',') + ' as zname ',
|
|
645
|
+
table: widget.table,
|
|
646
|
+
where: { company_id: company_id },
|
|
647
|
+
orderBy: ['id', 'asc'],
|
|
648
|
+
}
|
|
649
|
+
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
650
|
+
delete obj.where
|
|
651
|
+
}
|
|
645
652
|
results = await connection.results(obj)
|
|
646
653
|
}
|
|
647
654
|
relations[key] = [Util.arrayUnShift(['id', 'zname']), ...results]
|
|
648
655
|
relations[keyFields] = widget.fields
|
|
649
656
|
relations[keyObject] = Util.arrayWithObject(relations[key], 'id', 'zname')
|
|
650
657
|
} else if (widgetName == 'typeahead') {
|
|
651
|
-
let select = widget.fields.join(',') + ' as zname '
|
|
652
|
-
let obj = {
|
|
653
|
-
select: select,
|
|
654
|
-
table: widget.table,
|
|
655
|
-
where: { company_id: company_id },
|
|
656
|
-
order_by: widget.hasOwnProperty('order_by') && widget.order_by ? [`${widget.order_by}`] : ['zname asc'],
|
|
657
|
-
}
|
|
658
|
-
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
659
|
-
delete obj.where
|
|
660
|
-
}
|
|
661
658
|
const cacheKey = `${widget.table}_${MYMODEL.table}___${key}_${company_id}`
|
|
662
659
|
let results
|
|
663
660
|
if (myCache.has(cacheKey)) {
|
|
664
661
|
results = myCache.get(cacheKey)
|
|
665
662
|
} else {
|
|
663
|
+
let select = widget.fields.join(',') + ' as zname '
|
|
664
|
+
let obj = {
|
|
665
|
+
select: select,
|
|
666
|
+
table: widget.table,
|
|
667
|
+
where: { company_id: company_id },
|
|
668
|
+
order_by: widget.hasOwnProperty('order_by') && widget.order_by ? [`${widget.order_by}`] : ['zname asc'],
|
|
669
|
+
}
|
|
670
|
+
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
671
|
+
delete obj.where
|
|
672
|
+
}
|
|
666
673
|
results = await connection.results(obj)
|
|
667
674
|
}
|
|
668
675
|
relations[key] = [Util.arrayUnShift(['id', 'zname']), ...results]
|
|
@@ -673,8 +680,43 @@ zRoute.relations = async (req, res, table) => {
|
|
|
673
680
|
relations[keyFields] = widget.fields
|
|
674
681
|
} else if (widgetName == 'virtual') {
|
|
675
682
|
relations['zvirtuals'][key] = widget.fields
|
|
683
|
+
} else if (widgetName == 'dragdrop') {
|
|
684
|
+
const cacheKey = `${table}_${key}_${company_id}`
|
|
685
|
+
let results = {}
|
|
686
|
+
if (myCache.has(cacheKey)) {
|
|
687
|
+
results = myCache.get(cacheKey)
|
|
688
|
+
} else {
|
|
689
|
+
let wheredragdrop = {}
|
|
690
|
+
wheredragdrop['company_id'] = company_id
|
|
691
|
+
let whereWidget = widget.where || ''
|
|
692
|
+
if (whereWidget) {
|
|
693
|
+
if (whereWidget.includes(',')) {
|
|
694
|
+
let splits = whereWidget.split(',')
|
|
695
|
+
splits.map((item) => {
|
|
696
|
+
let splits2 = item.split('=')
|
|
697
|
+
wheredragdrop[splits2[0]] = splits2[1]
|
|
698
|
+
})
|
|
699
|
+
} else {
|
|
700
|
+
let splits = whereWidget.split('=')
|
|
701
|
+
wheredragdrop[splits[0]] = splits[1]
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
let obj = {
|
|
705
|
+
select: widget.fields.join(',') + ' as zname ',
|
|
706
|
+
table: widget.table,
|
|
707
|
+
where: wheredragdrop,
|
|
708
|
+
order_by: widget.hasOwnProperty('order_by') && widget.order_by ? [`${widget.order_by}`] : ['zname asc'],
|
|
709
|
+
}
|
|
710
|
+
if (Util.in_array(widget.table, zRoute.tableHasNoCompanyId)) {
|
|
711
|
+
delete obj.where
|
|
712
|
+
}
|
|
713
|
+
results = await connection.results(obj)
|
|
714
|
+
}
|
|
715
|
+
relations[key] = results
|
|
716
|
+
relations[keyObject] = Util.arrayWithObject(relations[key], 'id', 'zname')
|
|
676
717
|
}
|
|
677
718
|
}
|
|
719
|
+
//console.log(relations);
|
|
678
720
|
|
|
679
721
|
let selectZvirtuals = ''
|
|
680
722
|
for (let key in relations['zvirtuals']) {
|
|
@@ -686,6 +728,7 @@ zRoute.relations = async (req, res, table) => {
|
|
|
686
728
|
|
|
687
729
|
return relations
|
|
688
730
|
} catch (err) {
|
|
731
|
+
console.log(err)
|
|
689
732
|
debug(req, res, err)
|
|
690
733
|
}
|
|
691
734
|
}
|
|
@@ -802,6 +845,15 @@ zRoute.dataTableFilter = (MYMODEL, relations, filter) => {
|
|
|
802
845
|
types[key] = 'select'
|
|
803
846
|
break
|
|
804
847
|
|
|
848
|
+
case 'dragdrop':
|
|
849
|
+
options = relations[key].reduce((result, item) => {
|
|
850
|
+
var selected = value == item.id ? ' selected ' : ''
|
|
851
|
+
return result + `<option value="${item.id}" ${selected} >${item.zname}</option>`
|
|
852
|
+
}, '')
|
|
853
|
+
dataTable[key] = `<select id="data_table_${key}" class="form-control form-select search"><option value=""></option>${options}</select>`
|
|
854
|
+
types[key] = 'select'
|
|
855
|
+
break
|
|
856
|
+
|
|
805
857
|
case 'dropdown_chain':
|
|
806
858
|
options = relations[key].reduce((result, item) => {
|
|
807
859
|
var selected = value == item.id ? ' selected ' : ''
|
|
@@ -957,6 +1009,17 @@ zRoute.dataTableData = (key, value, MYMODEL, relations, myid = '') => {
|
|
|
957
1009
|
}
|
|
958
1010
|
break
|
|
959
1011
|
|
|
1012
|
+
case 'dragdrop':
|
|
1013
|
+
let arr2 = value ? value : []
|
|
1014
|
+
if (arr2.length) {
|
|
1015
|
+
let myarr2 = []
|
|
1016
|
+
arr2.forEach(function (item) {
|
|
1017
|
+
myarr2.push(relations[keyObject][item])
|
|
1018
|
+
})
|
|
1019
|
+
myvalue = myarr2.length ? myarr2.join(', ') : ''
|
|
1020
|
+
}
|
|
1021
|
+
break
|
|
1022
|
+
|
|
960
1023
|
case 'dropdown_chain':
|
|
961
1024
|
myvalue = relations[key][value] || ''
|
|
962
1025
|
break
|
|
@@ -1966,6 +2029,9 @@ zRoute.listData = async (req, res, MYMODEL, zRole, actionButtonsFn) => {
|
|
|
1966
2029
|
if (MYMODEL.widgets[key].name == 'dropdown_multi') {
|
|
1967
2030
|
asJSONb.push(key)
|
|
1968
2031
|
}
|
|
2032
|
+
if (MYMODEL.widgets[key].name == 'dragdrop') {
|
|
2033
|
+
asJSONb.push(key)
|
|
2034
|
+
}
|
|
1969
2035
|
if (MYMODEL.widgets[key].name == 'dropdown_checkbox') {
|
|
1970
2036
|
asJSONb.push(key)
|
|
1971
2037
|
}
|
|
@@ -2440,6 +2506,11 @@ zRoute.forms = (req, res, MYMODEL, relations, data = {}, tableRelations = {}) =>
|
|
|
2440
2506
|
obj.data = relations[key] || []
|
|
2441
2507
|
obj.multi = relations[key + 'Object']
|
|
2442
2508
|
break
|
|
2509
|
+
case 'dragdrop':
|
|
2510
|
+
obj.type = 'dragdrop'
|
|
2511
|
+
obj.data = relations[key] || []
|
|
2512
|
+
obj.dataObject = relations[key + 'Object']
|
|
2513
|
+
break
|
|
2443
2514
|
case 'number':
|
|
2444
2515
|
obj.type = 'number'
|
|
2445
2516
|
obj.class = 'form-control number'
|
|
@@ -3131,6 +3202,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3131
3202
|
let hasTags = false
|
|
3132
3203
|
let hasLexical = false
|
|
3133
3204
|
let hasLocation = false
|
|
3205
|
+
let hasDragdrop = false
|
|
3134
3206
|
let lexicals = []
|
|
3135
3207
|
let mapKey = ''
|
|
3136
3208
|
let hasAttributes = []
|
|
@@ -3161,6 +3233,11 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
3161
3233
|
endObj.location = locationObj.end
|
|
3162
3234
|
hasLocation = true
|
|
3163
3235
|
mapKey = key
|
|
3236
|
+
} else if (widgets[key].name == 'dragdrop') {
|
|
3237
|
+
let dragdropObj = moduleLib.dragdrop(req, res, key)
|
|
3238
|
+
scriptForm += dragdropObj.script
|
|
3239
|
+
headObj.dragdrop = dragdropObj.head
|
|
3240
|
+
endObj.dragdrop = dragdropObj.end
|
|
3164
3241
|
} else if (widgets[key].name == 'datetime') {
|
|
3165
3242
|
hasDateTimePicker = true
|
|
3166
3243
|
} else if (widgets[key].name == 'table') {
|
|
@@ -4252,6 +4329,7 @@ cache models in so it's no need call database repeatly
|
|
|
4252
4329
|
zRoute.modelsCache = async () => {
|
|
4253
4330
|
let obj = {}
|
|
4254
4331
|
let orderBy = {}
|
|
4332
|
+
let dragdropsObj = {}
|
|
4255
4333
|
if (process.env.APP_IS_CACHE == 1) {
|
|
4256
4334
|
let models = zRoute.MYMODELS() || {}
|
|
4257
4335
|
delete models.zrole
|
|
@@ -4262,6 +4340,10 @@ zRoute.modelsCache = async () => {
|
|
|
4262
4340
|
for (let keys in models) {
|
|
4263
4341
|
let widgets = models[keys].widgets
|
|
4264
4342
|
for (let key in widgets) {
|
|
4343
|
+
//check if has dragdrop
|
|
4344
|
+
if (widgets[key].name == 'dragdrop') {
|
|
4345
|
+
dragdropsObj[keys] = models[keys]
|
|
4346
|
+
}
|
|
4265
4347
|
if (Util.in_array(widgets[key].name, mustCaches)) {
|
|
4266
4348
|
let widget = widgets[key]
|
|
4267
4349
|
let table = widget.table
|
|
@@ -4283,6 +4365,7 @@ zRoute.modelsCache = async () => {
|
|
|
4283
4365
|
}
|
|
4284
4366
|
}
|
|
4285
4367
|
}
|
|
4368
|
+
//console.log(whereObj)
|
|
4286
4369
|
companies = await connection.results({
|
|
4287
4370
|
table: 'zcompany',
|
|
4288
4371
|
})
|
|
@@ -4313,6 +4396,7 @@ zRoute.modelsCache = async () => {
|
|
|
4313
4396
|
company_id: company.id,
|
|
4314
4397
|
},
|
|
4315
4398
|
}
|
|
4399
|
+
//console.log(keys)
|
|
4316
4400
|
if (orderBy[keys]) {
|
|
4317
4401
|
objectSQL.order_by = [`${orderBy[keys]}`]
|
|
4318
4402
|
}
|
|
@@ -4341,6 +4425,49 @@ zRoute.modelsCache = async () => {
|
|
|
4341
4425
|
}
|
|
4342
4426
|
}
|
|
4343
4427
|
}
|
|
4428
|
+
|
|
4429
|
+
//this is for dragdrops
|
|
4430
|
+
//yg lain tidak support where
|
|
4431
|
+
//dibuat sendiri
|
|
4432
|
+
let MODELS_DRAGDROPS = {}
|
|
4433
|
+
for (let keys in dragdropsObj) {
|
|
4434
|
+
let widgets = dragdropsObj[keys].widgets
|
|
4435
|
+
for (let key in widgets) {
|
|
4436
|
+
if (widgets[key].name == 'dragdrop') {
|
|
4437
|
+
if (!MODELS_DRAGDROPS[keys]) {
|
|
4438
|
+
MODELS_DRAGDROPS[keys] = []
|
|
4439
|
+
}
|
|
4440
|
+
companies.map((company) => {
|
|
4441
|
+
let where = {}
|
|
4442
|
+
where['company_id'] = company.id
|
|
4443
|
+
let whereWidget = widgets[key].where || ''
|
|
4444
|
+
if (whereWidget) {
|
|
4445
|
+
if (whereWidget.includes(',')) {
|
|
4446
|
+
let splits = whereWidget.split(',')
|
|
4447
|
+
splits.map((item) => {
|
|
4448
|
+
let splits2 = item.split('=')
|
|
4449
|
+
where[splits2[0]] = splits2[1]
|
|
4450
|
+
})
|
|
4451
|
+
} else {
|
|
4452
|
+
let splits = whereWidget.split('=')
|
|
4453
|
+
where[splits[0]] = splits[1]
|
|
4454
|
+
}
|
|
4455
|
+
}
|
|
4456
|
+
let objectSQL = {
|
|
4457
|
+
table: widgets[key].table,
|
|
4458
|
+
select: ` id, ${widgets[key].fields[1]} as zname `,
|
|
4459
|
+
where: where,
|
|
4460
|
+
}
|
|
4461
|
+
connection.results(objectSQL).then(function (results) {
|
|
4462
|
+
myCache.set(`${keys}_${key}_${company.id}`, results)
|
|
4463
|
+
})
|
|
4464
|
+
MODELS_DRAGDROPS[keys].push({ key: `${keys}_${key}_${company.id}`, objectSQL: objectSQL })
|
|
4465
|
+
})
|
|
4466
|
+
}
|
|
4467
|
+
}
|
|
4468
|
+
}
|
|
4469
|
+
myCache.set('MODELS_DRAGDROPS', MODELS_DRAGDROPS)
|
|
4470
|
+
//console.log(MODELS_DRAGDROPS)
|
|
4344
4471
|
} catch (e) {
|
|
4345
4472
|
//debug(req,res,e.toString());
|
|
4346
4473
|
console.log('modelsCache :', e + '')
|
|
@@ -4364,7 +4491,6 @@ zRoute.modelsCacheRenew = (table, companyId) => {
|
|
|
4364
4491
|
selects += `${obj[key]},`
|
|
4365
4492
|
}
|
|
4366
4493
|
selects += `id`
|
|
4367
|
-
|
|
4368
4494
|
let objectSQL = {
|
|
4369
4495
|
select: selects,
|
|
4370
4496
|
table: table,
|
|
@@ -4395,6 +4521,15 @@ zRoute.modelsCacheRenew = (table, companyId) => {
|
|
|
4395
4521
|
})
|
|
4396
4522
|
}
|
|
4397
4523
|
}
|
|
4524
|
+
|
|
4525
|
+
let MODELS_DRAGDROPS = myCache.get('MODELS_DRAGDROPS')
|
|
4526
|
+
if (MODELS_DRAGDROPS[table]) {
|
|
4527
|
+
MODELS_DRAGDROPS[table].map((item) => {
|
|
4528
|
+
connection.results(item.objectSQL).then(function (results) {
|
|
4529
|
+
myCache.set(item.key, results)
|
|
4530
|
+
})
|
|
4531
|
+
})
|
|
4532
|
+
}
|
|
4398
4533
|
}
|
|
4399
4534
|
} catch (err) {
|
|
4400
4535
|
console.log(err)
|