zet-lib 1.2.114 → 1.2.115
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 +23 -22
- package/lib/zRoute.js +47 -4
- package/package.json +1 -1
package/lib/Form.js
CHANGED
|
@@ -79,6 +79,7 @@ Form.field = (obj) => {
|
|
|
79
79
|
form_css = !obj.form_css ? 'bootstrap' : obj.form_css,
|
|
80
80
|
attributes = !obj.attributes ? {} : obj.attributes,
|
|
81
81
|
style = !obj.style ? '' : ` style=${obj.style} `,
|
|
82
|
+
additional_attributes = !obj.additional_attributes ? '' : obj.additional_attributes,
|
|
82
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>`
|
|
83
84
|
//replaceAll("\r\n","<br>")
|
|
84
85
|
let attributeDate = ''
|
|
@@ -109,12 +110,12 @@ Form.field = (obj) => {
|
|
|
109
110
|
selects = ''
|
|
110
111
|
switch (type) {
|
|
111
112
|
case 'text':
|
|
112
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" ${disabled} ${readonly} autofocus="" ${tabindex} type="${type}" ${classview} ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
113
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" ${disabled} ${readonly} autofocus="" ${tabindex} ${additional_attributes} type="${type}" ${classview} ${id} ${name} ${placeholder} ${style} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
113
114
|
break
|
|
114
115
|
|
|
115
116
|
case 'checkbox':
|
|
116
117
|
checked = value == 1 ? 'checked' : ''
|
|
117
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} ${disabled} ${readonly} ${style} type="checkbox" class="form-check-input ${obj.class}" ${id} ${name} ${checked} ${htmlOptions}>${information}${append}`
|
|
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}`
|
|
118
119
|
break
|
|
119
120
|
|
|
120
121
|
case 'tags':
|
|
@@ -131,7 +132,7 @@ Form.field = (obj) => {
|
|
|
131
132
|
datahtml += `<option value="${item}" selected="selected">${item}</option>`
|
|
132
133
|
})
|
|
133
134
|
}
|
|
134
|
-
displayForm = `${prepend}<select ${classview} ${id} ${name}
|
|
135
|
+
displayForm = `${prepend}<select ${classview} ${id} ${name} ${additional_attributes} ${placeholder} multiple data-allow-new="true">${datahtml}</select>${information}${append}`
|
|
135
136
|
break
|
|
136
137
|
|
|
137
138
|
case 'range':
|
|
@@ -141,11 +142,11 @@ Form.field = (obj) => {
|
|
|
141
142
|
break
|
|
142
143
|
|
|
143
144
|
case 'hidden':
|
|
144
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} type="${type}"
|
|
145
|
+
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${tabindex} type="${type}" ${additional_attributes} ${style} ${classview} ${id} ${name} ${placeholder} ${required} value="${value}" data-t="${value}" ${htmlOptions}>${append}`
|
|
145
146
|
break
|
|
146
147
|
|
|
147
148
|
case 'textarea':
|
|
148
|
-
displayForm = `${prepend}${inputGroupLeft}<textarea ${tabindex} ${disabled} ${classview} ${id} ${name}
|
|
149
|
+
displayForm = `${prepend}${inputGroupLeft}<textarea ${tabindex} ${disabled} ${classview} ${id} ${name} ${additional_attributes} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${value}</textarea>${inputGroupRight}${information}${append}`
|
|
149
150
|
break
|
|
150
151
|
|
|
151
152
|
case 'image':
|
|
@@ -171,32 +172,32 @@ Form.field = (obj) => {
|
|
|
171
172
|
break
|
|
172
173
|
|
|
173
174
|
case 'email':
|
|
174
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${readonly} ${disabled} ${tabindex} ${style} type="email" ${classview} ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
175
|
+
displayForm = `${prepend}<input autocomplete="off" autofocus="" ${readonly} ${disabled} ${additional_attributes} ${tabindex} ${style} type="email" ${classview} ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
175
176
|
break
|
|
176
177
|
|
|
177
178
|
case 'number':
|
|
178
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly}
|
|
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}`
|
|
179
180
|
break
|
|
180
181
|
|
|
181
182
|
case 'integer':
|
|
182
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${tabindex} ${style} type="number" class="form-control ${obj.class}" ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}>${inputGroupRight}${information}${append}`
|
|
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}`
|
|
183
184
|
break
|
|
184
185
|
|
|
185
186
|
case 'datepicker':
|
|
186
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly}
|
|
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}`
|
|
187
188
|
break
|
|
188
189
|
|
|
189
190
|
case 'datetimepicker':
|
|
190
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly}
|
|
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}`
|
|
191
192
|
break
|
|
192
193
|
|
|
193
194
|
case 'password':
|
|
194
|
-
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${tabindex} ${style} type="password" ${classview} ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}><span toggle="#password" class="bx bi-eye field-icon toggle-password"></span>${inputGroupRight}${information}${append}`
|
|
195
|
+
displayForm = `${prepend}${inputGroupLeft}<input autocomplete="off" autofocus="" ${disabled} ${readonly} ${additional_attributes} ${tabindex} ${style} type="password" ${classview} ${id} ${name} ${placeholder} ${required} value="${value}" ${htmlOptions}><span toggle="#password" class="bx bi-eye field-icon toggle-password"></span>${inputGroupRight}${information}${append}`
|
|
195
196
|
break
|
|
196
197
|
|
|
197
198
|
case 'switch':
|
|
198
199
|
checked = value == 1 ? ' checked ' : ''
|
|
199
|
-
displayForm = `${prepend}<p><input ${tabindex} type="checkbox" ${classview} ${readonly} ${style} ${id}
|
|
200
|
+
displayForm = `${prepend}<p><input ${tabindex} type="checkbox" ${classview} ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} ></p>${information}${append}`
|
|
200
201
|
break
|
|
201
202
|
|
|
202
203
|
case 'lexical':
|
|
@@ -205,7 +206,7 @@ Form.field = (obj) => {
|
|
|
205
206
|
|
|
206
207
|
case 'checkbox':
|
|
207
208
|
checked = value == 1 ? ' checked ' : ''
|
|
208
|
-
displayForm = `${prepend}<input
|
|
209
|
+
displayForm = `${prepend}<input ${tabindex} type="${type}" ${classview} ${readonly} ${style} ${id} ${additional_attributes} ${name} ${checked} >${information}${append}`
|
|
209
210
|
break
|
|
210
211
|
|
|
211
212
|
case 'dropdown_checkbox':
|
|
@@ -273,7 +274,7 @@ Form.field = (obj) => {
|
|
|
273
274
|
if (form_css == 'material_design') {
|
|
274
275
|
classview = Form.addProperty('class', ['selectpicker', obj.class])
|
|
275
276
|
}
|
|
276
|
-
displayForm = `${prepend}<select ${tabindex} ${style}
|
|
277
|
+
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}`
|
|
277
278
|
break
|
|
278
279
|
|
|
279
280
|
case 'radio':
|
|
@@ -283,7 +284,7 @@ Form.field = (obj) => {
|
|
|
283
284
|
//var selected = item.value == value ? ' selected ' : '';
|
|
284
285
|
const checked = item.value == value ? ' checked ' : ''
|
|
285
286
|
radios += `<div class="form-check">
|
|
286
|
-
<input class="form-check-input" type="radio" name="${obj.name}" value="${item.value}" id="${obj.id}${index}" ${checked}>
|
|
287
|
+
<input class="form-check-input" type="radio" name="${obj.name}" ${additional_attributes} value="${item.value}" id="${obj.id}${index}" ${checked}>
|
|
287
288
|
<label class="form-check-label" for="${obj.id}${index}">
|
|
288
289
|
${item.label}
|
|
289
290
|
</label>
|
|
@@ -366,7 +367,7 @@ Form.field = (obj) => {
|
|
|
366
367
|
|
|
367
368
|
case 'table':
|
|
368
369
|
let html = ''
|
|
369
|
-
/*console.log(`table : ${obj.data}`)
|
|
370
|
+
/*console.log(`table : ${JSON.stringify(obj.data)}`)
|
|
370
371
|
console.log(JSON.stringify(obj.data))
|
|
371
372
|
console.log(JSON.stringify(obj.properties));*/
|
|
372
373
|
for (let key in obj.data) {
|
|
@@ -399,7 +400,7 @@ Form.field = (obj) => {
|
|
|
399
400
|
${obj.btnAdd}
|
|
400
401
|
</tr>
|
|
401
402
|
</thead>
|
|
402
|
-
<tbody id="body-${obj.id}" data-value='${datavalue}'>${obj.
|
|
403
|
+
<tbody id="body-${obj.id}" data-value='${datavalue}'>${obj.bodyTable}</tbody>
|
|
403
404
|
</table></div>`
|
|
404
405
|
displayForm = Form.card(frameworkcss, obj)
|
|
405
406
|
break
|
|
@@ -416,23 +417,23 @@ Form.field = (obj) => {
|
|
|
416
417
|
|
|
417
418
|
case 'ide_editor':
|
|
418
419
|
displayForm = `<div class="ide_editor" id="editor_${obj.id}"></div>`
|
|
419
|
-
displayForm += `<textarea hidden ${classview} ${id} ${name} ${placeholder}
|
|
420
|
+
displayForm += `<textarea hidden ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4"></textarea>${information}${append}`
|
|
420
421
|
break
|
|
421
422
|
|
|
422
423
|
case 'json':
|
|
423
|
-
displayForm += `<textarea
|
|
424
|
+
displayForm += `<textarea ${additional_attributes} ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
424
425
|
break
|
|
425
426
|
|
|
426
427
|
case 'json_array':
|
|
427
|
-
displayForm += `<textarea
|
|
428
|
+
displayForm += `<textarea ${additional_attributes} ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
428
429
|
break
|
|
429
430
|
|
|
430
431
|
case 'array':
|
|
431
|
-
displayForm += `<textarea
|
|
432
|
+
displayForm += `<textarea ${additional_attributes} ${classview} ${id} ${name} ${placeholder} ${readonly} ${style} ${htmlOptions} rows="4">${JSON.stringify(obj.value)}</textarea>${information}${append}`
|
|
432
433
|
break
|
|
433
434
|
|
|
434
435
|
case 'virtual':
|
|
435
|
-
displayForm = `${prepend}<input autocomplete="off" autofocus=""
|
|
436
|
+
displayForm = `${prepend}<input ${additional_attributes} autocomplete="off" autofocus="" ${tabindex} ${style} type="text" ${classview} readonly ${id} ${placeholder} ${required} value="${value}" ${htmlOptions}>${information}${append}`
|
|
436
437
|
break
|
|
437
438
|
|
|
438
439
|
//additionals for form view in view
|
package/lib/zRoute.js
CHANGED
|
@@ -2250,7 +2250,14 @@ zRoute.formField = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2250
2250
|
|
|
2251
2251
|
zRoute.formsFieldSync = async (req, res, MYMODEL, data = {}) => {
|
|
2252
2252
|
const relations = await zRoute.relations(req, res, MYMODEL.table)
|
|
2253
|
-
let
|
|
2253
|
+
let tableRelations = {}
|
|
2254
|
+
for (let key in MYMODEL.widgets) {
|
|
2255
|
+
if (MYMODEL.widgets[key].name == 'table') {
|
|
2256
|
+
tableRelations[key] = await zRoute.relations(req, res, MYMODEL.widgets[key].table)
|
|
2257
|
+
//console.log("tabelrelations", JSON.stringify(tableRelations[key]))
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
let forms = zRoute.forms(req, res, MYMODEL, relations, data, tableRelations)
|
|
2254
2261
|
let obj = forms.obj
|
|
2255
2262
|
for (let key in obj) {
|
|
2256
2263
|
forms.build[key] = cForm.build(obj[key])
|
|
@@ -2269,8 +2276,9 @@ zRoute.formFieldSync = async (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2269
2276
|
return forms
|
|
2270
2277
|
}
|
|
2271
2278
|
|
|
2272
|
-
zRoute.forms = (req, res, MYMODEL, relations, data = {}) => {
|
|
2279
|
+
zRoute.forms = (req, res, MYMODEL, relations, data = {}, tableRelations = {}) => {
|
|
2273
2280
|
relations = relations || {}
|
|
2281
|
+
let MYMODELS = zRoute.MYMODELS()
|
|
2274
2282
|
let fields = MYMODEL.fields
|
|
2275
2283
|
let dropdowns = MYMODEL.dropdowns || {}
|
|
2276
2284
|
let modules = MYMODEL.modules || {}
|
|
@@ -2498,7 +2506,11 @@ zRoute.forms = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2498
2506
|
case 'table':
|
|
2499
2507
|
obj.type = 'table'
|
|
2500
2508
|
obj.data = relations[key]
|
|
2509
|
+
//console.log(obj.data)
|
|
2501
2510
|
obj.properties = relations[`properties_${key}`]
|
|
2511
|
+
//console.log(obj.properties)
|
|
2512
|
+
//(req, res, relations, dataObject, parentTable, fieldName, MYMODEL, datas = [])
|
|
2513
|
+
obj.bodyTable = zRoute.tableBody(req, res, tableRelations[key], obj.data, MYMODEL.table, key, MYMODELS[MYMODEL.widgets[key].table], obj.value)
|
|
2502
2514
|
break
|
|
2503
2515
|
case 'multi_line_editor':
|
|
2504
2516
|
obj.type = 'multi_line_editor'
|
|
@@ -3578,12 +3590,12 @@ $("#body-${keys}>tr").each(function (index, tr) {
|
|
|
3578
3590
|
}
|
|
3579
3591
|
`
|
|
3580
3592
|
|
|
3581
|
-
scriptForm += ` $(function () {
|
|
3593
|
+
/* scriptForm += ` $(function () {
|
|
3582
3594
|
var ${keys} = $("#body-${keys}").data("value") ? $("#body-${keys}").data("value") : [];
|
|
3583
3595
|
${keys}.forEach(function (myobj, index) {
|
|
3584
3596
|
build${keys}form(index, myobj);
|
|
3585
3597
|
});
|
|
3586
|
-
});${Util.newLine}
|
|
3598
|
+
});${Util.newLine}`*/
|
|
3587
3599
|
|
|
3588
3600
|
break
|
|
3589
3601
|
|
|
@@ -4435,6 +4447,7 @@ zRoute.typeahead = async (req, res) => {
|
|
|
4435
4447
|
let json = myCache.get(name)
|
|
4436
4448
|
res.json(json)
|
|
4437
4449
|
}
|
|
4450
|
+
|
|
4438
4451
|
zRoute.typeaheadpost = async (req, res) => {
|
|
4439
4452
|
let table = req.params.table
|
|
4440
4453
|
let keys = req.params.field
|
|
@@ -4561,4 +4574,34 @@ zRoute.history = async (req, res, relations, id, MYMODEL, users, results = []) =
|
|
|
4561
4574
|
}
|
|
4562
4575
|
return html
|
|
4563
4576
|
}
|
|
4577
|
+
|
|
4578
|
+
zRoute.tableBody = (req, res, relations, dataObject, parentTable, fieldName, MYMODEL, datas = []) => {
|
|
4579
|
+
let html = ''
|
|
4580
|
+
try {
|
|
4581
|
+
if (datas.length > 0) {
|
|
4582
|
+
datas.map((data, index) => {
|
|
4583
|
+
let forms = zRoute.forms(req, res, MYMODEL, relations, data)
|
|
4584
|
+
let obj = forms.obj
|
|
4585
|
+
if (index == 0) {
|
|
4586
|
+
//zRoute.moduleLib(req, res, MYMODEL, relations, forms);
|
|
4587
|
+
}
|
|
4588
|
+
html += `<tr data-id="${index}" data-name="${parentTable}[${fieldName}]">`
|
|
4589
|
+
for (let key in dataObject) {
|
|
4590
|
+
let myobj = obj[key]
|
|
4591
|
+
myobj.value = data[key]
|
|
4592
|
+
myobj.class = `${parentTable}_${fieldName}_${key}`
|
|
4593
|
+
myobj.name = `ztest_aja[${fieldName}][${index}][${key}]`
|
|
4594
|
+
myobj.additional_attributes = ` data-name="${key}" data-id="${parentTable}_${fieldName}_${key}" `
|
|
4595
|
+
html += `<td class="td_${key}_${MYMODEL.table}">${cForm.field(myobj)}</td>`
|
|
4596
|
+
}
|
|
4597
|
+
html += `<td style="vertical-align:top"><span class="icon-small icons-danger trash_${fieldName}_${MYMODEL.table}" onclick="$(this).closest('tr').remove()" title="Delete"><img class="icons-bg-white griddelete icon-image" src="/assets/icons/trash-filled.svg"></span></td>`
|
|
4598
|
+
html += `</tr>`
|
|
4599
|
+
})
|
|
4600
|
+
}
|
|
4601
|
+
return html
|
|
4602
|
+
} catch (e) {
|
|
4603
|
+
console.log(e)
|
|
4604
|
+
}
|
|
4605
|
+
return html
|
|
4606
|
+
}
|
|
4564
4607
|
module.exports = zRoute
|