From 5e2427ee81bf7de8ce041abbb8cc1543ce9d5379 Mon Sep 17 00:00:00 2001 From: philipp lang Date: Fri, 19 Apr 2024 23:57:05 +0200 Subject: [PATCH] Add condition for checkbox field --- resources/js/views/form/Conditions.vue | 50 ++++++++++++++++++++------ 1 file changed, 39 insertions(+), 11 deletions(-) diff --git a/resources/js/views/form/Conditions.vue b/resources/js/views/form/Conditions.vue index ad38db12..a494075e 100644 --- a/resources/js/views/form/Conditions.vue +++ b/resources/js/views/form/Conditions.vue @@ -10,17 +10,24 @@ Bedingung einfügen
- + +
@@ -57,10 +71,10 @@ const props = defineProps({ }); const comparatorOptions = ref([ - {id: 'isEqual', name: 'ist gleich', defaultValue: null}, - {id: 'isNotEqual', name: 'ist ungleich', defaultValue: null}, - {id: 'isIn', name: 'ist in', defaultValue: []}, - {id: 'isNotIn', name: 'ist nicht in', defaultValue: []}, + {id: 'isEqual', name: 'ist gleich', defaultValue: {DropdownField: null, RadioField: null, CheckboxField: false}}, + {id: 'isNotEqual', name: 'ist ungleich', defaultValue: {DropdownField: null, RadioField: null, CheckboxField: false}}, + {id: 'isIn', name: 'ist in', defaultValue: {DropdownField: [], RadioField: [], CheckboxField: false}}, + {id: 'isNotIn', name: 'ist nicht in', defaultValue: {DropdownField: [], RadioField: [], CheckboxField: false}}, ]); const modeOptions = ref([ @@ -81,9 +95,23 @@ const fields = computed(() => { return result; }); -function updateComparator(condition, comparator) { - condition.value = comparatorOptions.value.find((c) => c.id === comparator).defaultValue; - condition.comparator = comparator; +function update(index, key, value) { + if (key === 'comparator') { + var old = inner.value.ifs[index]; + inner.value.ifs[index] = { + field: old.field, + comparator: value, + value: old.field ? comparatorOptions.value.find((c) => c.id === value).defaultValue[getField(old.field).type] : null, + }; + } + if (key === 'field') { + var old = inner.value.ifs[index]; + inner.value.ifs[index] = { + field: value, + comparator: null, + value: null, + }; + } } function getField(fieldName) {