forked from mirrors/homebox
feat: locations tree viewer (#248)
* location tree API * test fixes * initial tree location elements * locations tree page * update meta-data * code-gen * store item display preferences * introduce basic table/card view elements * codegen * set parent location during location creation * add item support for tree query * refactor tree view * wip: location selector improvements * type gen * rename items -> search * remove various log statements * fix markdown rendering for description * update location selectors * fix tests * fix currency tests * formatting
This commit is contained in:
parent
4d220cdd9c
commit
3d295b5132
33 changed files with 1119 additions and 79 deletions
49
frontend/components/Location/Selector.vue
Normal file
49
frontend/components/Location/Selector.vue
Normal file
|
@ -0,0 +1,49 @@
|
|||
<template>
|
||||
<FormAutocomplete
|
||||
v-model="value"
|
||||
v-model:search="form.search"
|
||||
:items="locations"
|
||||
item-text="display"
|
||||
item-value="id"
|
||||
item-search="name"
|
||||
label="Parent Location"
|
||||
>
|
||||
<template #display="{ item }">
|
||||
<div>
|
||||
<div>
|
||||
{{ item.name }}
|
||||
</div>
|
||||
<div v-if="item.name != item.display" class="text-xs mt-1">{{ item.display }}</div>
|
||||
</div>
|
||||
</template>
|
||||
</FormAutocomplete>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { LocationSummary } from "~~/lib/api/types/data-contracts";
|
||||
|
||||
type Props = {
|
||||
modelValue?: LocationSummary | null;
|
||||
};
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const value = useVModel(props, "modelValue");
|
||||
|
||||
const locations = await useFlatLocations();
|
||||
|
||||
const form = ref({
|
||||
parent: null as LocationSummary | null,
|
||||
search: "",
|
||||
});
|
||||
|
||||
// Whenever parent goes from value to null reset search
|
||||
watch(
|
||||
() => value.value,
|
||||
() => {
|
||||
if (!value.value) {
|
||||
form.value.search = "";
|
||||
}
|
||||
}
|
||||
);
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue