zet-lib 1.3.40 → 1.3.42
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/LICENSE +21 -21
- package/README.md +15 -15
- package/lib/ErrorWithCode.js +6 -6
- package/lib/Form.js +1020 -1019
- package/lib/Mail.js +68 -68
- package/lib/Modal.js +95 -95
- package/lib/Pool.js +437 -437
- package/lib/UI.js +7 -7
- package/lib/Util.js +1384 -1384
- package/lib/access.js +6 -6
- package/lib/cache.js +3 -3
- package/lib/connection.js +409 -409
- package/lib/debug.js +22 -22
- package/lib/index.js +36 -36
- package/lib/io.js +44 -44
- package/lib/languages/lang_en.js +125 -125
- package/lib/languages/lang_fr.js +125 -125
- package/lib/languages/lang_id.js +126 -126
- package/lib/languages/lang_jp.js +125 -125
- package/lib/moduleLib.js +661 -661
- package/lib/tableForm.js +10 -10
- package/lib/views/generator.ejs +598 -598
- package/lib/views/generator_layout.ejs +224 -224
- package/lib/views/generatorjs.ejs +927 -927
- package/lib/zAppRouter.js +1637 -1637
- package/lib/zCache.js +301 -301
- package/lib/zComponent.js +27 -27
- package/lib/zFn.js +58 -58
- package/lib/zFunction.js +20 -20
- package/lib/zGeneratorRouter.js +1641 -1641
- package/lib/zMenuRouter.js +556 -556
- package/lib/zPage.js +188 -188
- package/lib/zReport.js +982 -982
- package/lib/zRole.js +256 -256
- package/lib/zRoleRouter.js +609 -609
- package/lib/zRoute.js +5787 -5025
- package/lib/zTester.js +93 -93
- package/lib/zapp.js +65 -65
- package/lib/zdataTable.js +330 -330
- package/package.json +56 -56
package/lib/Form.js
CHANGED
|
@@ -1,1019 +1,1020 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Universal class Form UI HTML
|
|
3
|
-
* Created by sintret dev on 8/23/2021.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
const Util = require('./Util')
|
|
7
|
-
|
|
8
|
-
const Form = {}
|
|
9
|
-
const addProperties = (obj, defaultObj = {}) => {
|
|
10
|
-
let html = ''
|
|
11
|
-
for (var key in obj) {
|
|
12
|
-
var value = defaultObj.hasOwnProperty(key) ? defaultObj[key] + obj[key] : obj[key]
|
|
13
|
-
html += ` ${key}="${obj[key]}" `
|
|
14
|
-
}
|
|
15
|
-
return html
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
Form.options = {
|
|
19
|
-
button: {
|
|
20
|
-
id: 'form-submit',
|
|
21
|
-
type: 'button',
|
|
22
|
-
class: 'btn btn-success boxy',
|
|
23
|
-
label: `<img src="/assets/icons/send.svg" class="icons-bg-white" > Submit`,
|
|
24
|
-
},
|
|
25
|
-
field: {},
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
Form.label = (field, label, required, htmlOptions = '') => {
|
|
29
|
-
required = required || false
|
|
30
|
-
const mark = required ? '*' : ''
|
|
31
|
-
return `<label for="${field}">${label} ${mark} ${htmlOptions}</label>`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Form.textarea = (obj) => {
|
|
35
|
-
obj.type = 'textarea'
|
|
36
|
-
return Form.field(obj)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
Form.input = (obj) => {
|
|
40
|
-
obj.type = 'input'
|
|
41
|
-
return Form.field(obj)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
Form.addProperty = (property, options = []) => {
|
|
45
|
-
///We expect options to be a non-empty Array
|
|
46
|
-
if (!options.length) return
|
|
47
|
-
var optionsString = options.join(' ')
|
|
48
|
-
return ` ${property}="${optionsString}" `
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
Form.field = (obj) => {
|
|
52
|
-
//options and default options
|
|
53
|
-
let options = obj.options || {}
|
|
54
|
-
let htmlOptions = ''
|
|
55
|
-
for (let key in options) {
|
|
56
|
-
let val = options[key]
|
|
57
|
-
val = Util.replaceAll(val, '"', '')
|
|
58
|
-
if (obj.hasOwnProperty(key)) {
|
|
59
|
-
obj[key] = options[key]
|
|
60
|
-
} else {
|
|
61
|
-
htmlOptions += ` ${key}=${val} `
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
let type = obj.type || 'text',
|
|
65
|
-
id = obj.isTableModule ? '' : Form.addProperty('id', [obj.id]),
|
|
66
|
-
name = obj.name ? ` name="${obj.name}" ` : '',
|
|
67
|
-
title = obj.title || '',
|
|
68
|
-
prepend = obj.prepend || '',
|
|
69
|
-
append = obj.append || '',
|
|
70
|
-
placeholder = Form.addProperty('placeholder', [obj.placeholder]),
|
|
71
|
-
tabindex = Form.addProperty('tabindex', [obj.tabindex]),
|
|
72
|
-
value = obj.value == undefined ? '' : obj.value,
|
|
73
|
-
classview = obj.class ? ` class="${obj.class}" ` : ` class=" " `,
|
|
74
|
-
disabled = obj.disabled ? ` disabled="disabled" ` : '',
|
|
75
|
-
data = obj.data,
|
|
76
|
-
required = obj.required == true ? ` required ` : '',
|
|
77
|
-
table = !obj.table ? '' : obj.table,
|
|
78
|
-
frameworkcss = !obj.frameworkcss ? 'bootstrap5' : obj.frameworkcss,
|
|
79
|
-
form_css = !obj.form_css ? 'bootstrap' : obj.form_css,
|
|
80
|
-
attributes = !obj.attributes ? {} : obj.attributes,
|
|
81
|
-
style = !obj.style ? '' : ` style=${obj.style} `,
|
|
82
|
-
additional_attributes = !obj.additional_attributes ? '' : obj.additional_attributes,
|
|
83
|
-
information = !obj.information ? '' : `<div id="information-${obj.id}" class="form-text">${Util.replaceAll(obj.information.substring(1, obj.information.length - 1), '\r\n', '<br>')}</div>`
|
|
84
|
-
//replaceAll("\r\n","<br>")
|
|
85
|
-
let attributeDate = ''
|
|
86
|
-
if (obj.hasOwnProperty.attributeData) {
|
|
87
|
-
for (let key in obj.attributeData) {
|
|
88
|
-
attributeDate += ` data-${key}="${obj.attributeData[key]}" `
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
let hasInputGroup = false
|
|
92
|
-
let inputGroupLeft = '',
|
|
93
|
-
inputGroupRight = '',
|
|
94
|
-
inputGroupDivLeft = ''
|
|
95
|
-
if (attributes.hasOwnProperty('hasInputGroup') && attributes.hasInputGroup) {
|
|
96
|
-
hasInputGroup = true
|
|
97
|
-
prepend = `<div class="input-group mb-3">`
|
|
98
|
-
append = `</div>`
|
|
99
|
-
if (attributes.hasOwnProperty('inputGroupLeft') && attributes.inputGroupLeft) {
|
|
100
|
-
inputGroupLeft = `<span class="input-group-text">${attributes.inputGroupLeft}</span>`
|
|
101
|
-
}
|
|
102
|
-
if (attributes.hasOwnProperty('inputGroupRight') && attributes.inputGroupRight) {
|
|
103
|
-
inputGroupRight = `<span class="input-group-text">${attributes.inputGroupRight}</span>`
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
let displayForm = ''
|
|
107
|
-
let readonly = obj.readonly ? `readonly` : ``
|
|
108
|
-
let boxyclass = '',
|
|
109
|
-
checked = '',
|
|
110
|
-
selects = ''
|
|
111
|
-
switch (type) {
|
|
112
|
-
case 'text':
|
|
113
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" ${disabled} ${readonly} autofocus="" ${tabindex} ${additional_attributes} type="${type}" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
114
|
-
break
|
|
115
|
-
|
|
116
|
-
case 'checkbox':
|
|
117
|
-
checked = value == 1 ? 'checked' : ''
|
|
118
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} ${disabled} ${readonly} ${additional_attributes} ${style} type="checkbox" class="form-check-input ${obj.class}" ${id} ${name} ${checked} ${htmlOptions}>${information}${append}`
|
|
119
|
-
break
|
|
120
|
-
|
|
121
|
-
case 'tags':
|
|
122
|
-
classview = ` class="form-control tags ${obj.class ? obj.class : ''} " `
|
|
123
|
-
let datahtml = ''
|
|
124
|
-
if (value) {
|
|
125
|
-
let dataValue = []
|
|
126
|
-
if (typeof value == 'string') {
|
|
127
|
-
dataValue = JSON.parse(value) || []
|
|
128
|
-
} else {
|
|
129
|
-
dataValue = value || []
|
|
130
|
-
}
|
|
131
|
-
dataValue.forEach(function (item) {
|
|
132
|
-
datahtml += `<option value="${item}" selected="selected">${item}</option>`
|
|
133
|
-
})
|
|
134
|
-
}
|
|
135
|
-
displayForm = `${prepend}<select ${classview} ${id} ${name} ${additional_attributes} ${placeholder} multiple data-allow-new="true">${datahtml}</select>${information}${append}`
|
|
136
|
-
break
|
|
137
|
-
|
|
138
|
-
case 'range':
|
|
139
|
-
let min = !obj.min ? 0 : obj.min
|
|
140
|
-
let max = !obj.max ? 100 : obj.max
|
|
141
|
-
displayForm = `${prepend}${inputGroupLeft}<input onmouseover="titlerange(this)" onchange="titlerange(this)" autocomplete="off" autofocus="" ${tabindex} type="${type}" class="form-range ${obj.class}" step="1" ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" min="${min}" max="${max}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
142
|
-
break
|
|
143
|
-
|
|
144
|
-
case 'hidden':
|
|
145
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} type="${type}" ${additional_attributes} ${style} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${append}`
|
|
146
|
-
break
|
|
147
|
-
|
|
148
|
-
case 'textarea':
|
|
149
|
-
displayForm = `${prepend}${inputGroupLeft}<textarea ${tabindex} ${disabled} class="form-control ${obj.class}" ${id} ${name} ${additional_attributes} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${value}</textarea>${inputGroupRight}${information}${append}`
|
|
150
|
-
break
|
|
151
|
-
|
|
152
|
-
case 'image':
|
|
153
|
-
boxyclass = value ? 'boxy' : ''
|
|
154
|
-
let stringvalue = value ? value.substring(13) : ''
|
|
155
|
-
let trashicon = stringvalue ? `<img class="tabler-icons icons-filter-danger" src="/assets/icons/trash-filled.svg" onclick="removeimage(this)">` : ''
|
|
156
|
-
displayForm = `${prepend}<input ${tabindex} type="file" accept="image/*" onchange="loadFile(this,'${obj.id}' )" data-width="${obj.width}" class="form-control ${obj.class || ''}" ${id} ${name} ${placeholder} value="${value}" ${htmlOptions}>
|
|
157
|
-
<div id="body${obj.id}" class="isfile" data-id="${obj.id}" data-table="${obj.routeName}" data-width="${obj.width}" data-name="${obj.title}" data-filename="${value}" data-required="${obj.required}"> <img class="mb-3" width="${obj.width}" id="file${obj.id}" /><br><a class="text-success" target="_blank" href="/uploads/${
|
|
158
|
-
obj.routeName
|
|
159
|
-
}/${value}"> ${stringvalue}</a> ${trashicon}</div>${append}`
|
|
160
|
-
break
|
|
161
|
-
|
|
162
|
-
case 'file':
|
|
163
|
-
boxyclass = value ? 'boxy' : ''
|
|
164
|
-
let stringvaluefile = value ? value.substring(13) : ''
|
|
165
|
-
let trashiconfile = stringvaluefile ? `<img class="tabler-icons icons-filter-danger" src="/assets/icons/trash-filled.svg" onclick="removeimage(this)">` : ''
|
|
166
|
-
displayForm = `${prepend}<input ${tabindex} type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,text/plain, application/pdf,.css,.js,.jpg,.png,.gif" onchange="loadFile(this,'${obj.id}' )" class="form-control ${
|
|
167
|
-
obj.class || ''
|
|
168
|
-
}" ${id} ${name} ${placeholder} value="${value}" ${htmlOptions}>
|
|
169
|
-
<div id="body${obj.id}" class="isfile" data-id="${obj.id}" data-name="${obj.title}" data-table="${obj.routeName}" data-filename="${value}" data-required="${obj.required}"> <img class="mb-3" id="file${obj.id}" /><a class="text-success" target="_blank" href="/uploads/${
|
|
170
|
-
obj.routeName
|
|
171
|
-
}/${value}"> ${stringvaluefile}</a>${trashiconfile}</div>${information}${append}`
|
|
172
|
-
break
|
|
173
|
-
|
|
174
|
-
case 'email':
|
|
175
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${readonly} ${disabled} ${additional_attributes} ${tabindex} ${style} type="email" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
176
|
-
break
|
|
177
|
-
|
|
178
|
-
case 'number':
|
|
179
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="text" class="form-control number ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
180
|
-
break
|
|
181
|
-
|
|
182
|
-
case 'integer':
|
|
183
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="number" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
184
|
-
break
|
|
185
|
-
|
|
186
|
-
case 'datepicker':
|
|
187
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="text" class="form-control datepicker ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
188
|
-
break
|
|
189
|
-
|
|
190
|
-
case 'datetimepicker':
|
|
191
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} type="text" ${style} class="form-control datetimepicker ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
192
|
-
break
|
|
193
|
-
|
|
194
|
-
case 'password':
|
|
195
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="password" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}><span toggle="#password" class="bx bi-eye field-icon toggle-password"></span>${inputGroupRight}${information}${append}`
|
|
196
|
-
break
|
|
197
|
-
|
|
198
|
-
case 'switch':
|
|
199
|
-
checked = value == 1 ? ' checked ' : ''
|
|
200
|
-
displayForm = `${prepend}<p><input ${tabindex} type="checkbox" class="form-control ${obj.class}" ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} ></p>${information}${append}`
|
|
201
|
-
break
|
|
202
|
-
|
|
203
|
-
case 'lexical':
|
|
204
|
-
displayForm = `${prepend}<div ${id}>${information}${append}`
|
|
205
|
-
break
|
|
206
|
-
|
|
207
|
-
case 'checkbox':
|
|
208
|
-
checked = value == 1 ? ' checked ' : ''
|
|
209
|
-
displayForm = `${prepend}<input ${tabindex} type="${type}" class="form-control ${obj.class}" ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} >${information}${append}`
|
|
210
|
-
break
|
|
211
|
-
|
|
212
|
-
case 'dropdown_checkbox':
|
|
213
|
-
let checkboxes = ''
|
|
214
|
-
let val = []
|
|
215
|
-
if (typeof value == 'object') {
|
|
216
|
-
val = value
|
|
217
|
-
} else if (typeof value == 'string') {
|
|
218
|
-
if (value) {
|
|
219
|
-
val = JSON.parse(value)
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
data.forEach(function (item) {
|
|
223
|
-
const checked = Util.in_array(item, val) ? ' checked ' : ''
|
|
224
|
-
checkboxes += `<div class="checkbox">
|
|
225
|
-
<label class="">
|
|
226
|
-
<input type="checkbox" name="${obj.name}[${item}]" ${checked} value="${item}">
|
|
227
|
-
${item}
|
|
228
|
-
</label>
|
|
229
|
-
</div>`
|
|
230
|
-
})
|
|
231
|
-
displayForm = `${prepend}<div class="form-check">${checkboxes}</div>${information}${append}`
|
|
232
|
-
break
|
|
233
|
-
|
|
234
|
-
case 'select':
|
|
235
|
-
var please_select = obj.please_select
|
|
236
|
-
if (please_select != undefined) {
|
|
237
|
-
if (please_select != '') {
|
|
238
|
-
selects += `<option value="">${please_select}</option>`
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
if (obj.hasOwnProperty('array')) {
|
|
242
|
-
var items = obj.array || []
|
|
243
|
-
if (items.length) {
|
|
244
|
-
items.forEach(function (item) {
|
|
245
|
-
if (item.label) {
|
|
246
|
-
const selected = item.value == value ? ' selected ' : ''
|
|
247
|
-
selects += `<option value="${item.value}" ${selected}>${item.label}</option>`
|
|
248
|
-
}
|
|
249
|
-
})
|
|
250
|
-
} else {
|
|
251
|
-
if (Array.isArray(data)) {
|
|
252
|
-
data.map((item) => {
|
|
253
|
-
if (item.zname) {
|
|
254
|
-
var selected = item.id == value ? ' selected ' : ''
|
|
255
|
-
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
256
|
-
}
|
|
257
|
-
})
|
|
258
|
-
} else {
|
|
259
|
-
for (var keys in data) {
|
|
260
|
-
if (data[keys]) {
|
|
261
|
-
var selected = keys == value ? ' selected ' : ''
|
|
262
|
-
selects += `<option value="${keys}" ${selected}>${data[keys]}</option>`
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
} else {
|
|
268
|
-
if (Array.isArray(data)) {
|
|
269
|
-
data.map((item) => {
|
|
270
|
-
if (item.zname) {
|
|
271
|
-
const selected = item.id == value ? ' selected ' : ''
|
|
272
|
-
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
273
|
-
}
|
|
274
|
-
})
|
|
275
|
-
} else {
|
|
276
|
-
for (let keys in data) {
|
|
277
|
-
if (data[keys]) {
|
|
278
|
-
let selected = keys == value ? ' selected ' : ''
|
|
279
|
-
selects += `<option value="${keys}" ${selected}>${data[keys]}</option>`
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
if (form_css == 'material_design') {
|
|
285
|
-
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
286
|
-
}
|
|
287
|
-
displayForm = `${prepend}<select ${tabindex} ${style} ${additional_attributes} ${disabled} ${readonly} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
288
|
-
break
|
|
289
|
-
|
|
290
|
-
case 'radio':
|
|
291
|
-
let radios = ''
|
|
292
|
-
let arr = obj.array || []
|
|
293
|
-
arr.map((item, index) => {
|
|
294
|
-
//var selected = item.value == value ? ' selected ' : '';
|
|
295
|
-
const checked = item.value == value ? ' checked ' : ''
|
|
296
|
-
radios += `<div class="form-check">
|
|
297
|
-
<input class="form-check-input ${obj.class}" type="radio" name="${obj.name}" ${additional_attributes} value="${item.value}" id="${obj.id}${index}" ${checked}>
|
|
298
|
-
<label class="form-check-label" for="${obj.id}${index}">
|
|
299
|
-
${item.label}
|
|
300
|
-
</label>
|
|
301
|
-
</div>`
|
|
302
|
-
})
|
|
303
|
-
displayForm = `${prepend} ${radios} ${information}${append}`
|
|
304
|
-
break
|
|
305
|
-
|
|
306
|
-
case 'select_user':
|
|
307
|
-
selects = ''
|
|
308
|
-
data.map((item) => {
|
|
309
|
-
const selected = item.value == value ? ' selected ' : ''
|
|
310
|
-
selects += `<option value="${item.id}" ${selected}>${item.fullname}</option>`
|
|
311
|
-
})
|
|
312
|
-
|
|
313
|
-
if (form_css == 'material_design') {
|
|
314
|
-
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
315
|
-
}
|
|
316
|
-
displayForm = `${prepend}<select ${tabindex} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
317
|
-
break
|
|
318
|
-
|
|
319
|
-
case 'chain':
|
|
320
|
-
selects = ''
|
|
321
|
-
// for array item.value and item.text
|
|
322
|
-
// proptery is value and text
|
|
323
|
-
data.map((item) => {
|
|
324
|
-
var selected = item.id == value ? ' selected ' : ''
|
|
325
|
-
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
326
|
-
})
|
|
327
|
-
if (form_css == 'material_design') {
|
|
328
|
-
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
329
|
-
}
|
|
330
|
-
displayForm = `${prepend}<select ${tabindex} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
331
|
-
break
|
|
332
|
-
|
|
333
|
-
case 'multi':
|
|
334
|
-
selects = ''
|
|
335
|
-
if (data) {
|
|
336
|
-
data.map((item) => {
|
|
337
|
-
selects += `<option value="${item.id}">${item.zname}</option>`
|
|
338
|
-
})
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
var spanmulti = ''
|
|
342
|
-
if (value) {
|
|
343
|
-
let arr = []
|
|
344
|
-
arr = typeof value == 'string' ? JSON.parse(value) : value
|
|
345
|
-
if (Array.isArray(arr)) {
|
|
346
|
-
arr.forEach(function (item, index) {
|
|
347
|
-
spanmulti += `<span class='span${obj.id}'>${index + 1}. <input type='hidden' name='${obj.name}[]' value='${item}' />${obj.multi[item]}<img class='tabler-icons icons-filter-danger pull-right' src='/assets/icons/trash-filled.svg' onclick='$(this).closest("span").remove();' title='${LANGUAGE['delete']}' /><br></span>`
|
|
348
|
-
})
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
if (form_css == 'material_design') {
|
|
352
|
-
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
let g = `<div class="input-group ">
|
|
356
|
-
<span class="input-group-text" id="dropdownadd${id}" class="dropdownadd" data-id="${id}" style="cursor: pointer" title="Add Data">+</span>
|
|
357
|
-
</div>
|
|
358
|
-
<div id="dropdownbox${id}" class="boxy">
|
|
359
|
-
<span class="span${id}">
|
|
360
|
-
</span>
|
|
361
|
-
</div>`
|
|
362
|
-
return `<div class="input-group">
|
|
363
|
-
<select ${tabindex} class="form-control ${obj.class} dropdown-multi" name='${obj.name}' ${id} ${placeholder} ${htmlOptions} >${selects}</select>
|
|
364
|
-
<span id="dropdownadd${obj.id}" class="input-group-text dropdownadd" data-id="${obj.id}" style="cursor: pointer;" title=" ${LANGUAGE['form_add_data']} ">+</span>
|
|
365
|
-
</div>
|
|
366
|
-
<div id="dropdownbox${obj.id}" class="boxy mb-3">${spanmulti}</div>`
|
|
367
|
-
break
|
|
368
|
-
|
|
369
|
-
case 'typeahead':
|
|
370
|
-
let typeahead_value = Util.replaceAll(obj.typeaheadvalue, '"', `'`)
|
|
371
|
-
displayForm = `${prepend}<div class="input-group">
|
|
372
|
-
<input ${tabindex} type="text" class="form-control ${obj.class}" id="${obj.id}Typeahead" autocomplete="off" data-provide="typeahead" id="${obj.id}Typeahead" placeholder="Please type a word" value="${typeahead_value}" >
|
|
373
|
-
<input type="hidden" ${id} ${name} ${placeholder} ${classview} ${required} value="${value}">
|
|
374
|
-
<span id="${obj.id}Clear" class="input-group-addon input-group-text dropdownadd" title="Clear" style="cursor: pointer;" title=" Add Data "><img src="/assets/icons/ban.svg" class="icons-bg-black" ></span>
|
|
375
|
-
</div>${information}${append}`
|
|
376
|
-
break
|
|
377
|
-
|
|
378
|
-
case 'table':
|
|
379
|
-
let html = ''
|
|
380
|
-
/*console.log(`table : ${JSON.stringify(obj.data)}`)
|
|
381
|
-
console.log(JSON.stringify(obj.data))
|
|
382
|
-
console.log(JSON.stringify(obj.properties));*/
|
|
383
|
-
for (let key in obj.data) {
|
|
384
|
-
if (obj.properties[key].hidden) {
|
|
385
|
-
html += `<th></th>`
|
|
386
|
-
} else {
|
|
387
|
-
html += `<th>${obj.data[key]}</th>`
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
let btnAdd = ''
|
|
391
|
-
if (!obj.isAddButton && !obj.viewOnly) {
|
|
392
|
-
btnAdd = `<th class="float-end"><img id="add${obj.id}" src="/assets/icons/plus.svg" class="icons-bg-white boxy-small btn-plus" ></th>`
|
|
393
|
-
}
|
|
394
|
-
obj.btnAdd = btnAdd
|
|
395
|
-
obj.html = html
|
|
396
|
-
obj.title = title
|
|
397
|
-
obj.table = table
|
|
398
|
-
obj.value = value
|
|
399
|
-
let datavalue = ''
|
|
400
|
-
if (obj.value) {
|
|
401
|
-
datavalue = JSON.stringify(obj.value)
|
|
402
|
-
datavalue = Util.replaceAll(datavalue, "'", '`')
|
|
403
|
-
}
|
|
404
|
-
obj.prepend = prepend
|
|
405
|
-
obj.body = `<div class="table-responsive">
|
|
406
|
-
<table id="table${obj.id}" class="table table-hover table-sm">
|
|
407
|
-
<thead>
|
|
408
|
-
<tr>
|
|
409
|
-
${html}
|
|
410
|
-
${obj.btnAdd}
|
|
411
|
-
</tr>
|
|
412
|
-
</thead>
|
|
413
|
-
<tbody id="body-${obj.id}" data-value='${datavalue}'>${obj.bodyTable}</tbody>
|
|
414
|
-
</table></div>`
|
|
415
|
-
displayForm = Form.card(frameworkcss, obj)
|
|
416
|
-
break
|
|
417
|
-
|
|
418
|
-
case 'multi_line_editor':
|
|
419
|
-
value = obj.value ? obj.value : {}
|
|
420
|
-
let description = obj.description || ''
|
|
421
|
-
for (var key in obj.fields) {
|
|
422
|
-
let val = !value[key] ? obj.fields[key] : value[key]
|
|
423
|
-
description = Util.replaceAll(description, `[[[${key}]]]`, `<span class="text-danger text-toggle" id="a_${key}" data-id="${key}" style="text-decoration: underline; cursor: pointer">${val}</span> <input type="hidden" name="${obj.name}[${key}]" class="editor-value" id="${key}" data-id="${key}" value="${val}" >`)
|
|
424
|
-
}
|
|
425
|
-
displayForm = `${prepend}<div class="boxy">${description}</div>${information}${append}`
|
|
426
|
-
break
|
|
427
|
-
|
|
428
|
-
case 'ide_editor':
|
|
429
|
-
displayForm = `<div class="ide_editor" id="editor_${obj.id}"></div>`
|
|
430
|
-
displayForm += `<textarea hidden ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4"></textarea>${information}${append}`
|
|
431
|
-
break
|
|
432
|
-
|
|
433
|
-
case 'json':
|
|
434
|
-
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
435
|
-
break
|
|
436
|
-
|
|
437
|
-
case 'json_array':
|
|
438
|
-
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
439
|
-
break
|
|
440
|
-
|
|
441
|
-
case 'dragdrop':
|
|
442
|
-
//dataObject
|
|
443
|
-
let leftButtons = ``
|
|
444
|
-
let rightButtons = ``
|
|
445
|
-
let all = Object.keys(obj.dataObject)
|
|
446
|
-
all.map((item, index) => {
|
|
447
|
-
if (!value.includes(item)) {
|
|
448
|
-
rightButtons += `<li><button class="btn btn-danger boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='trashx' value="${item}"></button></li>`
|
|
449
|
-
}
|
|
450
|
-
})
|
|
451
|
-
value = value || []
|
|
452
|
-
value.map((item, index) => {
|
|
453
|
-
leftButtons += `<li><button class="btn btn-primary boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='${obj.name}[]' value="${item}"></button></li>`
|
|
454
|
-
})
|
|
455
|
-
|
|
456
|
-
displayForm += `<div id="dragdrop_${obj.id}" class="row contentfields">
|
|
457
|
-
<div class="col-md-6">
|
|
458
|
-
<h5>${obj.attributes.left}</h5>
|
|
459
|
-
<ol class="mydragable${obj.id} divboxlittle" data-type="left" data-name="${obj.name}[]">${leftButtons}</ol>
|
|
460
|
-
</div>
|
|
461
|
-
<div class="col-md-6">
|
|
462
|
-
<h5>${obj.attributes.right}</h5>
|
|
463
|
-
<ol class="mydragable${obj.id} divboxlittle" data-type="right" data-name="trashx">
|
|
464
|
-
${rightButtons}
|
|
465
|
-
</ol>
|
|
466
|
-
</div>
|
|
467
|
-
</div>`
|
|
468
|
-
break
|
|
469
|
-
|
|
470
|
-
case 'array':
|
|
471
|
-
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
472
|
-
break
|
|
473
|
-
|
|
474
|
-
case 'virtual':
|
|
475
|
-
displayForm = `${prepend}<input ${additional_attributes} autocomplete="off" autofocus="" ${tabindex} ${style} type="text" ${classview} readonly ${id} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
476
|
-
break
|
|
477
|
-
|
|
478
|
-
//additionals for form view in view
|
|
479
|
-
case 'plaintext':
|
|
480
|
-
displayForm = `<span class="">${obj.value || ''}</span>`
|
|
481
|
-
break
|
|
482
|
-
|
|
483
|
-
case 'div':
|
|
484
|
-
displayForm = `<div id="${obj.id}" class="${obj.class}">${obj.value}</div>`
|
|
485
|
-
break
|
|
486
|
-
|
|
487
|
-
case 'data_table':
|
|
488
|
-
displayForm = obj.html
|
|
489
|
-
break
|
|
490
|
-
|
|
491
|
-
case 'location':
|
|
492
|
-
displayForm = `${prepend}<input type="text" class="form-control ${obj.class}" id="search_map_location" placeholder="type a place" ${required} value="" ${htmlOptions}>${information}${append}
|
|
493
|
-
<textarea ${id} ${name} style="display: none" ${readonly} rows="2">${JSON.stringify(obj.value)}</textarea>
|
|
494
|
-
<div id="map_${obj.id}" style="background-color:#C3C3C3;width: 100%;height: ${obj.height}px"></div>`
|
|
495
|
-
break
|
|
496
|
-
|
|
497
|
-
case 'dropzone':
|
|
498
|
-
displayForm = `${prepend}<div ${tabindex} ${style} type="text" ${classview} ${id} ${htmlOptions}><label for="files" class="dropzone-container">
|
|
499
|
-
<div class="dz-message" data-dz-message><div class="file-icon"><span class="icon-small icons-primary"><img class="icons-bg-white icon-image-large" src="/assets/icons/file-plus.svg"></span></div>
|
|
500
|
-
<div class="text-center pt-3 px-5">
|
|
501
|
-
<p class="w-80 h5 text-dark fw-bold">Drag your documents, photos or videos here to start uploading.</p>
|
|
502
|
-
</div></div>
|
|
503
|
-
</label></div>${information}${append}`
|
|
504
|
-
break
|
|
505
|
-
|
|
506
|
-
case 'dropzoneview':
|
|
507
|
-
let countFiles = obj.value && obj.value.length ? obj.value.length + ' Files' : ''
|
|
508
|
-
let bodydropzoneview =
|
|
509
|
-
countFiles == '' ? '' : `<div class="card-header">${countFiles} <div class="float-end"><span class="icon-small icons-light" title="Download"><img onclick="location.href= '/zdownloads-dropzone/${obj.routeName}/${obj.key}/${obj.dataId}'" class="icons-bg-black gridview icon-image" src="/assets/icons/download.svg"></span></div> </div>`
|
|
510
|
-
displayForm = `<div class="card">
|
|
511
|
-
${bodydropzoneview}
|
|
512
|
-
<div class="card-body">`
|
|
513
|
-
if (obj.value && obj.value.length > 0) {
|
|
514
|
-
obj.value.map((item) => {
|
|
515
|
-
let extFile = Util.fileExtension(item)
|
|
516
|
-
let filename = `/uploads/${obj.table}/${obj.key}/${item}`
|
|
517
|
-
if (extFile.type == 'image') {
|
|
518
|
-
displayForm += `<img src="${filename}" class="boxy zoom mx-2 my-2" width="200px">`
|
|
519
|
-
} else {
|
|
520
|
-
displayForm += '<br>' + Util.fileView(`/uploads/${obj.table}/${obj.key}/`, item, { withIcon: true }) + '<br>'
|
|
521
|
-
}
|
|
522
|
-
})
|
|
523
|
-
}
|
|
524
|
-
displayForm += `</div></div>`
|
|
525
|
-
|
|
526
|
-
break
|
|
527
|
-
default:
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
let
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
val =
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
html
|
|
557
|
-
html +=
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
{ text: LANGUAGE['
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
{ text: LANGUAGE['
|
|
619
|
-
{ text: LANGUAGE['
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
{ text: LANGUAGE['
|
|
627
|
-
{ text: LANGUAGE['
|
|
628
|
-
{ text: LANGUAGE['
|
|
629
|
-
{ text: LANGUAGE['
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
{ text: LANGUAGE['
|
|
637
|
-
{ text: LANGUAGE['
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
{ text: LANGUAGE['
|
|
645
|
-
{ text: LANGUAGE['
|
|
646
|
-
{ text: LANGUAGE['
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
{ text: LANGUAGE['
|
|
654
|
-
{ text: LANGUAGE['
|
|
655
|
-
{ text: LANGUAGE['
|
|
656
|
-
{ text: '
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
let
|
|
680
|
-
let
|
|
681
|
-
let
|
|
682
|
-
let
|
|
683
|
-
let
|
|
684
|
-
let
|
|
685
|
-
|
|
686
|
-
${
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
<div class="
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
${obj.
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
let
|
|
722
|
-
let
|
|
723
|
-
let
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
<a class="dropdown-item export-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
${
|
|
761
|
-
${
|
|
762
|
-
|
|
763
|
-
<button type="button" class="btn btn-
|
|
764
|
-
<button type="button"
|
|
765
|
-
<
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
<a class="dropdown-item export-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
let
|
|
785
|
-
html
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
<div class="
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
<
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
html
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
<
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
let
|
|
832
|
-
let
|
|
833
|
-
let
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
let
|
|
837
|
-
let
|
|
838
|
-
let
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
}
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
no
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
<
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
<input type="hidden" id="
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
<
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
<button title="
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
</div
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
<
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
</div
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
<
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
</div
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const
|
|
998
|
-
const
|
|
999
|
-
const
|
|
1000
|
-
const
|
|
1001
|
-
const
|
|
1002
|
-
const
|
|
1003
|
-
const
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
${
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Universal class Form UI HTML
|
|
3
|
+
* Created by sintret dev on 8/23/2021.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const Util = require('./Util')
|
|
7
|
+
|
|
8
|
+
const Form = {}
|
|
9
|
+
const addProperties = (obj, defaultObj = {}) => {
|
|
10
|
+
let html = ''
|
|
11
|
+
for (var key in obj) {
|
|
12
|
+
var value = defaultObj.hasOwnProperty(key) ? defaultObj[key] + obj[key] : obj[key]
|
|
13
|
+
html += ` ${key}="${obj[key]}" `
|
|
14
|
+
}
|
|
15
|
+
return html
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
Form.options = {
|
|
19
|
+
button: {
|
|
20
|
+
id: 'form-submit',
|
|
21
|
+
type: 'button',
|
|
22
|
+
class: 'btn btn-success boxy',
|
|
23
|
+
label: `<img src="/assets/icons/send.svg" class="icons-bg-white" > Submit`,
|
|
24
|
+
},
|
|
25
|
+
field: {},
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
Form.label = (field, label, required, htmlOptions = '') => {
|
|
29
|
+
required = required || false
|
|
30
|
+
const mark = required ? '*' : ''
|
|
31
|
+
return `<label for="${field}">${label} ${mark} ${htmlOptions}</label>`
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Form.textarea = (obj) => {
|
|
35
|
+
obj.type = 'textarea'
|
|
36
|
+
return Form.field(obj)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Form.input = (obj) => {
|
|
40
|
+
obj.type = 'input'
|
|
41
|
+
return Form.field(obj)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
Form.addProperty = (property, options = []) => {
|
|
45
|
+
///We expect options to be a non-empty Array
|
|
46
|
+
if (!options.length) return
|
|
47
|
+
var optionsString = options.join(' ')
|
|
48
|
+
return ` ${property}="${optionsString}" `
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
Form.field = (obj) => {
|
|
52
|
+
//options and default options
|
|
53
|
+
let options = obj.options || {}
|
|
54
|
+
let htmlOptions = ''
|
|
55
|
+
for (let key in options) {
|
|
56
|
+
let val = options[key]
|
|
57
|
+
val = Util.replaceAll(val, '"', '')
|
|
58
|
+
if (obj.hasOwnProperty(key)) {
|
|
59
|
+
obj[key] = options[key]
|
|
60
|
+
} else {
|
|
61
|
+
htmlOptions += ` ${key}=${val} `
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
let type = obj.type || 'text',
|
|
65
|
+
id = obj.isTableModule ? '' : Form.addProperty('id', [obj.id]),
|
|
66
|
+
name = obj.name ? ` name="${obj.name}" ` : '',
|
|
67
|
+
title = obj.title || '',
|
|
68
|
+
prepend = obj.prepend || '',
|
|
69
|
+
append = obj.append || '',
|
|
70
|
+
placeholder = Form.addProperty('placeholder', [obj.placeholder]),
|
|
71
|
+
tabindex = Form.addProperty('tabindex', [obj.tabindex]),
|
|
72
|
+
value = obj.value == undefined ? '' : obj.value,
|
|
73
|
+
classview = obj.class ? ` class="${obj.class}" ` : ` class=" " `,
|
|
74
|
+
disabled = obj.disabled ? ` disabled="disabled" ` : '',
|
|
75
|
+
data = obj.data,
|
|
76
|
+
required = obj.required == true ? ` required ` : '',
|
|
77
|
+
table = !obj.table ? '' : obj.table,
|
|
78
|
+
frameworkcss = !obj.frameworkcss ? 'bootstrap5' : obj.frameworkcss,
|
|
79
|
+
form_css = !obj.form_css ? 'bootstrap' : obj.form_css,
|
|
80
|
+
attributes = !obj.attributes ? {} : obj.attributes,
|
|
81
|
+
style = !obj.style ? '' : ` style=${obj.style} `,
|
|
82
|
+
additional_attributes = !obj.additional_attributes ? '' : obj.additional_attributes,
|
|
83
|
+
information = !obj.information ? '' : `<div id="information-${obj.id}" class="form-text">${Util.replaceAll(obj.information.substring(1, obj.information.length - 1), '\r\n', '<br>')}</div>`
|
|
84
|
+
//replaceAll("\r\n","<br>")
|
|
85
|
+
let attributeDate = ''
|
|
86
|
+
if (obj.hasOwnProperty.attributeData) {
|
|
87
|
+
for (let key in obj.attributeData) {
|
|
88
|
+
attributeDate += ` data-${key}="${obj.attributeData[key]}" `
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
let hasInputGroup = false
|
|
92
|
+
let inputGroupLeft = '',
|
|
93
|
+
inputGroupRight = '',
|
|
94
|
+
inputGroupDivLeft = ''
|
|
95
|
+
if (attributes.hasOwnProperty('hasInputGroup') && attributes.hasInputGroup) {
|
|
96
|
+
hasInputGroup = true
|
|
97
|
+
prepend = `<div class="input-group mb-3">`
|
|
98
|
+
append = `</div>`
|
|
99
|
+
if (attributes.hasOwnProperty('inputGroupLeft') && attributes.inputGroupLeft) {
|
|
100
|
+
inputGroupLeft = `<span class="input-group-text">${attributes.inputGroupLeft}</span>`
|
|
101
|
+
}
|
|
102
|
+
if (attributes.hasOwnProperty('inputGroupRight') && attributes.inputGroupRight) {
|
|
103
|
+
inputGroupRight = `<span class="input-group-text">${attributes.inputGroupRight}</span>`
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
let displayForm = ''
|
|
107
|
+
let readonly = obj.readonly ? `readonly` : ``
|
|
108
|
+
let boxyclass = '',
|
|
109
|
+
checked = '',
|
|
110
|
+
selects = ''
|
|
111
|
+
switch (type) {
|
|
112
|
+
case 'text':
|
|
113
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" ${disabled} ${readonly} autofocus="" ${tabindex} ${additional_attributes} type="${type}" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
114
|
+
break
|
|
115
|
+
|
|
116
|
+
case 'checkbox':
|
|
117
|
+
checked = value == 1 ? 'checked' : ''
|
|
118
|
+
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} ${disabled} ${readonly} ${additional_attributes} ${style} type="checkbox" class="form-check-input ${obj.class}" ${id} ${name} ${checked} ${htmlOptions}>${information}${append}`
|
|
119
|
+
break
|
|
120
|
+
|
|
121
|
+
case 'tags':
|
|
122
|
+
classview = ` class="form-control tags ${obj.class ? obj.class : ''} " `
|
|
123
|
+
let datahtml = ''
|
|
124
|
+
if (value) {
|
|
125
|
+
let dataValue = []
|
|
126
|
+
if (typeof value == 'string') {
|
|
127
|
+
dataValue = JSON.parse(value) || []
|
|
128
|
+
} else {
|
|
129
|
+
dataValue = value || []
|
|
130
|
+
}
|
|
131
|
+
dataValue.forEach(function (item) {
|
|
132
|
+
datahtml += `<option value="${item}" selected="selected">${item}</option>`
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
displayForm = `${prepend}<select ${classview} ${id} ${name} ${additional_attributes} ${placeholder} multiple data-allow-new="true">${datahtml}</select>${information}${append}`
|
|
136
|
+
break
|
|
137
|
+
|
|
138
|
+
case 'range':
|
|
139
|
+
let min = !obj.min ? 0 : obj.min
|
|
140
|
+
let max = !obj.max ? 100 : obj.max
|
|
141
|
+
displayForm = `${prepend}${inputGroupLeft}<input onmouseover="titlerange(this)" onchange="titlerange(this)" autocomplete="off" autofocus="" ${tabindex} type="${type}" class="form-range ${obj.class}" step="1" ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" min="${min}" max="${max}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
142
|
+
break
|
|
143
|
+
|
|
144
|
+
case 'hidden':
|
|
145
|
+
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} type="${type}" ${additional_attributes} ${style} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${append}`
|
|
146
|
+
break
|
|
147
|
+
|
|
148
|
+
case 'textarea':
|
|
149
|
+
displayForm = `${prepend}${inputGroupLeft}<textarea ${tabindex} ${disabled} class="form-control ${obj.class}" ${id} ${name} ${additional_attributes} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${value}</textarea>${inputGroupRight}${information}${append}`
|
|
150
|
+
break
|
|
151
|
+
|
|
152
|
+
case 'image':
|
|
153
|
+
boxyclass = value ? 'boxy' : ''
|
|
154
|
+
let stringvalue = value ? value.substring(13) : ''
|
|
155
|
+
let trashicon = stringvalue ? `<img class="tabler-icons icons-filter-danger" src="/assets/icons/trash-filled.svg" onclick="removeimage(this)">` : ''
|
|
156
|
+
displayForm = `${prepend}<input ${tabindex} type="file" accept="image/*" onchange="loadFile(this,'${obj.id}' )" data-width="${obj.width}" class="form-control ${obj.class || ''}" ${id} ${name} ${placeholder} value="${value}" ${htmlOptions}>
|
|
157
|
+
<div id="body${obj.id}" class="isfile" data-id="${obj.id}" data-table="${obj.routeName}" data-width="${obj.width}" data-name="${obj.title}" data-filename="${value}" data-required="${obj.required}"> <img class="mb-3" width="${obj.width}" id="file${obj.id}" /><br><a class="text-success" target="_blank" href="/uploads/${
|
|
158
|
+
obj.routeName
|
|
159
|
+
}/${value}"> ${stringvalue}</a> ${trashicon}</div>${append}`
|
|
160
|
+
break
|
|
161
|
+
|
|
162
|
+
case 'file':
|
|
163
|
+
boxyclass = value ? 'boxy' : ''
|
|
164
|
+
let stringvaluefile = value ? value.substring(13) : ''
|
|
165
|
+
let trashiconfile = stringvaluefile ? `<img class="tabler-icons icons-filter-danger" src="/assets/icons/trash-filled.svg" onclick="removeimage(this)">` : ''
|
|
166
|
+
displayForm = `${prepend}<input ${tabindex} type="file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/msword, application/vnd.ms-excel, application/vnd.ms-powerpoint,text/plain, application/pdf,.css,.js,.jpg,.png,.gif" onchange="loadFile(this,'${obj.id}' )" class="form-control ${
|
|
167
|
+
obj.class || ''
|
|
168
|
+
}" ${id} ${name} ${placeholder} value="${value}" ${htmlOptions}>
|
|
169
|
+
<div id="body${obj.id}" class="isfile" data-id="${obj.id}" data-name="${obj.title}" data-table="${obj.routeName}" data-filename="${value}" data-required="${obj.required}"> <img class="mb-3" id="file${obj.id}" /><a class="text-success" target="_blank" href="/uploads/${
|
|
170
|
+
obj.routeName
|
|
171
|
+
}/${value}"> ${stringvaluefile}</a>${trashiconfile}</div>${information}${append}`
|
|
172
|
+
break
|
|
173
|
+
|
|
174
|
+
case 'email':
|
|
175
|
+
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${readonly} ${disabled} ${additional_attributes} ${tabindex} ${style} type="email" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
176
|
+
break
|
|
177
|
+
|
|
178
|
+
case 'number':
|
|
179
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="text" class="form-control number ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
180
|
+
break
|
|
181
|
+
|
|
182
|
+
case 'integer':
|
|
183
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="number" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
184
|
+
break
|
|
185
|
+
|
|
186
|
+
case 'datepicker':
|
|
187
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="text" class="form-control datepicker ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
188
|
+
break
|
|
189
|
+
|
|
190
|
+
case 'datetimepicker':
|
|
191
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} type="text" ${style} class="form-control datetimepicker ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
192
|
+
break
|
|
193
|
+
|
|
194
|
+
case 'password':
|
|
195
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="password" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}><span toggle="#password" class="bx bi-eye field-icon toggle-password"></span>${inputGroupRight}${information}${append}`
|
|
196
|
+
break
|
|
197
|
+
|
|
198
|
+
case 'switch':
|
|
199
|
+
checked = value == 1 ? ' checked ' : ''
|
|
200
|
+
displayForm = `${prepend}<p><input ${tabindex} type="checkbox" class="form-control ${obj.class}" ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} ></p>${information}${append}`
|
|
201
|
+
break
|
|
202
|
+
|
|
203
|
+
case 'lexical':
|
|
204
|
+
displayForm = `${prepend}<div ${id}>${information}${append}`
|
|
205
|
+
break
|
|
206
|
+
|
|
207
|
+
case 'checkbox':
|
|
208
|
+
checked = value == 1 ? ' checked ' : ''
|
|
209
|
+
displayForm = `${prepend}<input ${tabindex} type="${type}" class="form-control ${obj.class}" ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} >${information}${append}`
|
|
210
|
+
break
|
|
211
|
+
|
|
212
|
+
case 'dropdown_checkbox':
|
|
213
|
+
let checkboxes = ''
|
|
214
|
+
let val = []
|
|
215
|
+
if (typeof value == 'object') {
|
|
216
|
+
val = value
|
|
217
|
+
} else if (typeof value == 'string') {
|
|
218
|
+
if (value) {
|
|
219
|
+
val = JSON.parse(value)
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
data.forEach(function (item) {
|
|
223
|
+
const checked = Util.in_array(item, val) ? ' checked ' : ''
|
|
224
|
+
checkboxes += `<div class="checkbox">
|
|
225
|
+
<label class="">
|
|
226
|
+
<input type="checkbox" name="${obj.name}[${item}]" ${checked} value="${item}">
|
|
227
|
+
${item}
|
|
228
|
+
</label>
|
|
229
|
+
</div>`
|
|
230
|
+
})
|
|
231
|
+
displayForm = `${prepend}<div class="form-check">${checkboxes}</div>${information}${append}`
|
|
232
|
+
break
|
|
233
|
+
|
|
234
|
+
case 'select':
|
|
235
|
+
var please_select = obj.please_select
|
|
236
|
+
if (please_select != undefined) {
|
|
237
|
+
if (please_select != '') {
|
|
238
|
+
selects += `<option value="">${please_select}</option>`
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (obj.hasOwnProperty('array')) {
|
|
242
|
+
var items = obj.array || []
|
|
243
|
+
if (items.length) {
|
|
244
|
+
items.forEach(function (item) {
|
|
245
|
+
if (item.label) {
|
|
246
|
+
const selected = item.value == value ? ' selected ' : ''
|
|
247
|
+
selects += `<option value="${item.value}" ${selected}>${item.label}</option>`
|
|
248
|
+
}
|
|
249
|
+
})
|
|
250
|
+
} else {
|
|
251
|
+
if (Array.isArray(data)) {
|
|
252
|
+
data.map((item) => {
|
|
253
|
+
if (item.zname) {
|
|
254
|
+
var selected = item.id == value ? ' selected ' : ''
|
|
255
|
+
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
256
|
+
}
|
|
257
|
+
})
|
|
258
|
+
} else {
|
|
259
|
+
for (var keys in data) {
|
|
260
|
+
if (data[keys]) {
|
|
261
|
+
var selected = keys == value ? ' selected ' : ''
|
|
262
|
+
selects += `<option value="${keys}" ${selected}>${data[keys]}</option>`
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
} else {
|
|
268
|
+
if (Array.isArray(data)) {
|
|
269
|
+
data.map((item) => {
|
|
270
|
+
if (item.zname) {
|
|
271
|
+
const selected = item.id == value ? ' selected ' : ''
|
|
272
|
+
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
273
|
+
}
|
|
274
|
+
})
|
|
275
|
+
} else {
|
|
276
|
+
for (let keys in data) {
|
|
277
|
+
if (data[keys]) {
|
|
278
|
+
let selected = keys == value ? ' selected ' : ''
|
|
279
|
+
selects += `<option value="${keys}" ${selected}>${data[keys]}</option>`
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
if (form_css == 'material_design') {
|
|
285
|
+
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
286
|
+
}
|
|
287
|
+
displayForm = `${prepend}<select ${tabindex} ${style} ${additional_attributes} ${disabled} ${readonly} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
288
|
+
break
|
|
289
|
+
|
|
290
|
+
case 'radio':
|
|
291
|
+
let radios = ''
|
|
292
|
+
let arr = obj.array || []
|
|
293
|
+
arr.map((item, index) => {
|
|
294
|
+
//var selected = item.value == value ? ' selected ' : '';
|
|
295
|
+
const checked = item.value == value ? ' checked ' : ''
|
|
296
|
+
radios += `<div class="form-check">
|
|
297
|
+
<input class="form-check-input ${obj.class}" type="radio" name="${obj.name}" ${additional_attributes} value="${item.value}" id="${obj.id}${index}" ${checked}>
|
|
298
|
+
<label class="form-check-label" for="${obj.id}${index}">
|
|
299
|
+
${item.label}
|
|
300
|
+
</label>
|
|
301
|
+
</div>`
|
|
302
|
+
})
|
|
303
|
+
displayForm = `${prepend} ${radios} ${information}${append}`
|
|
304
|
+
break
|
|
305
|
+
|
|
306
|
+
case 'select_user':
|
|
307
|
+
selects = ''
|
|
308
|
+
data.map((item) => {
|
|
309
|
+
const selected = item.value == value ? ' selected ' : ''
|
|
310
|
+
selects += `<option value="${item.id}" ${selected}>${item.fullname}</option>`
|
|
311
|
+
})
|
|
312
|
+
|
|
313
|
+
if (form_css == 'material_design') {
|
|
314
|
+
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
315
|
+
}
|
|
316
|
+
displayForm = `${prepend}<select ${tabindex} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
317
|
+
break
|
|
318
|
+
|
|
319
|
+
case 'chain':
|
|
320
|
+
selects = ''
|
|
321
|
+
// for array item.value and item.text
|
|
322
|
+
// proptery is value and text
|
|
323
|
+
data.map((item) => {
|
|
324
|
+
var selected = item.id == value ? ' selected ' : ''
|
|
325
|
+
selects += `<option value="${item.id}" ${selected}>${item.zname}</option>`
|
|
326
|
+
})
|
|
327
|
+
if (form_css == 'material_design') {
|
|
328
|
+
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
329
|
+
}
|
|
330
|
+
displayForm = `${prepend}<select ${tabindex} class="form-control form-select ${obj.class}" ${id} ${name} ${placeholder} ${required} ${htmlOptions} >${selects}</select>${information}${append}`
|
|
331
|
+
break
|
|
332
|
+
|
|
333
|
+
case 'multi':
|
|
334
|
+
selects = ''
|
|
335
|
+
if (data) {
|
|
336
|
+
data.map((item) => {
|
|
337
|
+
selects += `<option value="${item.id}">${item.zname}</option>`
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
var spanmulti = ''
|
|
342
|
+
if (value) {
|
|
343
|
+
let arr = []
|
|
344
|
+
arr = typeof value == 'string' ? JSON.parse(value) : value
|
|
345
|
+
if (Array.isArray(arr)) {
|
|
346
|
+
arr.forEach(function (item, index) {
|
|
347
|
+
spanmulti += `<span class='span${obj.id}'>${index + 1}. <input type='hidden' name='${obj.name}[]' value='${item}' />${obj.multi[item]}<img class='tabler-icons icons-filter-danger pull-right' src='/assets/icons/trash-filled.svg' onclick='$(this).closest("span").remove();' title='${LANGUAGE['delete']}' /><br></span>`
|
|
348
|
+
})
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (form_css == 'material_design') {
|
|
352
|
+
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
let g = `<div class="input-group ">
|
|
356
|
+
<span class="input-group-text" id="dropdownadd${id}" class="dropdownadd" data-id="${id}" style="cursor: pointer" title="Add Data">+</span>
|
|
357
|
+
</div>
|
|
358
|
+
<div id="dropdownbox${id}" class="boxy">
|
|
359
|
+
<span class="span${id}">
|
|
360
|
+
</span>
|
|
361
|
+
</div>`
|
|
362
|
+
return `<div class="input-group">
|
|
363
|
+
<select ${tabindex} class="form-control ${obj.class} dropdown-multi" name='${obj.name}' ${id} ${placeholder} ${htmlOptions} >${selects}</select>
|
|
364
|
+
<span id="dropdownadd${obj.id}" class="input-group-text dropdownadd" data-id="${obj.id}" style="cursor: pointer;" title=" ${LANGUAGE['form_add_data']} ">+</span>
|
|
365
|
+
</div>
|
|
366
|
+
<div id="dropdownbox${obj.id}" class="boxy mb-3">${spanmulti}</div>`
|
|
367
|
+
break
|
|
368
|
+
|
|
369
|
+
case 'typeahead':
|
|
370
|
+
let typeahead_value = Util.replaceAll(obj.typeaheadvalue, '"', `'`)
|
|
371
|
+
displayForm = `${prepend}<div class="input-group">
|
|
372
|
+
<input ${tabindex} type="text" class="form-control ${obj.class}" id="${obj.id}Typeahead" autocomplete="off" data-provide="typeahead" id="${obj.id}Typeahead" placeholder="Please type a word" value="${typeahead_value}" >
|
|
373
|
+
<input type="hidden" ${id} ${name} ${placeholder} ${classview} ${required} value="${value}">
|
|
374
|
+
<span id="${obj.id}Clear" class="input-group-addon input-group-text dropdownadd" title="Clear" style="cursor: pointer;" title=" Add Data "><img src="/assets/icons/ban.svg" class="icons-bg-black" ></span>
|
|
375
|
+
</div>${information}${append}`
|
|
376
|
+
break
|
|
377
|
+
|
|
378
|
+
case 'table':
|
|
379
|
+
let html = ''
|
|
380
|
+
/*console.log(`table : ${JSON.stringify(obj.data)}`)
|
|
381
|
+
console.log(JSON.stringify(obj.data))
|
|
382
|
+
console.log(JSON.stringify(obj.properties));*/
|
|
383
|
+
for (let key in obj.data) {
|
|
384
|
+
if (obj.properties[key].hidden) {
|
|
385
|
+
html += `<th></th>`
|
|
386
|
+
} else {
|
|
387
|
+
html += `<th>${obj.data[key]}</th>`
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
let btnAdd = ''
|
|
391
|
+
if (!obj.isAddButton && !obj.viewOnly) {
|
|
392
|
+
btnAdd = `<th class="float-end"><img id="add${obj.id}" src="/assets/icons/plus.svg" class="icons-bg-white boxy-small btn-plus" ></th>`
|
|
393
|
+
}
|
|
394
|
+
obj.btnAdd = btnAdd
|
|
395
|
+
obj.html = html
|
|
396
|
+
obj.title = title
|
|
397
|
+
obj.table = table
|
|
398
|
+
obj.value = value
|
|
399
|
+
let datavalue = ''
|
|
400
|
+
if (obj.value) {
|
|
401
|
+
datavalue = JSON.stringify(obj.value)
|
|
402
|
+
datavalue = Util.replaceAll(datavalue, "'", '`')
|
|
403
|
+
}
|
|
404
|
+
obj.prepend = prepend
|
|
405
|
+
obj.body = `<div class="table-responsive">
|
|
406
|
+
<table id="table${obj.id}" class="table table-hover table-sm">
|
|
407
|
+
<thead>
|
|
408
|
+
<tr>
|
|
409
|
+
${html}
|
|
410
|
+
${obj.btnAdd}
|
|
411
|
+
</tr>
|
|
412
|
+
</thead>
|
|
413
|
+
<tbody id="body-${obj.id}" data-value='${datavalue}'>${obj.bodyTable}</tbody>
|
|
414
|
+
</table></div>`
|
|
415
|
+
displayForm = Form.card(frameworkcss, obj)
|
|
416
|
+
break
|
|
417
|
+
|
|
418
|
+
case 'multi_line_editor':
|
|
419
|
+
value = obj.value ? obj.value : {}
|
|
420
|
+
let description = obj.description || ''
|
|
421
|
+
for (var key in obj.fields) {
|
|
422
|
+
let val = !value[key] ? obj.fields[key] : value[key]
|
|
423
|
+
description = Util.replaceAll(description, `[[[${key}]]]`, `<span class="text-danger text-toggle" id="a_${key}" data-id="${key}" style="text-decoration: underline; cursor: pointer">${val}</span> <input type="hidden" name="${obj.name}[${key}]" class="editor-value" id="${key}" data-id="${key}" value="${val}" >`)
|
|
424
|
+
}
|
|
425
|
+
displayForm = `${prepend}<div class="boxy">${description}</div>${information}${append}`
|
|
426
|
+
break
|
|
427
|
+
|
|
428
|
+
case 'ide_editor':
|
|
429
|
+
displayForm = `<div class="ide_editor" id="editor_${obj.id}"></div>`
|
|
430
|
+
displayForm += `<textarea hidden ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4"></textarea>${information}${append}`
|
|
431
|
+
break
|
|
432
|
+
|
|
433
|
+
case 'json':
|
|
434
|
+
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
435
|
+
break
|
|
436
|
+
|
|
437
|
+
case 'json_array':
|
|
438
|
+
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
439
|
+
break
|
|
440
|
+
|
|
441
|
+
case 'dragdrop':
|
|
442
|
+
//dataObject
|
|
443
|
+
let leftButtons = ``
|
|
444
|
+
let rightButtons = ``
|
|
445
|
+
let all = Object.keys(obj.dataObject)
|
|
446
|
+
all.map((item, index) => {
|
|
447
|
+
if (!value.includes(item)) {
|
|
448
|
+
rightButtons += `<li><button class="btn btn-danger boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='trashx' value="${item}"></button></li>`
|
|
449
|
+
}
|
|
450
|
+
})
|
|
451
|
+
value = value || []
|
|
452
|
+
value.map((item, index) => {
|
|
453
|
+
leftButtons += `<li><button class="btn btn-primary boxy" type="button">${obj.dataObject[item]}<input type="hidden" name='${obj.name}[]' value="${item}"></button></li>`
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
displayForm += `<div id="dragdrop_${obj.id}" class="row contentfields">
|
|
457
|
+
<div class="col-md-6">
|
|
458
|
+
<h5>${obj.attributes.left}</h5>
|
|
459
|
+
<ol class="mydragable${obj.id} divboxlittle" data-type="left" data-name="${obj.name}[]">${leftButtons}</ol>
|
|
460
|
+
</div>
|
|
461
|
+
<div class="col-md-6">
|
|
462
|
+
<h5>${obj.attributes.right}</h5>
|
|
463
|
+
<ol class="mydragable${obj.id} divboxlittle" data-type="right" data-name="trashx">
|
|
464
|
+
${rightButtons}
|
|
465
|
+
</ol>
|
|
466
|
+
</div>
|
|
467
|
+
</div>`
|
|
468
|
+
break
|
|
469
|
+
|
|
470
|
+
case 'array':
|
|
471
|
+
displayForm += `<textarea ${additional_attributes} class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
472
|
+
break
|
|
473
|
+
|
|
474
|
+
case 'virtual':
|
|
475
|
+
displayForm = `${prepend}<input ${additional_attributes} autocomplete="off" autofocus="" ${tabindex} ${style} type="text" ${classview} readonly ${id} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
476
|
+
break
|
|
477
|
+
|
|
478
|
+
//additionals for form view in view
|
|
479
|
+
case 'plaintext':
|
|
480
|
+
displayForm = `<span class="">${obj.value || ''}</span>`
|
|
481
|
+
break
|
|
482
|
+
|
|
483
|
+
case 'div':
|
|
484
|
+
displayForm = `<div id="${obj.id}" class="${obj.class}">${obj.value}</div>`
|
|
485
|
+
break
|
|
486
|
+
|
|
487
|
+
case 'data_table':
|
|
488
|
+
displayForm = obj.html
|
|
489
|
+
break
|
|
490
|
+
|
|
491
|
+
case 'location':
|
|
492
|
+
displayForm = `${prepend}<input type="text" class="form-control ${obj.class}" id="search_map_location" placeholder="type a place" ${required} value="" ${htmlOptions}>${information}${append}
|
|
493
|
+
<textarea ${id} ${name} style="display: none" ${readonly} rows="2">${JSON.stringify(obj.value)}</textarea>
|
|
494
|
+
<div id="map_${obj.id}" style="background-color:#C3C3C3;width: 100%;height: ${obj.height}px"></div>`
|
|
495
|
+
break
|
|
496
|
+
|
|
497
|
+
case 'dropzone':
|
|
498
|
+
displayForm = `${prepend}<div ${tabindex} ${style} type="text" ${classview} ${id} ${htmlOptions}><label for="files" class="dropzone-container">
|
|
499
|
+
<div class="dz-message" data-dz-message><div class="file-icon"><span class="icon-small icons-primary"><img class="icons-bg-white icon-image-large" src="/assets/icons/file-plus.svg"></span></div>
|
|
500
|
+
<div class="text-center pt-3 px-5">
|
|
501
|
+
<p class="w-80 h5 text-dark fw-bold">Drag your documents, photos or videos here to start uploading.</p>
|
|
502
|
+
</div></div>
|
|
503
|
+
</label></div>${information}${append}`
|
|
504
|
+
break
|
|
505
|
+
|
|
506
|
+
case 'dropzoneview':
|
|
507
|
+
let countFiles = obj.value && obj.value.length ? obj.value.length + ' Files' : ''
|
|
508
|
+
let bodydropzoneview =
|
|
509
|
+
countFiles == '' ? '' : `<div class="card-header">${countFiles} <div class="float-end"><span class="icon-small icons-light" title="Download"><img onclick="location.href= '/zdownloads-dropzone/${obj.routeName}/${obj.key}/${obj.dataId}'" class="icons-bg-black gridview icon-image" src="/assets/icons/download.svg"></span></div> </div>`
|
|
510
|
+
displayForm = `<div class="card">
|
|
511
|
+
${bodydropzoneview}
|
|
512
|
+
<div class="card-body">`
|
|
513
|
+
if (obj.value && obj.value.length > 0) {
|
|
514
|
+
obj.value.map((item) => {
|
|
515
|
+
let extFile = Util.fileExtension(item)
|
|
516
|
+
let filename = `/uploads/${obj.table}/${obj.key}/${item}`
|
|
517
|
+
if (extFile.type == 'image') {
|
|
518
|
+
displayForm += `<img src="${filename}" class="boxy zoom mx-2 my-2" width="200px">`
|
|
519
|
+
} else {
|
|
520
|
+
displayForm += '<br>' + Util.fileView(`/uploads/${obj.table}/${obj.key}/`, item, { withIcon: true }) + '<br>'
|
|
521
|
+
}
|
|
522
|
+
})
|
|
523
|
+
}
|
|
524
|
+
displayForm += `</div></div>`
|
|
525
|
+
|
|
526
|
+
break
|
|
527
|
+
default:
|
|
528
|
+
value = value ? value.replaceAll('"', '"') : obj.value
|
|
529
|
+
displayForm = `${prepend}${inputGroupLeft}<input ${disabled} autocomplete="nope" autofocus="" ${readonly} ${tabindex} type="${type}" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
530
|
+
break
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
return displayForm
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
Form.group = (name, label, field) => {
|
|
537
|
+
return `<div class="form-group div${name} mb-3">${label}${field}</div>`
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
Form.button = (optionsExtends = {}) => {
|
|
541
|
+
let options = Form.options.button
|
|
542
|
+
let htmlOptions = ''
|
|
543
|
+
for (let key in optionsExtends) {
|
|
544
|
+
let val = optionsExtends[key]
|
|
545
|
+
val = Util.replaceAll(val, '"', '')
|
|
546
|
+
if (options.hasOwnProperty(key)) {
|
|
547
|
+
options[key] = optionsExtends[key]
|
|
548
|
+
} else {
|
|
549
|
+
htmlOptions += ` ${key}=${val} `
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
return `<button id="${options.id}" type="${options.type}" class="${options.class}" ${htmlOptions}>${options.label}</button>`
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
Form.buttonGroup = (buttons = []) => {
|
|
556
|
+
let html = `<div class="btn-group" role="group" aria-label="...">`
|
|
557
|
+
html += buttons.join(' ')
|
|
558
|
+
html += `</div>`
|
|
559
|
+
return html
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
Form.submit = (optionsExtends = {}) => {
|
|
563
|
+
let options = {
|
|
564
|
+
id: 'form-submit',
|
|
565
|
+
type: 'submit',
|
|
566
|
+
class: 'btn btn btn-success boxy image-button ',
|
|
567
|
+
label: `<img src="/assets/icons/send.svg" class="icons-bg-white" > <span>${LANGUAGE['submit']}</span>`,
|
|
568
|
+
}
|
|
569
|
+
let settings = { ...options, ...optionsExtends }
|
|
570
|
+
return Form.button(settings)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
Form.pullRight = (frameworkcss) => {
|
|
574
|
+
if (frameworkcss == 'bootstrap3') {
|
|
575
|
+
return 'pull-right'
|
|
576
|
+
} else if (frameworkcss == 'bootstrap4') {
|
|
577
|
+
return 'float-right'
|
|
578
|
+
} else {
|
|
579
|
+
return 'float-end'
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
Form.breadcrumb = (type, arr) => {
|
|
584
|
+
let html = `<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");" aria-label="breadcrumb"><ol class="breadcrumb float-end">`
|
|
585
|
+
arr.map((item) => {
|
|
586
|
+
if (item.active == true) {
|
|
587
|
+
html += `<li class="breadcrumb-item active" aria-current="page">${item.text}</li>`
|
|
588
|
+
} else {
|
|
589
|
+
html += `<li class="breadcrumb-item"><a href="${item.href}">${item.text}</a></li>`
|
|
590
|
+
}
|
|
591
|
+
})
|
|
592
|
+
html += `</ol></nav>`
|
|
593
|
+
return html
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
Form.breadcrumbs = (arr) => {
|
|
597
|
+
let html = `<nav style="--bs-breadcrumb-divider: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E");" aria-label="breadcrumb"><ol class="breadcrumb float-end">`
|
|
598
|
+
arr.map((item) => {
|
|
599
|
+
if (item.active == true) {
|
|
600
|
+
html += `<li class="breadcrumb-item active" aria-current="page">${item.text}</li>`
|
|
601
|
+
} else {
|
|
602
|
+
html += `<li class="breadcrumb-item"><a href="${item.href}">${item.text}</a></li>`
|
|
603
|
+
}
|
|
604
|
+
})
|
|
605
|
+
html += `</ol></nav>`
|
|
606
|
+
return html
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
Form.breadcrumbIndex = () => {
|
|
610
|
+
return Form.breadcrumbs([
|
|
611
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
612
|
+
{ text: LANGUAGE['grid_list'], active: true },
|
|
613
|
+
])
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
Form.breadcrumbCreate = (routeName) => {
|
|
617
|
+
return Form.breadcrumbs([
|
|
618
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
619
|
+
{ text: LANGUAGE['grid_list'], href: '/' + routeName },
|
|
620
|
+
{ text: LANGUAGE['create'], active: true },
|
|
621
|
+
])
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
Form.breadcrumbUpdate = (routeName, id) => {
|
|
625
|
+
return Form.breadcrumbs([
|
|
626
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
627
|
+
{ text: LANGUAGE['grid_list'], href: '/' + routeName },
|
|
628
|
+
{ text: LANGUAGE['create'], href: '/' + routeName + '/create' },
|
|
629
|
+
{ text: LANGUAGE['view'], href: '/' + routeName + '/view/' + id },
|
|
630
|
+
{ text: LANGUAGE['update'], active: true },
|
|
631
|
+
])
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
Form.breadcrumbView = (routeName) => {
|
|
635
|
+
return Form.breadcrumbs([
|
|
636
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
637
|
+
{ text: LANGUAGE['grid_list'], href: '/' + routeName },
|
|
638
|
+
{ text: LANGUAGE['view'], active: true },
|
|
639
|
+
])
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
Form.breadcrumbImport = (routeName) => {
|
|
643
|
+
return Form.breadcrumbs([
|
|
644
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
645
|
+
{ text: LANGUAGE['grid_list'], href: '/' + routeName },
|
|
646
|
+
{ text: LANGUAGE['create'], href: '/' + routeName + '/create' },
|
|
647
|
+
{ text: LANGUAGE['form_import'], active: true },
|
|
648
|
+
])
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
Form.breadcrumbApproval = (routeName, id) => {
|
|
652
|
+
return Form.breadcrumbs([
|
|
653
|
+
{ text: LANGUAGE['home'], href: '/dashboard' },
|
|
654
|
+
{ text: LANGUAGE['grid_list'], href: '/' + routeName },
|
|
655
|
+
{ text: LANGUAGE['update'], href: '/' + routeName + '/update/' + id },
|
|
656
|
+
{ text: LANGUAGE['create'], href: '/' + routeName + '/create' },
|
|
657
|
+
{ text: 'Approval', active: true },
|
|
658
|
+
])
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
Form.grid = (type, obj) => {
|
|
662
|
+
return gridBootstrap5(obj)
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/*
|
|
666
|
+
tab property
|
|
667
|
+
label,active,content,headerOptions
|
|
668
|
+
*/
|
|
669
|
+
Form.tab = (type, obj) => {
|
|
670
|
+
return tabBootstrap5(obj)
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
Form.card = (type, obj) => {
|
|
674
|
+
return card45(obj)
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
//card 4 & 5 bootstrap
|
|
678
|
+
const card45 = (obj) => {
|
|
679
|
+
let html = obj.prepend
|
|
680
|
+
let objHeader = obj.headerOptions || {}
|
|
681
|
+
let headerOptions = obj.headerOptions ? addProperties(obj.headerOptions, { class: 'card' }) : addProperties({ class: 'card' })
|
|
682
|
+
let img = obj.img ? `<img ${addProperties(obj.img)} >` : ''
|
|
683
|
+
let title = `<div class="card-header"><h5 class="card-title">${obj.title}</h5></div>`
|
|
684
|
+
let footer = (obj.footer = obj.footer ? `<div class="card-footer">${obj.footer}</div>` : ``)
|
|
685
|
+
let append = !obj.append ? '' : obj.append
|
|
686
|
+
html += `<div ${headerOptions}>
|
|
687
|
+
${img}
|
|
688
|
+
${title}
|
|
689
|
+
<div class="card-body">
|
|
690
|
+
${obj.body}
|
|
691
|
+
</div>
|
|
692
|
+
${footer}
|
|
693
|
+
</div>`
|
|
694
|
+
|
|
695
|
+
html += append
|
|
696
|
+
return html
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
const cardBootstrap5 = (obj) => {
|
|
700
|
+
return `${obj.prepend}<div class="card div${obj.id}">
|
|
701
|
+
<div class="card-content">
|
|
702
|
+
<div class="card-body">
|
|
703
|
+
<div class="card-title">${obj.title}</div>
|
|
704
|
+
<div class="table-responsive">
|
|
705
|
+
<table id="table${obj.id}" class="table">
|
|
706
|
+
<thead>
|
|
707
|
+
<tr>
|
|
708
|
+
${obj.html}
|
|
709
|
+
${obj.btnAdd}
|
|
710
|
+
</tr>
|
|
711
|
+
</thead>
|
|
712
|
+
<tbody id="body-${obj.id}" data-value='${obj.value}'>${obj.table}</tbody>
|
|
713
|
+
</table>
|
|
714
|
+
</div>
|
|
715
|
+
</div>
|
|
716
|
+
</div>
|
|
717
|
+
</div>`
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const gridBootstrap5 = (obj) => {
|
|
721
|
+
let levels = obj.levels
|
|
722
|
+
let routeName = obj.routeName
|
|
723
|
+
let advanceSearch = !obj.advanceSearch ? '' : obj.advanceSearch
|
|
724
|
+
let createBtn = '',
|
|
725
|
+
exportBtn = '',
|
|
726
|
+
importBtn = '',
|
|
727
|
+
superBtn = '',
|
|
728
|
+
exportBtnGroup = '',
|
|
729
|
+
selectPagesize = ''
|
|
730
|
+
if (levels.create) {
|
|
731
|
+
createBtn = `<button type="button" id="create_btn" class="btn btn-success btn-xs"><i class="fa fa-plus white-icon"></i></button>`
|
|
732
|
+
}
|
|
733
|
+
if (levels.export) {
|
|
734
|
+
exportBtn = `<button type="button" id="backupExcel" class="btn btn-info btn-xs" title="${obj.LANGUAGE['download_excel']}"><i class="fas fa-file-excel"></i></button>`
|
|
735
|
+
|
|
736
|
+
exportBtnGroup = `<div class="btn-group" role="group">
|
|
737
|
+
<button id="dropdownExport" type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
738
|
+
${obj.LANGUAGE['grid_export_data']}
|
|
739
|
+
</button>
|
|
740
|
+
<div class="dropdown-menu" aria-labelledby="dropdownExport">
|
|
741
|
+
<a class="dropdown-item export-xls" href="#"><i class="text-success fa fa-file-excel-o"></i> Excel </a>
|
|
742
|
+
<a class="dropdown-item export-pdf" href="#"><i class="text-danger fa fa-file-pdf-o"></i> PDF </a>
|
|
743
|
+
</div>
|
|
744
|
+
</div>`
|
|
745
|
+
}
|
|
746
|
+
if (levels.import) {
|
|
747
|
+
importBtn = `<button type="button" id="importExcel" class="btn btn-warning btn-xs" title="<%- LANGUAGE['data_import'] %>"><i class="fas fa-file-import"></i></button>`
|
|
748
|
+
}
|
|
749
|
+
selectPagesize = `<div class="dropdown-menu" aria-labelledby="dropdownPagination">`
|
|
750
|
+
let pageSize = obj.gridFilters.pageSize || 20
|
|
751
|
+
|
|
752
|
+
for (var i = 0; i < obj.paginationApp.length; i++) {
|
|
753
|
+
var actived = pageSize == obj.paginationApp[i] ? ' active ' : ''
|
|
754
|
+
selectPagesize += `<a data-value="${obj.paginationApp[i]}" class="dropdown-item pageSizeGrid ${actived}" id="pagination${obj.paginationApp[i]}" href="#" >${obj.paginationApp[i]}</a>`
|
|
755
|
+
}
|
|
756
|
+
selectPagesize += `</div>`
|
|
757
|
+
|
|
758
|
+
let toolbarDefault = `<div class="float">
|
|
759
|
+
<div class="btn-group float-end" role="group" aria-label="Button group with nested dropdown">
|
|
760
|
+
${createBtn}
|
|
761
|
+
${exportBtn}
|
|
762
|
+
${importBtn}
|
|
763
|
+
<button type="button" class="btn btn-secondary btn-xs" title="${LANGUAGE['grid_personalize_labeling']}" data-bs-toggle="modal" data-bs-target="#grid-labels" ><i class="fa fa-font"></i></button>
|
|
764
|
+
<button type="button" class="btn btn-info btn-xs" title="${LANGUAGE['grid_personalize_setting']}" data-bs-toggle="modal" data-bs-target="#grid-modal"><i class="fa fa-cog"></i></button>
|
|
765
|
+
<button type="button" id="reloadgrid" class="btn btn-default btn-xs" title="${LANGUAGE['grid_refresh']}"><i class="fas fa-redo"></i></button>
|
|
766
|
+
<div class="btn-group" role="group">
|
|
767
|
+
<button id="dropdownPagination" type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
768
|
+
Pagination ${pageSize}
|
|
769
|
+
</button>
|
|
770
|
+
${selectPagesize}
|
|
771
|
+
</div>
|
|
772
|
+
|
|
773
|
+
<div class="btn-group" role="group">
|
|
774
|
+
<button id="dropdownExport" type="button" class="btn btn-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
775
|
+
${obj.LANGUAGE['grid_export_data']}
|
|
776
|
+
</button>
|
|
777
|
+
<div class="dropdown-menu" aria-labelledby="dropdownExport">
|
|
778
|
+
<a class="dropdown-item export-xls" href="#"><i class="text-success fa fa-file-excel-o"></i> Excel </a>
|
|
779
|
+
<a class="dropdown-item export-pdf" href="#"><i class="text-danger fa fa-file-pdf-o"></i> PDF </a>
|
|
780
|
+
</div>
|
|
781
|
+
</div>
|
|
782
|
+
|
|
783
|
+
</div></div>`
|
|
784
|
+
let toolbar = obj.toolbar ? obj.toolbar : toolbarDefault
|
|
785
|
+
let html = ''
|
|
786
|
+
html += `<div class="card">
|
|
787
|
+
<div class="card-body">
|
|
788
|
+
<div class="float-end">
|
|
789
|
+
<div class="summary"></div>
|
|
790
|
+
</div>
|
|
791
|
+
<div class="card-title"><i class="fa fa-book"></i> ${obj.header}</div>
|
|
792
|
+
<div class="row">
|
|
793
|
+
${toolbar}
|
|
794
|
+
<div style="padding-top: 7px;"><a href="#" class="open_advancesearch"> Advance Search</a></div>
|
|
795
|
+
${advanceSearch}
|
|
796
|
+
</div>
|
|
797
|
+
|
|
798
|
+
<input type="hidden" id="pageSize" value="${pageSize}">
|
|
799
|
+
<div class="table-responsive pt-3 row">
|
|
800
|
+
<div id="jsGrid" class="table-responsive"></div>
|
|
801
|
+
</div>
|
|
802
|
+
</div>
|
|
803
|
+
</div>`
|
|
804
|
+
return html
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
const tabBootstrap5 = (arr = []) => {
|
|
808
|
+
let html = ''
|
|
809
|
+
html += `<ul class="nav nav-tabs" id="myTab" role="tablist">${Util.newLine}`
|
|
810
|
+
arr.forEach(function (item, index) {
|
|
811
|
+
var active = '',
|
|
812
|
+
selected = 'false'
|
|
813
|
+
if (item.active) {
|
|
814
|
+
active = 'active'
|
|
815
|
+
selected = 'true'
|
|
816
|
+
}
|
|
817
|
+
html += `${Util.tab}
|
|
818
|
+
<li class="nav-item" role="presentation" >
|
|
819
|
+
<button class="nav-link ${active}" id="tab${index}" data-bs-toggle="tab" data-bs-target="#arr${index}" type="button" role="tab" aria-controls="arrtab${index}" aria-selected="true">${item.label}</button>
|
|
820
|
+
</li>${Util.newLine}`
|
|
821
|
+
})
|
|
822
|
+
html += `</ul>`
|
|
823
|
+
return {
|
|
824
|
+
html: html,
|
|
825
|
+
class: 'tab-pane fade',
|
|
826
|
+
active: 'show active',
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
Form.build = (obj) => {
|
|
831
|
+
let html = ''
|
|
832
|
+
let required = !obj.required ? '' : `<span class="required-mark">*</span>`
|
|
833
|
+
let labelOptions = !obj.labelOptions ? '' : obj.labelOptions
|
|
834
|
+
let relation = ''
|
|
835
|
+
//form float
|
|
836
|
+
let float = false
|
|
837
|
+
let inline = false
|
|
838
|
+
let attributes = Object.prototype.hasOwnProperty.call(obj, 'attributes') ? obj.attributes : {}
|
|
839
|
+
let view_only = Object.prototype.hasOwnProperty.call(obj, 'view_only') ? obj.view_only : false
|
|
840
|
+
if (!view_only) {
|
|
841
|
+
if (attributes && Object.prototype.hasOwnProperty.call(attributes, 'name')) {
|
|
842
|
+
if (obj.attributes.name == 'relation' || obj.attributes.name == 'typeahead' || obj.attributes.name == 'dropdown_multi') {
|
|
843
|
+
relation = `<a target="_blank" href="/${obj.attributes.table}"> > </a>`
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
if (attributes && Object.prototype.hasOwnProperty.call(attributes, 'float')) {
|
|
849
|
+
float = obj.attributes.float || false
|
|
850
|
+
}
|
|
851
|
+
if (attributes && Object.prototype.hasOwnProperty.call(attributes, 'inline')) {
|
|
852
|
+
inline = obj.attributes.inline || false
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
if (float) {
|
|
856
|
+
//obj.class = "nice-float"
|
|
857
|
+
if (obj.type == 'checkbox') {
|
|
858
|
+
html += `<div class="form-switch mx-auto div${obj.id} mb-3">${Form.field(obj)}<label class="form-check-label" for="">${obj.id} ${required}</label></div>`
|
|
859
|
+
} else {
|
|
860
|
+
html += `<div class="form-floating mx-auto mb-3 mt-3 div${obj.id} mb-3">${Form.field(obj)}<label for="${obj.id}">${obj.title} ${required} ${relation}</label></div>`
|
|
861
|
+
}
|
|
862
|
+
} else {
|
|
863
|
+
if (inline) {
|
|
864
|
+
if (obj.type == 'checkbox') {
|
|
865
|
+
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>`
|
|
866
|
+
} else {
|
|
867
|
+
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>`
|
|
868
|
+
}
|
|
869
|
+
} else {
|
|
870
|
+
if (obj.type == 'checkbox') {
|
|
871
|
+
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>`
|
|
872
|
+
} else {
|
|
873
|
+
html += `<div class="form-group div${obj.id} mb-3"><label for="${obj.id}">${obj.title} ${labelOptions} ${required} ${relation}</label>${Form.field(obj)}</div>`
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
return html
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
Form.modal = (obj, LANGUAGE = {}) => {
|
|
881
|
+
let attributeData = obj.attributeData,
|
|
882
|
+
visibles = obj.visibles || [],
|
|
883
|
+
invisibles = obj.invisibles || [],
|
|
884
|
+
visiblesHtml = '',
|
|
885
|
+
invisiblesHtml = '',
|
|
886
|
+
labelsHtml = ''
|
|
887
|
+
visibles.map((item) => {
|
|
888
|
+
visiblesHtml += `<li data-name="${item}" draggable="true" class="image-li" role="option" aria-grabbed="false"><img src="/assets/icons/eye.svg" class="icons-bg-black"> ${attributeData.labels[item]}</li>`
|
|
889
|
+
})
|
|
890
|
+
invisibles.map((item) => {
|
|
891
|
+
invisiblesHtml += `<li data-name="${item}" draggable="true" class="image-li" role="option" aria-grabbed="false"><img src="/assets/icons/eye-off.svg" class="icons-bg-black"> ${attributeData.labels[item]}</li>`
|
|
892
|
+
})
|
|
893
|
+
let no = 1
|
|
894
|
+
for (let key in attributeData.labels) {
|
|
895
|
+
labelsHtml += `<tr><td>${no}</td><td>${key}</td><td>${attributeData.labels[key]}</td><td><input maxlength="25" type="text" class="form-control" required name="${obj.routeName}[${key}]" value="${attributeData.labels[key]}"></td></tr>`
|
|
896
|
+
no++
|
|
897
|
+
}
|
|
898
|
+
const modalFields = Form.modalBuild({
|
|
899
|
+
id: 'grid-modal',
|
|
900
|
+
size: 'modal-xl',
|
|
901
|
+
header: `<h5 id="dynagrid-1-grid-modal-label" class="modal-title">
|
|
902
|
+
<i class="fa fa-cog"></i> ${LANGUAGE.grid_settings || 'Settings Grid'}
|
|
903
|
+
</h5>`,
|
|
904
|
+
body: `<div class="container">
|
|
905
|
+
<form id="form-grid" class="form-vertical kv-form-bs4" action="/${obj.routeName}/grid" method="post">
|
|
906
|
+
<input type="hidden" name="_csrf" value="">
|
|
907
|
+
<div class="dynagrid-column-label">
|
|
908
|
+
${LANGUAGE.grid_configure || 'Configure Order and Display of Grid Columns'}
|
|
909
|
+
</div>
|
|
910
|
+
<div class="row">
|
|
911
|
+
<div class="col-sm-5">
|
|
912
|
+
<ul id="gridleft" class="sortable-visible sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
|
|
913
|
+
<li data-name="" class="alert alert-info dynagrid-sortable-header disabled">
|
|
914
|
+
${LANGUAGE.grid_visible || 'Visible Columns'}
|
|
915
|
+
</li>
|
|
916
|
+
${visiblesHtml}
|
|
917
|
+
</ul>
|
|
918
|
+
</div>
|
|
919
|
+
<div class="col-sm-2 text-center">
|
|
920
|
+
<div class="dynagrid-sortable-separator"><i class="fas fa-arrows-alt-h"></i></div>
|
|
921
|
+
</div>
|
|
922
|
+
<div class="col-sm-5">
|
|
923
|
+
<ul id="gridright"
|
|
924
|
+
class="sortable-hidden sortable list kv-connected cursor-move gridsortable" aria-dropeffect="move">
|
|
925
|
+
<li data-name="" class="alert alert-info dynagrid-sortable-header disabled">${LANGUAGE.grid_invisible || 'Hidden / Fixed Columns'}
|
|
926
|
+
</li>
|
|
927
|
+
${invisiblesHtml}
|
|
928
|
+
</ul>
|
|
929
|
+
</div>
|
|
930
|
+
</div>
|
|
931
|
+
<input type="hidden" id="serialize_left" name="serialize_left" value=''/>
|
|
932
|
+
<input type="hidden" id="serialize_right" name="serialize_right" value=''/>
|
|
933
|
+
</form>
|
|
934
|
+
</div> <!-- .dynagrid-config-form -->`,
|
|
935
|
+
footer: `<select id="zgrid_default_type" class="form-control select-sm" style="width:100px"><option value="1">Standart</option><option value="2">Fixed Header</option><option value="3">Footer Total</option><option value="4">No Wrap</option><option value="5">Fixed Header & No Wrap</option><option value="6">Footer Total & No Wrap</option><option value="7">Fixed Header & Footer & No Wrap</option></select>
|
|
936
|
+
<button type="reset" class="btn btn-default refresh gridreload image-button" title="Abort any changes and reset settings">
|
|
937
|
+
<img src="/assets/icons/refresh.svg" class="icons-bg-black"> ${LANGUAGE.reset || 'Reset'}
|
|
938
|
+
</button>
|
|
939
|
+
<button type="button" class="btn btn-primary grid-submit boxy image-button" title="Save grid settings">
|
|
940
|
+
<img src="/assets/icons/send.svg" class="icons-bg-white"> ${LANGUAGE.apply || 'Apply'}
|
|
941
|
+
</button>`,
|
|
942
|
+
})
|
|
943
|
+
|
|
944
|
+
let modalFields2 = `
|
|
945
|
+
<div class="modal fade" id="grid-lock" tabindex="-1" aria-labelledby="grid-lock-label" aria-hidden="true">
|
|
946
|
+
<div class="modal-dialog">
|
|
947
|
+
<div class="modal-content">
|
|
948
|
+
<div class="modal-header">
|
|
949
|
+
<h1 class="modal-title fs-5">Lock/Unlock</h1>
|
|
950
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
951
|
+
</div>
|
|
952
|
+
<div class="modal-body">
|
|
953
|
+
<button title="Lock" style="background-color: #DC4C64; color:white" class="btn btn-save-lock boxy-small dimens2x image-button" type="button"><img src="/assets/icons/lock.svg" class="icons-bg-white"> Lock</button>
|
|
954
|
+
<button title="Unlock" style="background-color: #14A44D; color:white" class="btn btn-save-unlock boxy-small dimens2x image-button" type="button"><img src="/assets/icons/lock-open.svg" class="icons-bg-white"> Unlock</button>
|
|
955
|
+
</div>
|
|
956
|
+
</div>
|
|
957
|
+
</div>
|
|
958
|
+
</div>`
|
|
959
|
+
let modalFields3 = `
|
|
960
|
+
<div class="modal fade" id="grid-approval" tabindex="-1" aria-labelledby="grid-approval-label" aria-hidden="true">
|
|
961
|
+
<div class="modal-dialog">
|
|
962
|
+
<div class="modal-content">
|
|
963
|
+
<div class="modal-header">
|
|
964
|
+
<h1 class="modal-title fs-5" >Approvals</h1>
|
|
965
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
966
|
+
</div>
|
|
967
|
+
<div class="modal-body" style="min-height: 150px">
|
|
968
|
+
<div class="row"><div class="col-md-12 modal-body-approval"></div></div>
|
|
969
|
+
</div>
|
|
970
|
+
</div>
|
|
971
|
+
</div>
|
|
972
|
+
</div>`
|
|
973
|
+
let modalFields4 = `
|
|
974
|
+
<div class="modal fade" id="grid-delete-all" tabindex="-1" aria-labelledby="grid-delete-all-label" aria-hidden="true">
|
|
975
|
+
<div class="modal-dialog">
|
|
976
|
+
<div class="modal-content">
|
|
977
|
+
<div class="modal-header">
|
|
978
|
+
<h1 class="modal-title fs-5">Delete selected data</h1>
|
|
979
|
+
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
980
|
+
</div>
|
|
981
|
+
<div class="modal-body">
|
|
982
|
+
<button title="Delete All" style="background-color: #DC4C64; color:white" class="btn btn-save-delete-selected boxy-small dimens2x image-button" type="button"><img src="/assets/icons/http-delete.svg" class="icons-bg-white"> Delete selected data</button>
|
|
983
|
+
</div>
|
|
984
|
+
</div>
|
|
985
|
+
</div>
|
|
986
|
+
</div>`
|
|
987
|
+
try {
|
|
988
|
+
return modalFields + modalFields2 + modalFields3 + modalFields4
|
|
989
|
+
} catch (err) {
|
|
990
|
+
console.log(err)
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
|
|
994
|
+
Form.modalBuild = (obj) => {
|
|
995
|
+
let html = '<!-- Modal -->'
|
|
996
|
+
try {
|
|
997
|
+
const size = obj.size ? `${obj.size}` : ''
|
|
998
|
+
const id = obj.id ? `id="${obj.id}"` : ''
|
|
999
|
+
const headerOptions = Util.attributeOptions(obj.headerOptions || {}, { class: 'modal-header' })
|
|
1000
|
+
const header = obj.header ? `<div ${headerOptions} >${obj.header}<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button></div>` : ''
|
|
1001
|
+
const body = obj.body ? obj.body : ''
|
|
1002
|
+
const bodyOptions = Util.attributeOptions(obj.bodyOptions || {}, { class: 'modal-body' })
|
|
1003
|
+
const footerOptions = Util.attributeOptions(obj.footerOptions || {}, { class: 'modal-footer' })
|
|
1004
|
+
const footer = obj.footer ? `<div ${footerOptions} >${obj.footer}</div>` : ''
|
|
1005
|
+
html += `${Util.newLine}<div class="modal fade " ${id} role="dialog" tabindex="-1">
|
|
1006
|
+
<div class="modal-dialog ${size}">
|
|
1007
|
+
<div class="modal-content">
|
|
1008
|
+
${header}
|
|
1009
|
+
<div ${bodyOptions}>${body}</div>
|
|
1010
|
+
${footer}
|
|
1011
|
+
</div>
|
|
1012
|
+
</div>
|
|
1013
|
+
</div>`
|
|
1014
|
+
} catch (error) {
|
|
1015
|
+
console.log(error)
|
|
1016
|
+
}
|
|
1017
|
+
return html
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
module.exports = Form
|