fix add jobs

This commit is contained in:
Tim Gröger 2023-04-24 21:14:19 +02:00
parent f54911ed48
commit 9359db3881
3 changed files with 28 additions and 30 deletions

View File

@ -82,13 +82,14 @@
</div>
</div>
<template v-for="(job, index) in event.jobs" :key="index">
<!--:ref="active === index ? 'activeJob' : undefined"-->
<edit-job-slot
:ref="active === index ? 'activeJob' : undefined"
ref="activeJob"
v-model="event.jobs[index]"
:active="index === active"
class="q-mb-md"
@activate="activate(index)"
@remove-job="removeJob(index)"
@activate="activate(index)"
/>
</template>
</q-card-section>
@ -113,7 +114,7 @@ import { IsoDateInput } from '@flaschengeist/api/components';
import { useEventStore } from '../../store';
import { emptyEvent, emptyJob, EditableEvent } from '../../store/models';
import { date, ModifyDateOptions } from 'quasar';
import { date, DateOptions } from 'quasar';
import { computed, defineComponent, PropType, ref, onBeforeMount, watch } from 'vue';
import EditJobSlot from './EditJobSlot.vue';
@ -164,9 +165,12 @@ export default defineComponent({
);
function addJob() {
if (!activeJob.value) event.value.jobs.push(emptyJob());
else
void activeJob.value.validate().then((success) => {
console.log('addJob', activeJob.value);
if (!activeJob.value[active.value]) {
event.value.jobs.push(emptyJob());
active.value = event.value.jobs.length - 1;
} else
void activeJob.value[active.value].validate().then((success) => {
if (success) {
event.value.jobs.push(emptyJob());
active.value = event.value.jobs.length - 1;
@ -210,7 +214,7 @@ export default defineComponent({
if (props.modelValue === undefined && recurrent.value && !event.value.is_template) {
let count = 0;
const options: ModifyDateOptions = {};
const options: DateOptions = {};
switch (recurrenceRule.value.frequency) {
case 'daily':
options['days'] = 1 * recurrenceRule.value.interval;
@ -263,7 +267,7 @@ export default defineComponent({
!d || event.value.start <= d || 'Das Veranstaltungsende muss vor dem Beginn liegen';
function activate(idx: number) {
void activeJob.value?.validate().then((s) => {
void activeJob.value[active.value]?.validate().then((s) => {
if (s) active.value = idx;
});
}

View File

@ -28,27 +28,21 @@
</q-card>
</q-dialog>
<q-table :title="title" :rows="rows" row-key="id" :columns="columns">
<template #top-right>
<q-input
ref="input"
v-model="actualType.name"
:rules="rules"
dense
placeholder="Neuer Typ"
>
<slot name="after"
><q-btn color="primary" icon="mdi-plus" title="Hinzufügen" @click="addType"
/></slot>
</q-input>
</template>
<template #body-cell-actions="props">
<q-td :props="props" align="right" :auto-width="true">
<q-btn round icon="mdi-pencil" @click="editType(props.row.id)" />
<q-btn round icon="mdi-delete" @click="deleteType(props.row.id)" />
</q-td>
</template>
</q-table>
<q-table :title="title" :rows="rows" row-key="id" :columns="columns">
<template #top-right>
<q-input ref="input" v-model="actualType.name" :rules="rules" dense placeholder="Neuer Typ">
<slot name="after"
><q-btn color="primary" icon="mdi-plus" title="Hinzufügen" @click="addType"
/></slot>
</q-input>
</template>
<template #body-cell-actions="props">
<q-td :props="props" align="right" :auto-width="true">
<q-btn round icon="mdi-pencil" @click="editType(props.row.id)" />
<q-btn round icon="mdi-delete" @click="deleteType(props.row.id)" />
</q-td>
</template>
</q-table>
</div>
</template>

View File

@ -1,5 +1,5 @@
{
"extends": "@quasar/app/tsconfig-preset",
"extends": "@quasar/app-webpack/tsconfig-preset",
"target": "esnext",
"compilerOptions": {
"baseUrl": "./src/",