zet-lib 1.0.68 → 1.0.69
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 +6 -5
- package/lib/moduleLib.js +374 -362
- package/lib/zRoute.js +9 -9
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -196,7 +196,7 @@ Form.field = (obj) => {
|
|
|
196
196
|
|
|
197
197
|
case 'switch':
|
|
198
198
|
checked = value == 1 ? ' checked ' : ''
|
|
199
|
-
displayForm = `${prepend}<p><input
|
|
199
|
+
displayForm = `${prepend}<p><input ${tabindex} type="checkbox" ${classview} ${readonly} ${style} ${id} ${name} ${checked} ></p>${information}${append}`
|
|
200
200
|
break
|
|
201
201
|
|
|
202
202
|
case 'lexical':
|
|
@@ -746,6 +746,7 @@ const tabBootstrap5 = (arr = []) => {
|
|
|
746
746
|
Form.build = (obj) => {
|
|
747
747
|
let html = ''
|
|
748
748
|
let required = !obj.required ? '' : `<span class="required-mark">*</span>`
|
|
749
|
+
let labelOptions = !obj.labelOptions ? '' : obj.labelOptions
|
|
749
750
|
let relation = ''
|
|
750
751
|
//form float
|
|
751
752
|
let float = false
|
|
@@ -777,15 +778,15 @@ Form.build = (obj) => {
|
|
|
777
778
|
} else {
|
|
778
779
|
if (inline) {
|
|
779
780
|
if (obj.type == 'checkbox') {
|
|
780
|
-
html += ` <div class="mb-3 row"><label for="${obj.id}" class="col form-check-label">${obj.title} ${
|
|
781
|
+
html += ` <div class="mb-3 row"><label for="${obj.id}" class="col form-check-label">${obj.title} ${labelOptions} ${required} ${relation}</label><div class="col-8">${Form.field(obj)}</div></div>`
|
|
781
782
|
} else {
|
|
782
|
-
html += ` <div class="mb-3 row"><label for="${obj.id}" class="col col-form-label">${obj.title} ${
|
|
783
|
+
html += ` <div class="mb-3 row"><label for="${obj.id}" class="col col-form-label">${obj.title} ${labelOptions} ${required} ${relation}</label><div class="col-8">${Form.field(obj)}</div></div>`
|
|
783
784
|
}
|
|
784
785
|
} else {
|
|
785
786
|
if (obj.type == 'checkbox') {
|
|
786
|
-
html += `<div class="form-check div${obj.id} mb-3">${Form.field(obj)}<label class="form-check-label" for="${obj.id}">${obj.title} ${
|
|
787
|
+
html += `<div class="form-check div${obj.id} mb-3">${Form.field(obj)}<label class="form-check-label" for="${obj.id}">${obj.title} ${labelOptions} ${required}</label></div>`
|
|
787
788
|
} else {
|
|
788
|
-
html += `<div class="form-group div${obj.id} mb-3"><label for="${obj.id}">${obj.title} ${
|
|
789
|
+
html += `<div class="form-group div${obj.id} mb-3"><label for="${obj.id}">${obj.title} ${labelOptions} ${required} ${relation}</label>${Form.field(obj)}</div>`
|
|
789
790
|
}
|
|
790
791
|
}
|
|
791
792
|
}
|
package/lib/moduleLib.js
CHANGED
|
@@ -1,326 +1,324 @@
|
|
|
1
|
-
const Util = require('./Util')
|
|
2
|
-
const newLine = Util.newLine
|
|
1
|
+
const Util = require('./Util')
|
|
2
|
+
const newLine = Util.newLine
|
|
3
3
|
|
|
4
|
-
const m = {}
|
|
4
|
+
const m = {}
|
|
5
5
|
|
|
6
6
|
//module for ide code editor
|
|
7
|
-
m.ideCDN = function (req,res) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
m.ide = function (req,res,elem) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
7
|
+
m.ideCDN = function (req, res) {
|
|
8
|
+
let script = ''
|
|
9
|
+
let head = ``
|
|
10
|
+
let end = ``
|
|
11
|
+
end += `<script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.15.0/ace.js"></script>${Util.newLine}`
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
head: head,
|
|
15
|
+
end: end,
|
|
16
|
+
script: script,
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
m.ide = function (req, res, elem) {
|
|
21
|
+
let script = ''
|
|
22
|
+
let head = ``
|
|
23
|
+
let end = ``
|
|
24
|
+
elem = elem || '#ide_editor'
|
|
25
|
+
end += `<script> var editor_${elem} = ace.edit("${elem}");
|
|
26
26
|
editor_${elem}.getSession().setMode("ace/mode/ejs");
|
|
27
|
-
</script> ${Util.newLine}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
m.tags = function(req,res,elem) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
27
|
+
</script> ${Util.newLine}`
|
|
28
|
+
return {
|
|
29
|
+
head: head,
|
|
30
|
+
end: end,
|
|
31
|
+
script: script,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
m.tags = function (req, res, elem) {
|
|
36
|
+
let script = ''
|
|
37
|
+
let head = ``
|
|
38
|
+
let end = ``
|
|
39
|
+
elem = elem || '.tags'
|
|
40
|
+
end += `<script type="module">import Tags from "https://cdn.jsdelivr.net/gh/lekoala/bootstrap5-tags@master/tags.js";Tags.init("${elem}");</script>`
|
|
41
|
+
return {
|
|
42
|
+
head: head,
|
|
43
|
+
end: end,
|
|
44
|
+
script: script,
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
47
|
//module for datepicker
|
|
48
48
|
m.datepicker = function (req, res, elem) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
let script = ''
|
|
50
|
+
let head = ``
|
|
51
|
+
let end = ``
|
|
52
|
+
elem = elem || '.datepicker'
|
|
53
|
+
/* head += '<link href="/css/bootstrap-datepicker.css" rel="stylesheet">';
|
|
54
54
|
end += '<script src="/js/bootstrap-datepicker.min.js"></script>';*/
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
55
|
+
head += '<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/css/bootstrap-datepicker.min.css" rel="stylesheet">'
|
|
56
|
+
end += '<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.9.0/js/bootstrap-datepicker.min.js"></script>'
|
|
57
|
+
script = `$.fn.datepicker.defaults.format = "yyyy-mm-dd";$.fn.datepicker.defaults.todayHighlight = true;$("body").on("click", "${elem}", function(){$(this).datepicker();$(this).datepicker("show");});`
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
head: head,
|
|
61
|
+
end: end,
|
|
62
|
+
script: script,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
65
|
|
|
66
66
|
//module for datepicker
|
|
67
67
|
m.datetimepicker = function (req, res, elem) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
|
|
68
|
+
let script = ''
|
|
69
|
+
let head = ``
|
|
70
|
+
let end = ``
|
|
71
|
+
elem = elem || '.datetimepicker'
|
|
72
|
+
head += '<link href="/css/bootstrap-datetimepicker.min.css" rel="stylesheet" />'
|
|
73
|
+
end += '<script type="text/javascript" src="/js/moment-with-locales.min.js" ></script>'
|
|
74
|
+
end += '<script type="text/javascript" src="/js/bootstrap-datetimepicker.min.js" ></script>'
|
|
75
|
+
script += `$(function () { $("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'}); });`
|
|
76
|
+
script += `setTimeout(function () { $("body").click();},1000);`
|
|
77
|
+
script += `$("body").on("click", function(){$("${elem}").datetimepicker({format:'YYYY-MM-DD hh:mm:ss'});});`
|
|
78
|
+
|
|
79
|
+
return {
|
|
80
|
+
head: head,
|
|
81
|
+
end: end,
|
|
82
|
+
script: script,
|
|
83
|
+
}
|
|
84
|
+
}
|
|
87
85
|
|
|
88
86
|
//using ckeditor
|
|
89
87
|
m.ckeditor = function (req, res, elem) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
88
|
+
let script = ''
|
|
89
|
+
let head = ``
|
|
90
|
+
let end = ``
|
|
91
|
+
elem = elem || '.editor'
|
|
92
|
+
end += '<script src="/modules/ckeditor5-build-classic/ckeditor.js"></script>' + newLine
|
|
93
|
+
end += '<script>'
|
|
94
|
+
end += 'ClassicEditor.create( document.querySelector( "' + elem + '" ) ).catch( error => {console.error( error );} );' + newLine
|
|
95
|
+
end += '</script>'
|
|
96
|
+
return {
|
|
97
|
+
head: head,
|
|
98
|
+
end: end,
|
|
99
|
+
script: script,
|
|
100
|
+
}
|
|
101
|
+
}
|
|
105
102
|
|
|
106
103
|
//using tinymce
|
|
107
104
|
m.tinymce = function (req, res, elem) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
105
|
+
let script = ''
|
|
106
|
+
let head = ``
|
|
107
|
+
let end = ``
|
|
108
|
+
elem = elem || '.tinymce'
|
|
109
|
+
end += '<script src="https://cdn.tiny.cloud/1/b7054u42l8lw67ch5oh9qutnvbyu8exzryg4edy0gg2snhtr/tinymce/6/tinymce.min.js" referrerpolicy="origin"></script>' + newLine
|
|
110
|
+
script += ` tinymce.init({
|
|
114
111
|
selector: '${elem}',
|
|
115
112
|
plugins: 'anchor autolink charmap codesample emoticons image link lists media searchreplace table visualblocks wordcount',
|
|
116
113
|
toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough | link image media table | align lineheight | numlist bullist indent outdent | emoticons charmap | removeformat',
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}
|
|
114
|
+
});`
|
|
115
|
+
return {
|
|
116
|
+
head: head,
|
|
117
|
+
end: end,
|
|
118
|
+
script: script,
|
|
119
|
+
}
|
|
120
|
+
}
|
|
124
121
|
|
|
125
122
|
//using froala
|
|
126
123
|
m.froala = function (req, res, elem) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
m.lexical = function(req,res,elem) {
|
|
145
|
-
let script = '';
|
|
146
|
-
let head = ``;
|
|
147
|
-
let end = ``;
|
|
148
|
-
elem = elem || ".editor";
|
|
149
|
-
head += `<link rel="stylesheet" href="/assets/main.143ecbc6.css">`;
|
|
150
|
-
end += `<script type="module" crossorigin src="/assets/main.3be493b7.js"></script>`;
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
head : head,
|
|
154
|
-
end : end,
|
|
155
|
-
script: script
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
|
|
124
|
+
let script = ''
|
|
125
|
+
let head = ``
|
|
126
|
+
let end = ``
|
|
127
|
+
elem = elem || '.editor'
|
|
128
|
+
|
|
129
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />'
|
|
130
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />'
|
|
131
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>'
|
|
132
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
head: head,
|
|
136
|
+
end: end,
|
|
137
|
+
script: script,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
159
140
|
|
|
141
|
+
m.lexical = function (req, res, elem) {
|
|
142
|
+
let script = ''
|
|
143
|
+
let head = ``
|
|
144
|
+
let end = ``
|
|
145
|
+
elem = elem || '.editor'
|
|
146
|
+
head += `<link rel="stylesheet" href="/assets/main.143ecbc6.css">`
|
|
147
|
+
end += `<script type="module" crossorigin src="/assets/main.3be493b7.js"></script>`
|
|
148
|
+
return {
|
|
149
|
+
head: head,
|
|
150
|
+
end: end,
|
|
151
|
+
script: script,
|
|
152
|
+
}
|
|
153
|
+
}
|
|
160
154
|
|
|
161
155
|
//Default editor is froala
|
|
162
|
-
m.editor = (req, res, elem =
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}
|
|
156
|
+
m.editor = (req, res, elem = '') => {
|
|
157
|
+
elem = elem || '.editor'
|
|
158
|
+
//Default editor is froala
|
|
159
|
+
//return m.froala(req, res, elem);
|
|
160
|
+
//return m.tinymce(req, res, elem);
|
|
161
|
+
//return m.ckeditor(req, res, elem);
|
|
162
|
+
//return m.lexical(req,res,elem);
|
|
163
|
+
|
|
164
|
+
let script = ''
|
|
165
|
+
let head = ``
|
|
166
|
+
let end = ``
|
|
167
|
+
|
|
168
|
+
head += '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.4.2/css/all.min.css" integrity="sha512-NicFTMUg/LwBeG8C7VG+gC4YiiRtQACl98QdkmfsLy37RzXdkaUAuPyVMND0olPP4Jn8M/ctesGSB2pgUBDRIw==" crossorigin="anonymous" referrerpolicy="no-referrer" />'
|
|
169
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_editor.pkgd.min.css" rel="stylesheet" type="text/css" />'
|
|
170
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/css/froala_style.min.css" rel="stylesheet" type="text/css" />'
|
|
171
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/froala-editor@2.9.0/js/froala_editor.pkgd.min.js"></script>'
|
|
172
|
+
script += `$(function() {$("${elem}").froalaEditor({height: 200})});`
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
head: head,
|
|
176
|
+
end: end,
|
|
177
|
+
script: script,
|
|
178
|
+
}
|
|
179
|
+
}
|
|
186
180
|
|
|
187
181
|
m.switch = function (req, res, elem, array) {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
}
|
|
207
|
-
|
|
182
|
+
elem = elem || '.switch'
|
|
183
|
+
let script = ''
|
|
184
|
+
let head = ``
|
|
185
|
+
let end = ``
|
|
186
|
+
|
|
187
|
+
head += '<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/css/bootstrap3/bootstrap-switch.css" rel="stylesheet" type="text/css" />' + newLine
|
|
188
|
+
end += '<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-switch/3.3.4/js/bootstrap-switch.js"></script>' + newLine
|
|
189
|
+
|
|
190
|
+
let labels = ''
|
|
191
|
+
if (Array.isArray(array)) {
|
|
192
|
+
labels = '{offText:"' + array[0] + '", onText:"' + array[1] + '"}'
|
|
193
|
+
}
|
|
194
|
+
script += '$("' + elem + '").bootstrapSwitch(' + labels + ');' + newLine
|
|
195
|
+
return {
|
|
196
|
+
head: head,
|
|
197
|
+
end: end,
|
|
198
|
+
script: script,
|
|
199
|
+
}
|
|
200
|
+
}
|
|
208
201
|
|
|
209
202
|
m.switchOld = function (req, res, elem, array) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
203
|
+
let script = ''
|
|
204
|
+
let head = ``
|
|
205
|
+
let end = ``
|
|
206
|
+
elem = elem || '.switch'
|
|
207
|
+
head += '<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet">' + newLine
|
|
208
|
+
end += '<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>' + newLine
|
|
209
|
+
|
|
210
|
+
let labels = ''
|
|
211
|
+
if (Array.isArray(array)) {
|
|
212
|
+
labels = '{off:"' + array[0] + '", on:"' + array[1] + '"}'
|
|
213
|
+
}
|
|
214
|
+
script += `$(function(){$('${elem}').bootstrapToggle(${labels});});${Util.newLine}`
|
|
215
|
+
|
|
216
|
+
return {
|
|
217
|
+
head: head,
|
|
218
|
+
end: end,
|
|
219
|
+
script: script,
|
|
220
|
+
}
|
|
221
|
+
}
|
|
229
222
|
|
|
230
223
|
m.clockpicker = function (req, res, elem) {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
224
|
+
let script = ''
|
|
225
|
+
let head = ``
|
|
226
|
+
let end = ``
|
|
227
|
+
elem = elem || '.clockpicker'
|
|
228
|
+
head += '<link href="https://cdn.jsdelivr.net/npm/clockpicker@0.0.7/dist/jquery-clockpicker.min.css" rel="stylesheet" type="text/css" />' + newLine
|
|
229
|
+
end += '<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/clockpicker@0.0.7/dist/bootstrap-clockpicker.min.js"></script>' + newLine
|
|
230
|
+
script += `$("body").on("click", "${elem}", function(){$(this).clockpicker({donetext: "Done"});});`
|
|
231
|
+
//end += '$("' + elem + '").clockpicker({donetext: "Done"});' + newLine;
|
|
232
|
+
return {
|
|
233
|
+
head: head,
|
|
234
|
+
end: end,
|
|
235
|
+
script: script,
|
|
236
|
+
}
|
|
237
|
+
}
|
|
245
238
|
|
|
246
239
|
m.number = (req, res, elem) => {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
}
|
|
240
|
+
let script = ''
|
|
241
|
+
let head = ``
|
|
242
|
+
let end = ``
|
|
243
|
+
elem = elem || '.number'
|
|
244
|
+
|
|
245
|
+
end += '<script type="text/javascript" src="/js/jquery-currency.js"></script>'
|
|
246
|
+
script += `$(function () { $(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."}); });`
|
|
247
|
+
script += `setTimeout(function () { $("body").click();},1000);`
|
|
248
|
+
script += `$("body").on("click", function(){$(".number").formatCurrencyLive({symbol:"",roundToDecimalPlace :0,digitGroupSymbol :"."});});`
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
head: head,
|
|
252
|
+
end: end,
|
|
253
|
+
script: script,
|
|
254
|
+
}
|
|
255
|
+
}
|
|
263
256
|
|
|
264
257
|
m.typeahead = (req, res, elem, data) => {
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
258
|
+
let script = ''
|
|
259
|
+
let head = ``
|
|
260
|
+
let end = ``
|
|
261
|
+
data = data || []
|
|
262
|
+
elem = elem || '.typeahead'
|
|
263
|
+
end += '<script type="text/javascript" src="/modules/typeahead/typeahead.js"></script>' + newLine
|
|
264
|
+
|
|
265
|
+
let elemData = elem.replace('.', '')
|
|
266
|
+
elemData = elemData.replace('#', '')
|
|
267
|
+
let element = elem.replace('Typeahead', '')
|
|
268
|
+
|
|
269
|
+
script +=
|
|
270
|
+
'const ' +
|
|
271
|
+
elemData +
|
|
272
|
+
'Data = ' +
|
|
273
|
+
JSON.stringify(
|
|
274
|
+
data.filter(function (value, index, arr) {
|
|
275
|
+
return index > 0
|
|
276
|
+
})
|
|
277
|
+
) +
|
|
278
|
+
';' +
|
|
279
|
+
newLine
|
|
280
|
+
script += `$("body").on("change", "${elem}", function(){
|
|
280
281
|
var current = $("${elem}").typeahead("getActive");
|
|
281
282
|
if(current){
|
|
282
283
|
$("${element}").val(current.id);
|
|
283
284
|
$("${element}").change();
|
|
284
285
|
}
|
|
285
|
-
});${Util.newLine}
|
|
286
|
-
|
|
286
|
+
});${Util.newLine}`
|
|
287
|
+
script += `$("body").on("click", "${element}Clear", function(){
|
|
287
288
|
$("${elem}").val("");
|
|
288
289
|
$("${element}").val("");
|
|
289
290
|
$("${elem}").change();
|
|
290
|
-
});${Util.newLine}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
m.custom = (req, res, script, css, src)=> {
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
m.script = (req, res, table) => {
|
|
321
|
-
|
|
322
|
-
};
|
|
291
|
+
});${Util.newLine}`
|
|
292
|
+
script += '$("' + elem + '").typeahead({source: ' + elemData + 'Data ,items: 50, displayText: function(item){ return item.zname.toString();}});' + newLine
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
head: head,
|
|
296
|
+
end: end,
|
|
297
|
+
script: script,
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
m.custom = (req, res, script, css, src) => {
|
|
302
|
+
src = src || ''
|
|
303
|
+
css = css || ''
|
|
304
|
+
let head = res.locals.moduleHead
|
|
305
|
+
let end = res.locals.moduleEnd
|
|
306
|
+
if (script) {
|
|
307
|
+
end += '<script>' + newLine
|
|
308
|
+
end += script + newLine
|
|
309
|
+
end += '</script>' + newLine
|
|
310
|
+
}
|
|
311
|
+
if (css) {
|
|
312
|
+
head += css
|
|
313
|
+
}
|
|
314
|
+
if (src) {
|
|
315
|
+
end += `<script src="${src}"> ${newLine}`
|
|
316
|
+
}
|
|
317
|
+
res.locals.moduleHead = head
|
|
318
|
+
res.locals.moduleEnd = end
|
|
319
|
+
}
|
|
323
320
|
|
|
321
|
+
m.script = (req, res, table) => {}
|
|
324
322
|
|
|
325
323
|
/*
|
|
326
324
|
add scrip code in the body html
|
|
@@ -329,100 +327,114 @@ m.script = (req, res, table) => {
|
|
|
329
327
|
|
|
330
328
|
type : script / css
|
|
331
329
|
*/
|
|
332
|
-
m.addScript = (req, res, contentScript, at =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
m.addModule = (req,res, content, isModuleHead = false) => {
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
m.highchart = async(req, res, obj) => {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
330
|
+
m.addScript = (req, res, contentScript, at = 'end', type = 'script') => {
|
|
331
|
+
if (contentScript) {
|
|
332
|
+
let generateId = 'app_' + Util.generate(6)
|
|
333
|
+
let tagOpen = type == 'script' ? `<script id="${generateId}">` : '<style type="text/css">'
|
|
334
|
+
let tagClose = type == 'script' ? '</script>' : '</style>'
|
|
335
|
+
let content = at == 'end' ? res.locals.moduleEnd : res.locals.moduleHead
|
|
336
|
+
content += tagOpen + newLine
|
|
337
|
+
content += contentScript + newLine
|
|
338
|
+
content += tagClose + newLine
|
|
339
|
+
|
|
340
|
+
if (at == 'end') {
|
|
341
|
+
res.locals.moduleEnd = content
|
|
342
|
+
} else res.locals.moduleHead = content
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
m.addModule = (req, res, content, isModuleHead = false) => {
|
|
347
|
+
let moduleContent = isModuleHead ? res.locals.moduleHead : res.locals.moduleEnd
|
|
348
|
+
moduleContent += content
|
|
349
|
+
if (isModuleHead) {
|
|
350
|
+
res.locals.moduleHead = moduleContent
|
|
351
|
+
} else {
|
|
352
|
+
res.locals.moduleEnd = moduleContent
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
m.highchart = async (req, res, obj) => {
|
|
357
|
+
obj = obj || {}
|
|
358
|
+
let head = res.locals.moduleHead
|
|
359
|
+
let end = res.locals.moduleEnd
|
|
360
|
+
if (end.indexOf('highcharts') < 0) {
|
|
361
|
+
end += '<script src="https://code.highcharts.com/highcharts.js"></script>' + newLine
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if (!Util.isEmptyObject(obj)) {
|
|
365
|
+
const highcharts = require('./highcharts')
|
|
366
|
+
end += '<script>' + newLine
|
|
367
|
+
end += await highcharts.build(obj)
|
|
368
|
+
end += '</script>' + newLine
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
res.locals.moduleHead = head
|
|
372
|
+
res.locals.moduleEnd = end
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
//build auto js and css based on function type
|
|
376
|
+
m.build = (req, res, objData) => {
|
|
377
|
+
let head = res.locals.moduleHead
|
|
378
|
+
let end = res.locals.moduleEnd
|
|
379
|
+
|
|
380
|
+
head += objData.head
|
|
381
|
+
end += objData.end
|
|
382
|
+
if (objData.script) {
|
|
383
|
+
end += `<script>${objData.script}</script>`
|
|
384
|
+
}
|
|
385
|
+
res.locals.moduleHead = head
|
|
386
|
+
res.locals.moduleEnd = end
|
|
375
387
|
}
|
|
376
388
|
|
|
377
389
|
m.tableForm = (req, res, name, table) => {
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
390
|
+
let head = res.locals.moduleHead
|
|
391
|
+
let end = res.locals.moduleEnd
|
|
392
|
+
res.locals.moduleHead = head
|
|
393
|
+
res.locals.moduleEnd = end
|
|
382
394
|
}
|
|
383
395
|
|
|
384
396
|
m.selectYear = (req, res, elem, val, startYear, endYear) => {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
397
|
+
let dt = new Date()
|
|
398
|
+
endYear = endYear || dt.getFullYear()
|
|
399
|
+
val = val || ''
|
|
400
|
+
var options = ''
|
|
401
|
+
for (var i = endYear; i >= startYear; i--) {
|
|
402
|
+
var selected = i == val ? ' selected ' : ''
|
|
403
|
+
options += `<option value="${i}" ${selected}>${i}</option>`
|
|
404
|
+
}
|
|
405
|
+
let end = res.locals.moduleEnd
|
|
406
|
+
end += '<script>' + newLine
|
|
407
|
+
end += `$("${elem}").html('${options}')`
|
|
408
|
+
end += '</script>' + newLine
|
|
409
|
+
res.locals.moduleEnd = end
|
|
398
410
|
}
|
|
399
411
|
|
|
400
412
|
//https://highlightjs.org/usage/
|
|
401
413
|
m.highlight = (req, res, elem) => {
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
414
|
+
elem = elem || '.codes'
|
|
415
|
+
let head = res.locals.moduleHead
|
|
416
|
+
let end = res.locals.moduleEnd
|
|
417
|
+
if (head.indexOf('highlight') < 0) {
|
|
418
|
+
head += '<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/styles/default.min.css"> ' + newLine
|
|
419
|
+
end += '<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.4.1/highlight.min.js"></script>' + newLine
|
|
420
|
+
}
|
|
421
|
+
end += '<script>$(function(){ document.querySelectorAll("' + elem + '").forEach((block) => {hljs.highlightBlock(block);}); })</script>' + newLine
|
|
422
|
+
res.locals.moduleHead = head
|
|
423
|
+
res.locals.moduleEnd = end
|
|
412
424
|
}
|
|
413
425
|
|
|
414
426
|
//https://developer.snapappointments.com/bootstrap-select/
|
|
415
427
|
m.selectpicker = function (req, res, elem) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
module.exports = m
|
|
428
|
+
elem = elem || '.selectpicker'
|
|
429
|
+
let head = res.locals.moduleHead
|
|
430
|
+
let end = res.locals.moduleEnd
|
|
431
|
+
if (head.indexOf('bootstrap-select') < 0) {
|
|
432
|
+
head += '<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/css/bootstrap-select.min.css">' + newLine
|
|
433
|
+
end += '<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.14/dist/js/bootstrap-select.min.js"></script>' + newLine
|
|
434
|
+
end += `<script>$(function () {$('${elem}').selectpicker();});</script>${newLine}`
|
|
435
|
+
}
|
|
436
|
+
res.locals.moduleHead = head
|
|
437
|
+
res.locals.moduleEnd = end
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
module.exports = m
|
package/lib/zRoute.js
CHANGED
|
@@ -2558,14 +2558,14 @@ zRoute.moduleLib = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
2558
2558
|
|
|
2559
2559
|
//add script for dropdown multi in table type
|
|
2560
2560
|
//stupid way temporary
|
|
2561
|
-
let scriptTemp = ''
|
|
2562
|
-
for(let keys in MYMODEL.widgets) {
|
|
2563
|
-
if(MYMODEL.widgets[keys].name ==
|
|
2564
|
-
let MODEL_TABLE = require(`${dirRoot}/models/${MYMODEL.widgets[keys].table}`)
|
|
2565
|
-
for(let key in MODEL_TABLE.widgets) {
|
|
2566
|
-
if(MODEL_TABLE.widgets[key].name ==
|
|
2567
|
-
let relObject = relations[keys+'Row'][key+'Object']
|
|
2568
|
-
scriptTemp += `<script>var ${key}Object = ${JSON.stringify(relObject)};</script>${Util.newLine}
|
|
2561
|
+
let scriptTemp = ''
|
|
2562
|
+
for (let keys in MYMODEL.widgets) {
|
|
2563
|
+
if (MYMODEL.widgets[keys].name == 'table') {
|
|
2564
|
+
let MODEL_TABLE = require(`${dirRoot}/models/${MYMODEL.widgets[keys].table}`)
|
|
2565
|
+
for (let key in MODEL_TABLE.widgets) {
|
|
2566
|
+
if (MODEL_TABLE.widgets[key].name == 'dropdown_multi') {
|
|
2567
|
+
let relObject = relations[keys + 'Row'][key + 'Object']
|
|
2568
|
+
scriptTemp += `<script>var ${key}Object = ${JSON.stringify(relObject)};</script>${Util.newLine}`
|
|
2569
2569
|
}
|
|
2570
2570
|
}
|
|
2571
2571
|
}
|
|
@@ -2878,7 +2878,7 @@ zRoute.generateJS = (req, res, MYMODEL, relations, zForms = '', data = {}) => {
|
|
|
2878
2878
|
for (let qq in MODEL_TABLE.widgets) {
|
|
2879
2879
|
//check if have dropdown_multi
|
|
2880
2880
|
if (MODEL_TABLE.widgets[qq].name == 'dropdown_multi') {
|
|
2881
|
-
dropdownMultis.push(qq)
|
|
2881
|
+
dropdownMultis.push(qq)
|
|
2882
2882
|
scriptForm += `$("#body-${keys}").on("click", "#dropdownadd${qq}",function () {
|
|
2883
2883
|
let elm = $(this).siblings("#${qq}");
|
|
2884
2884
|
var val = elm.val();
|