[cleanup] Fixed some warnings

This commit is contained in:
Ferdinand Thiessen 2021-11-15 10:25:52 +01:00
parent 8b425e723e
commit c003b58183
1 changed files with 11 additions and 12 deletions

View File

@ -6,7 +6,7 @@
<div class="text-h6">Editere {{title}} {{ actualType.name }}</div>
</q-card-section>
<q-card-section>
<q-input v-model="actualType.name" :rules="rules" ref="dialogInput" dense label="name" filled />
<q-input ref="dialogInput" v-model="actualType.name" :rules="rules" dense label="name" filled />
</q-card-section>
<q-card-actions>
<q-btn flat color="danger" label="Abbrechen" @click="discardChanges()" />
@ -20,8 +20,8 @@
<q-table :title="title" :rows="rows" row-key="id" :columns="columns">
<template #top-right>
<q-input
v-model="actualType.name"
ref="input"
v-model="actualType.name"
:rules="rules"
dense
placeholder="Neuer Typ"
@ -62,22 +62,21 @@ export default defineComponent({
},
setup(props) {
const store = useScheduleStore();
const newType = ref('');
const dialogOpen = ref(false);
const emptyType = { id: -1, name: '' };
const actualType = ref(emptyType);
const input = ref<QInput>(null);
const dialogInput = ref<QInput>(null);
const storeName = computed(() => props.type.charAt(0).toLowerCase() + props.type.slice(1) + 's')
const input = ref<QInput>();
const dialogInput = ref<QInput>();
const storeName = computed(() => props.type == 'EventType' ? 'eventTypes' : 'jobTypes')
onBeforeMount(async () => await store[`get${props.type}s`]());
const rows = computed(() => store[storeName.value]);
const rows = computed(() => <(FG.EventType|FG.JobType)[]>store[storeName.value]);
const rules = [
(s: any) => !!s || 'Darf nicht leer sein!',
(s: unknown) => !!s || 'Darf nicht leer sein!',
(s: string) =>
store[storeName.value].find((e) => e.name === s) === undefined ||
rows.value.find((e) => e.name === s) === undefined ||
'Der Name wird bereits verwendet',
];
@ -98,7 +97,7 @@ export default defineComponent({
];
function addType() {
if (input.value === null || input.value.validate())
if (input.value === undefined || input.value.validate())
store
[`add${props.type}`](actualType.value.name)
.then(() => {
@ -124,8 +123,8 @@ export default defineComponent({
}
function saveChanges() {
if (dialogInput.value === null || dialogInput.value.validate())
store[`rename${props.type}`](actualType.value.id, actualType.value.name).then(() => discardChanges());
if (dialogInput.value === undefined || dialogInput.value.validate())
void store[`rename${props.type}`](actualType.value.id, actualType.value.name).then(() => discardChanges());
}
function discardChanges() {