This commit is contained in:
philipp lang 2024-07-15 16:59:29 +02:00
parent bf1388dbd9
commit 158cd2d352
1 changed files with 23 additions and 20 deletions

View File

@ -53,8 +53,8 @@
</div> </div>
</template> </template>
<script lang="js" setup> <script setup>
import { ref, inject, computed } from 'vue'; import {ref, inject, computed} from 'vue';
const axios = inject('axios'); const axios = inject('axios');
const emit = defineEmits(['update:modelValue']); const emit = defineEmits(['update:modelValue']);
@ -70,19 +70,19 @@ const props = defineProps({
id: { id: {
required: true, required: true,
type: String, type: String,
} },
}); });
const comparatorOptions = ref([ const comparatorOptions = ref([
{ id: 'isEqual', name: 'ist gleich', defaultValue: { DropdownField: null, RadioField: null, CheckboxField: false } }, {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: 'isNotEqual', name: 'ist ungleich', defaultValue: {DropdownField: null, RadioField: null, CheckboxField: false}},
{ id: 'isIn', name: 'ist in', defaultValue: { DropdownField: [], RadioField: [], CheckboxField: false } }, {id: 'isIn', name: 'ist in', defaultValue: {DropdownField: [], RadioField: [], CheckboxField: false}},
{ id: 'isNotIn', name: 'ist nicht in', defaultValue: { DropdownField: [], RadioField: [], CheckboxField: false } }, {id: 'isNotIn', name: 'ist nicht in', defaultValue: {DropdownField: [], RadioField: [], CheckboxField: false}},
]); ]);
const modeOptions = ref([ const modeOptions = ref([
{ id: 'all', name: 'alle Bedingungen müssen zutreffen' }, {id: 'all', name: 'alle Bedingungen müssen zutreffen'},
{ id: 'any', name: 'mindestens eine Bedingung muss zutreffen' }, {id: 'any', name: 'mindestens eine Bedingung muss zutreffen'},
]); ]);
const fields = computed(() => { const fields = computed(() => {
@ -133,31 +133,34 @@ function getField(fieldName) {
function getOptions(fieldName) { function getOptions(fieldName) {
return getField(fieldName).options.map((o) => { return getField(fieldName).options.map((o) => {
return { id: o, name: o }; return {id: o, name: o};
}); });
} }
const fieldOptions = computed(() => const fieldOptions = computed(() =>
fields.value.map((field) => { fields.value.map((field) => {
return { id: field.key, name: field.name }; return {id: field.key, name: field.name};
}) })
); );
function addCondition() { function addCondition() {
emit('update:modelValue', {...props.modelValue, ifs: [ emit('update:modelValue', {
...props.modelValue.ifs, ...props.modelValue,
{ ifs: [
field: null, ...props.modelValue.ifs,
comparator: null, {
value: null, field: null,
} comparator: null,
]}); value: null,
},
],
});
} }
const locked = ref(false); const locked = ref(false);
async function checkIfDirty() { async function checkIfDirty() {
const response = await axios.post(props.single.links.is_dirty, { config: props.single.config }); const response = await axios.post(props.single.links.is_dirty, {config: props.single.config});
locked.value = response.data.result; locked.value = response.data.result;
} }