feat: items-editor (#5)

* format readme

* update logo

* format html

* add logo to docs

* repository for document and document tokens

* add attachments type and repository

* autogenerate types via scripts

* use autogenerated types

* attachment type updates

* add insured and quantity fields for items

* implement HasID interface for entities

* implement label updates for items

* implement service update method

* WIP item update client side actions

* check err on attachment

* finish types for basic items editor

* remove unused var

* house keeping
This commit is contained in:
Hayden 2022-09-12 14:47:27 -08:00 committed by GitHub
parent fbc364dcd2
commit 95ab14b866
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
125 changed files with 15626 additions and 1791 deletions

View file

@ -17,7 +17,7 @@
v-for="(obj, idx) in items"
:key="idx"
:class="{
bordered: selectedIndexes[idx],
bordered: selected[idx],
}"
>
<button type="button" @click="toggle(idx)">
@ -37,10 +37,12 @@
default: "",
},
modelValue: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type: Array as () => any[],
default: null,
},
items: {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type: Array as () => any[],
required: true,
},
@ -54,28 +56,23 @@
},
});
const selectedIndexes = ref<Record<number, boolean>>({});
const value = useVModel(props, "modelValue", emit);
const selected = computed<Record<number, boolean>>(() => {
const obj: Record<number, boolean> = {};
value.value.forEach(itm => {
const idx = props.items.findIndex(item => item[props.name] === itm.name);
obj[idx] = true;
});
return obj;
});
function toggle(index: number) {
selectedIndexes.value[index] = !selectedIndexes.value[index];
const item = props.items[index];
if (selectedIndexes.value[index]) {
value.value = [...value.value, item];
if (selected.value[index]) {
value.value = value.value.filter(itm => itm.name !== item.name);
} else {
value.value = value.value.filter(itm => itm !== item);
value.value = [...value.value, item];
}
}
watchOnce(
() => props.items,
() => {
if (props.selectFirst && props.items.length > 0) {
value.value = props.items[0];
}
}
);
const value = useVModel(props, "modelValue", emit);
</script>