update task and schema module
This commit is contained in:
@@ -14,6 +14,7 @@ function repeatLabel(schema) {
|
||||
if (schema.repeat['2week']) return '2-Wöchentlich'
|
||||
if (schema.repeat['4week']) return '4-Wöchentlich'
|
||||
if (schema.repeat.monthly) return 'Monatlich'
|
||||
if (schema.repeat.days) return 'Mehrere Tage'
|
||||
return ''
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { ref } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useSchemasStore } from '../stores/schemas'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const store = useSchemasStore()
|
||||
@@ -16,6 +17,7 @@ const form = ref({
|
||||
end: '',
|
||||
weekly: Array(7).fill(false),
|
||||
monthly: Array(31).fill(false),
|
||||
days: [],
|
||||
})
|
||||
|
||||
const submitting = ref(false)
|
||||
@@ -46,6 +48,8 @@ function buildPayload() {
|
||||
data.repeat = { '4week': [...form.value.weekly] }
|
||||
} else if (form.value.repeatType === 'monthly') {
|
||||
data.repeat = { monthly: [...form.value.monthly] }
|
||||
} else if (form.value.repeatType === 'days') {
|
||||
data.repeat = { days: form.value.days.filter(d => d) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +104,7 @@ async function onSave() {
|
||||
<option value="2week">2-Wöchentlich</option>
|
||||
<option value="4week">4-Wöchentlich</option>
|
||||
<option value="monthly">Monatlich</option>
|
||||
<option value="days">Mehrere Tage</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -128,7 +133,18 @@ async function onSave() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="form.repeatType !== 'none'" class="field-row">
|
||||
<div v-if="form.repeatType === 'days'" class="field">
|
||||
<label>Termine</label>
|
||||
<div v-for="(d, i) in form.days" :key="i" class="days-row">
|
||||
<input type="date" v-model="form.days[i]" />
|
||||
<button type="button" class="icon-btn" @click="form.days.splice(i, 1)" title="Entfernen">
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="add-termin" @click="form.days.push('')">+ Termin</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!['none', 'days'].includes(form.repeatType)" class="field-row">
|
||||
<div class="field">
|
||||
<label for="start">Start</label>
|
||||
<input id="start" v-model="form.start" type="date" />
|
||||
@@ -249,6 +265,35 @@ button:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.days-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.days-row input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
width: 2.5rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icon-btn:hover {
|
||||
background: var(--breadcrumb-bg);
|
||||
}
|
||||
|
||||
.add-termin {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { onMounted, ref } from 'vue'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { useSchemasStore } from '../stores/schemas'
|
||||
import Icon from '../components/Icon.vue'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -19,6 +20,7 @@ const form = ref({
|
||||
end: '',
|
||||
weekly: Array(7).fill(false),
|
||||
monthly: Array(31).fill(false),
|
||||
days: [],
|
||||
})
|
||||
const submitting = ref(false)
|
||||
const error = ref(null)
|
||||
@@ -37,6 +39,7 @@ function detectRepeatType(schema) {
|
||||
if (schema.repeat['2week']) return '2week'
|
||||
if (schema.repeat['4week']) return '4week'
|
||||
if (schema.repeat.monthly) return 'monthly'
|
||||
if (schema.repeat.days) return 'days'
|
||||
return 'none'
|
||||
}
|
||||
|
||||
@@ -55,6 +58,7 @@ function loadFromSchema(schema) {
|
||||
: schema.repeat?.['4week'] ? [...schema.repeat['4week']]
|
||||
: Array(7).fill(false),
|
||||
monthly: schema.repeat?.monthly ? [...schema.repeat.monthly] : Array(31).fill(false),
|
||||
days: schema.repeat?.days ? [...schema.repeat.days] : [],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,6 +85,8 @@ function buildPayload() {
|
||||
data.repeat = { '4week': [...form.value.weekly] }
|
||||
} else if (form.value.repeatType === 'monthly') {
|
||||
data.repeat = { monthly: [...form.value.monthly] }
|
||||
} else if (form.value.repeatType === 'days') {
|
||||
data.repeat = { days: form.value.days.filter(d => d) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,11 +116,6 @@ async function onUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
if (original.value) {
|
||||
form.value = loadFromSchema(original.value)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -151,6 +152,7 @@ function onReset() {
|
||||
<option value="2week">2-Wöchentlich</option>
|
||||
<option value="4week">4-Wöchentlich</option>
|
||||
<option value="monthly">Monatlich</option>
|
||||
<option value="days">Mehrere Tage</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
@@ -179,7 +181,18 @@ function onReset() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="form.repeatType !== 'none'" class="field-row">
|
||||
<div v-if="form.repeatType === 'days'" class="field">
|
||||
<label>Termine</label>
|
||||
<div v-for="(d, i) in form.days" :key="i" class="days-row">
|
||||
<input type="date" v-model="form.days[i]" />
|
||||
<button type="button" class="icon-btn" @click="form.days.splice(i, 1)" title="Entfernen">
|
||||
<Icon name="trash" />
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="add-termin" @click="form.days.push('')">+ Termin</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!['none', 'days'].includes(form.repeatType)" class="field-row">
|
||||
<div class="field">
|
||||
<label for="start">Start</label>
|
||||
<input id="start" v-model="form.start" type="date" />
|
||||
@@ -194,7 +207,6 @@ function onReset() {
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" :disabled="submitting || !form.name">Aktualisieren</button>
|
||||
<button type="button" @click="onReset">Zurücksetzen</button>
|
||||
<button type="button" @click="router.back()">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
@@ -303,6 +315,35 @@ button:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.days-row {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.days-row input {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.icon-btn {
|
||||
width: 2.5rem;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 0.375rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.icon-btn:hover {
|
||||
background: var(--breadcrumb-bg);
|
||||
}
|
||||
|
||||
.add-termin {
|
||||
align-self: flex-start;
|
||||
}
|
||||
|
||||
.error {
|
||||
color: #dc2626;
|
||||
}
|
||||
|
||||
@@ -54,12 +54,6 @@ async function onUpdate() {
|
||||
}
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
if (original.value) {
|
||||
form.value = loadFromTask(original.value)
|
||||
}
|
||||
}
|
||||
|
||||
function onAbort() {
|
||||
router.back()
|
||||
}
|
||||
@@ -90,7 +84,6 @@ function onAbort() {
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" :disabled="submitting">Aktualisieren</button>
|
||||
<button type="button" @click="onReset">Zurücksetzen</button>
|
||||
<button type="button" @click="onAbort">Abbrechen</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user