Skip to content

Commit 20de995

Browse files
committed
enable conditional renering of fields
1 parent 3760eeb commit 20de995

File tree

3 files changed

+146
-110
lines changed

3 files changed

+146
-110
lines changed

pnpm-lock.yaml

Lines changed: 52 additions & 87 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/runtime/components/Form/Builder/Properties.vue

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
type Reactive,
1313
ref,
1414
} from "vue";
15-
import type { FormElementData, Pages, Stores } from "~/src/runtime/types";
15+
import type { _ElementData, FormElementData, Pages, Stores } from "~/src/runtime/types";
1616
1717
const props = defineProps({
1818
styles: {
@@ -78,10 +78,11 @@ const dependsOnField = computed(() => {
7878
return fields.value.find((f) => f.label === props.active?.dependsOn?.label);
7979
});
8080
81-
function updateDependsOnCondition(event: Event) {
81+
type Equality = NonNullable<_ElementData['dependsOn']>['condition']
82+
function updateDependsOnCondition(value: Equality) {
83+
console.log(value)
8284
if (!props.active?.dependsOn) return console.log("WTF!");
83-
const target = event.target as HTMLSelectElement;
84-
props.active.dependsOn.condition = target.value as any;
85+
props.active.dependsOn.condition = value;
8586
}
8687
</script>
8788

@@ -169,8 +170,8 @@ function updateDependsOnCondition(event: Event) {
169170
<div>
170171
<select
171172
class="input"
172-
style="width: 40px; border-radius: 3px"
173-
@change="updateDependsOnCondition"
173+
style="width: 4em; border-radius: 3px"
174+
@change="(event) => updateDependsOnCondition((event.target as HTMLSelectElement).value as Equality)"
174175
>
175176
<option
176177
value="eq"

0 commit comments

Comments
 (0)