Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e75ec4c

Browse files
committed
feat: use computed for matrix col/row available prop
1 parent 94a0dcf commit e75ec4c

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

src/composables/elements/useCells.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,12 @@ const base = function(props, context, dependencies)
100100
: row
101101
})
102102
.map(r => ({ ...r, label: form$.value.$vueform.sanitize(localize(r.label, config$.value, form$.value)) }))
103-
.map(r => ({ ...r, available: !r.conditions || !r.conditions.some((condition) => !form$.value.$vueform.services.condition.check(condition, path.value, form$.value, el$.value)) }))
103+
.map(r => ({
104+
...r,
105+
available: computed(() => !r.conditions || !r.conditions.some((condition) =>
106+
!form$.value.$vueform.services.condition.check(condition, path.value, form$.value, el$.value)
107+
))
108+
}))
104109
})
105110

106111
/**
@@ -123,7 +128,12 @@ const base = function(props, context, dependencies)
123128
: col
124129
})
125130
.map(r => ({ ...r, label: form$.value.$vueform.sanitize(localize(r.label, config$.value, form$.value)) }))
126-
.map(r => ({ ...r, available: !r.conditions || !r.conditions.some((condition) => !form$.value.$vueform.services.condition.check(condition, path.value, form$.value, el$.value)) }))
131+
.map(r => ({
132+
...r,
133+
available: computed(() => !r.conditions || !r.conditions.some((condition) =>
134+
!form$.value.$vueform.services.condition.check(condition, path.value, form$.value, el$.value)
135+
))
136+
}))
127137
})
128138

129139
/**

src/composables/elements/useMatrix.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const base = function(props, context, dependencies)
125125
const min = resolveWidth(minWidth.value, 'min-content')
126126
const max = resolveWidth(maxWidth.value, '1fr')
127127

128-
el$.value.resolvedColumns.filter(c => c.available).forEach((col, i) => {
128+
el$.value.resolvedColumns.filter(c => c.available.value).forEach((col, i) => {
129129
const colMin = resolveWidth(col.minWidth, min)
130130
const colMax = resolveWidth(col.maxWidth, max)
131131

themes/blank/templates/elements/MatrixElement.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@
1111
<div v-if="rowsVisible && colsVisible" :class="classes.headerFirst" />
1212
<!-- Column headers -->
1313
<template v-for="(col, c) in resolvedColumns">
14-
<div v-if="colsVisible" v-show="col.available" v-html="col.label" :class="classes.header" />
14+
<div v-if="colsVisible" v-show="col.available.value" v-html="col.label" :class="classes.header" />
1515
</template>
1616
<!-- Remove column -->
1717
<div v-if="allowRemove && colsVisible" :class="classes.headerRemove" />
1818

1919
<!-- Content rows -->
2020
<template v-for="(row, r) in resolvedRows">
2121
<!-- Row label -->
22-
<div v-if="rowsVisible" v-show="row.available" v-html="row.label" :class="classes.rowLabel" />
22+
<div v-if="rowsVisible" v-show="row.available.value" v-html="row.label" :class="classes.rowLabel" />
2323
<!-- Input cells -->
2424
<template v-for="(col, c) in resolvedColumns">
25-
<div v-show="row.available && col.available" :class="classes.cell">
25+
<div v-show="row.available.value && col.available.value" :class="classes.cell">
2626
<div :class="classes.cellWrapper(resolveColType(col), resolveComponentName(r, c))">
2727
<component
2828
:is="resolveComponentType(col)"

0 commit comments

Comments
 (0)