zet-lib 1.2.68 → 1.2.70
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/zRoute.js +26 -6
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -544,7 +544,12 @@ zRoute.relations = async (req, res, table) => {
|
|
|
544
544
|
let nots = Util.nots
|
|
545
545
|
let obj = {}
|
|
546
546
|
let visibles = MODEL_TABLE.grids.visibles
|
|
547
|
+
//exclude lock,approval_status, approval_history
|
|
548
|
+
let notIncludes = ['lock', 'approval_status', 'approval_history', 'created_at']
|
|
549
|
+
visibles = visibles.filter((item) => !notIncludes.includes(item))
|
|
547
550
|
let invisibles = MODEL_TABLE.grids.invisibles
|
|
551
|
+
invisibles = invisibles.filter((item) => !notIncludes.includes(item))
|
|
552
|
+
|
|
548
553
|
let properties = {}
|
|
549
554
|
visibles.forEach(function (item) {
|
|
550
555
|
if (!Util.in_array(item, nots)) {
|
|
@@ -558,6 +563,9 @@ zRoute.relations = async (req, res, table) => {
|
|
|
558
563
|
properties[item] = MODEL_TABLE.widgets[item]
|
|
559
564
|
}
|
|
560
565
|
})
|
|
566
|
+
delete properties.lock
|
|
567
|
+
delete properties.approval_status
|
|
568
|
+
delete properties.approval_history
|
|
561
569
|
relations[key] = obj
|
|
562
570
|
relations[`properties_${key}`] = properties
|
|
563
571
|
relations[keyRow] = await zRoute.relations(req, res, widget.table)
|
|
@@ -2510,7 +2518,7 @@ zRoute.viewFormsSync = async (req, res, MYMODEL, data = {}) => {
|
|
|
2510
2518
|
let val = obj.value || []
|
|
2511
2519
|
if (val.length) {
|
|
2512
2520
|
val.forEach(function (item) {
|
|
2513
|
-
let myforms = zRoute.viewForm(req, res, MODEL, relationsTable, item)
|
|
2521
|
+
let myforms = zRoute.viewForm(req, res, MODEL, relationsTable, item, MYMODEL)
|
|
2514
2522
|
html += `<tr>`
|
|
2515
2523
|
for (let k in obj.data) {
|
|
2516
2524
|
html += `<td>${cForm.field(myforms.obj[k])}</td>`
|
|
@@ -2551,7 +2559,8 @@ zRoute.viewFormSync = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2551
2559
|
return forms
|
|
2552
2560
|
}
|
|
2553
2561
|
|
|
2554
|
-
zRoute.viewForm = (req, res, MYMODEL, relations, data = {}) => {
|
|
2562
|
+
zRoute.viewForm = (req, res, MYMODEL, relations, data = {}, MODEL_TABLE = {}) => {
|
|
2563
|
+
let isTableType = Object.keys(MODEL_TABLE).length > 0 ? true : false
|
|
2555
2564
|
let forms = zRoute.forms(req, res, MYMODEL, relations, data)
|
|
2556
2565
|
const widgets = MYMODEL.widgets
|
|
2557
2566
|
let obj = forms.obj
|
|
@@ -2578,16 +2587,27 @@ zRoute.viewForm = (req, res, MYMODEL, relations, data = {}) => {
|
|
|
2578
2587
|
case 'image':
|
|
2579
2588
|
obj[key].type = 'plaintext'
|
|
2580
2589
|
let width = widgets[key].width || '300'
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
Util.fileView(`/uploads/${MYMODEL.routeName}/`, data[key], {
|
|
2590
|
+
if (isTableType) {
|
|
2591
|
+
obj[key].value = Util.fileView(`/uploads/${MODEL_TABLE.routeName}/${MYMODEL.routeName}/`, data[key], {
|
|
2584
2592
|
width: width,
|
|
2585
2593
|
class: 'boxy',
|
|
2586
2594
|
})
|
|
2595
|
+
} else {
|
|
2596
|
+
obj[key].value =
|
|
2597
|
+
'<br><br>' +
|
|
2598
|
+
Util.fileView(`/uploads/${MYMODEL.routeName}/`, data[key], {
|
|
2599
|
+
width: width,
|
|
2600
|
+
class: 'boxy',
|
|
2601
|
+
})
|
|
2602
|
+
}
|
|
2587
2603
|
break
|
|
2588
2604
|
case 'file':
|
|
2589
2605
|
obj[key].type = 'plaintext'
|
|
2590
|
-
|
|
2606
|
+
if (isTableType) {
|
|
2607
|
+
obj[key].value = Util.fileView(`/uploads/${MODEL_TABLE.routeName}/${MYMODEL.routeName}/`, data[key], { withIcon: true })
|
|
2608
|
+
} else {
|
|
2609
|
+
obj[key].value = '<br><br>' + Util.fileView(`/uploads/${MYMODEL.routeName}/`, data[key], { withIcon: true })
|
|
2610
|
+
}
|
|
2591
2611
|
break
|
|
2592
2612
|
case 'switch':
|
|
2593
2613
|
obj[key].type = 'plaintext'
|