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

View File

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

View File

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