Optimise invoice data requests #56

This commit is contained in:
2025-11-18 10:27:49 +01:00
parent 387c3be93a
commit 93f7871c18
14 changed files with 308 additions and 972 deletions
@@ -19,7 +19,7 @@ import NumberInput from '../ui/number-input/NumberInput.vue';
import { GrowingTextarea } from '../ui/growing-textarea';
const props = defineProps<{
lineItems: LineItem[],
lineItems: LineItem[] | undefined,
stickyTop: number | string,
class?: HTMLAttributes['class']
}>()
@@ -29,11 +29,16 @@ const emit = defineEmits<{
}>()
const units = ref(['Stück', 'Stunden', 'Tage', 'pauschal'])
const items = ref(props.lineItems.sort(function (a, b) { return a.position - b.position })) // items only uses props.lineItems as the initial value;
const items = ref((props.lineItems ?? []).slice().sort(function (a, b) { return a.position - b.position })) // items only uses props.lineItems as the initial value;
watch(items, (newItems) => {
emit('update:lineItems', newItems)
}, { deep: true })
watch(() => props.lineItems, (newLineItems) => {
items.value = (newLineItems ?? []).slice().sort(function (a, b) { return a.position - b.position })
}, { deep: true })
const newItem = () => {
const position = items.value.length + 1
let item = newLineItem()