mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-28 07:56:35 +01:00
* feat: migrate tools page and label generator to shadcn * chore: lint issues * feat: also do profile page * feat: shadcn 404 page * feat: login page shadcn * fix: daisyui ironically breaks the z height for the login page * feat: componentise the language selector and add it to the login page * feat: use nuxtlink * feat: card and table made more shadcn * feat: shadcn statscard * chore: lint * feat: shadcn labelchip and locationcard * feat: shadcn locations page * refactor: remove unused new item page * chore: lint * feat: shadcn item card * fix: wrapping of location and lint * feat: ctrl enter in text area in form submits form * feat: begin shadcn locations page and remove pageqrcode comp in favour of integrating it into labelmaker * chore: lint + remove unused code * fix: remove uneeded margin * feat: shadcn labels page and fix some issues with location * feat: shadcn scanner * chore: lint * feat: begin shadcning item pages * feat: shadcn maintenance page * feat: begin shadcn search page * fix: quick switch blurry text and crashing page when switching + incorrect z height for create menu * feat: finish shadcn search page * chore: lint * feat: shadcn edit item page * fix: quickmenumodal bug * feat: shadcn item details page * feat: remove all non-color related daisyui classes * fix: type error * fix: quick menu modal again :(
72 lines
2.1 KiB
Vue
72 lines
2.1 KiB
Vue
<script setup lang="ts">
|
|
import { useTreeState } from "./tree-state";
|
|
import type { TreeItem } from "~~/lib/api/types/data-contracts";
|
|
import MdiChevronRight from "~icons/mdi/chevron-right";
|
|
import MdiMapMarker from "~icons/mdi/map-marker";
|
|
import MdiPackageVariant from "~icons/mdi/package-variant";
|
|
|
|
type Props = {
|
|
treeId: string;
|
|
item: TreeItem;
|
|
};
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
|
|
const link = computed(() => {
|
|
return props.item.type === "location" ? `/location/${props.item.id}` : `/item/${props.item.id}`;
|
|
});
|
|
|
|
const hasChildren = computed(() => {
|
|
return props.item.children.length > 0;
|
|
});
|
|
|
|
const state = useTreeState(props.treeId);
|
|
|
|
const openRef = computed({
|
|
get() {
|
|
return state.value[nodeHash.value] ?? false;
|
|
},
|
|
set(value: boolean) {
|
|
state.value[nodeHash.value] = value;
|
|
},
|
|
});
|
|
|
|
const nodeHash = computed(() => {
|
|
// converts a UUID to a short hash
|
|
return props.item.id.replace(/-/g, "").substring(0, 8);
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<div
|
|
class="flex items-center gap-1 rounded p-1"
|
|
:class="{
|
|
'cursor-pointer hover:bg-base-200': hasChildren,
|
|
}"
|
|
@click="openRef = !openRef"
|
|
>
|
|
<div
|
|
class="mr-1 flex items-center justify-center rounded p-0.5"
|
|
:class="{
|
|
'hover:bg-base-200': hasChildren,
|
|
}"
|
|
>
|
|
<div v-if="!hasChildren" class="size-6"></div>
|
|
<div v-else class="group/node relative size-6" :data-swap="openRef">
|
|
<div
|
|
class="absolute inset-0 flex items-center justify-center transition-transform duration-300 group-data-[swap=true]/node:rotate-90"
|
|
>
|
|
<MdiChevronRight class="size-6" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<MdiMapMarker v-if="item.type === 'location'" class="size-4" />
|
|
<MdiPackageVariant v-else class="size-4" />
|
|
<NuxtLink class="text-lg hover:underline" :to="link" @click.stop>{{ item.name }} </NuxtLink>
|
|
</div>
|
|
<div v-if="openRef" class="ml-4">
|
|
<LocationTreeNode v-for="child in item.children" :key="child.id" :item="child" :tree-id="treeId" />
|
|
</div>
|
|
</div>
|
|
</template>
|