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