negotiation-summary-section.js
1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const {
buildUpgradeIconUrl,
FORM_NAV_ICON_LEFT,
FORM_NAV_ICON_RIGHT
} = require('../../utils/upgrade-icon-url.js')
Component({
properties: {
label: {
type: String,
value: ''
},
recordRows: {
type: Array,
value: []
},
activeIndex: {
type: Number,
value: 0
}
},
data: {
visibleFields: [],
navIconLeft: '',
navIconRight: ''
},
lifetimes: {
attached() {
this.setData({
navIconLeft: buildUpgradeIconUrl(FORM_NAV_ICON_LEFT),
navIconRight: buildUpgradeIconUrl(FORM_NAV_ICON_RIGHT)
})
}
},
observers: {
'recordRows, activeIndex'(recordRows, activeIndex) {
const rows = Array.isArray(recordRows) ? recordRows : []
const index = Number(activeIndex)
const safeIndex = Number.isFinite(index) && index >= 0 ? index : 0
const row = rows[safeIndex] || { fields: [] }
this.setData({
visibleFields: Array.isArray(row.fields) ? row.fields : []
})
}
},
methods: {
onNav(e) {
const direction = Number(e.currentTarget.dataset.direction)
if (!direction) return
this.triggerEvent('nav', { direction })
}
}
})