update location/labels

This commit is contained in:
Hayden 2023-06-02 18:08:06 -08:00
parent 77101121be
commit 2b8373f636
No known key found for this signature in database
GPG key ID: 17CF79474E257545
3 changed files with 36 additions and 64 deletions

View file

@ -56,6 +56,7 @@
<template v-else>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
<ItemCard v-for="item in items" :key="item.id" :item="item" />
<div class="first:block hidden text-lg">No Items to Display</div>
</div>
</template>
</section>

View file

@ -123,40 +123,50 @@
</form>
</BaseModal>
<BaseCard class="mb-16">
<template #title>
<BaseSectionHeader>
<Icon name="mdi-tag" class="mr-2 -mt-1 text-base-content" />
<BaseContainer v-if="label" class="space-y-6 mb-16">
<section>
<BaseSectionHeader v-if="label">
<Icon name="mdi-package-variant" class="mr-2 -mt-1 text-base-content" />
<span class="text-base-content">
{{ label ? label.name : "" }}
</span>
</BaseSectionHeader>
</template>
<template #title-actions>
<div class="flex flex-wrap mt-2 gap-2">
<div class="form-control max-w-[160px]">
<label class="label cursor-pointer">
<input v-model="preferences.showDetails" type="checkbox" class="toggle toggle-primary" />
<span class="label-text ml-2"> Detailed View </span>
</label>
<template #description>
<Markdown class="text-lg" :source="label.description"> </Markdown>
</template>
</BaseSectionHeader>
<div class="flex gap-3 flex-wrap mb-6 text-sm italic">
<div>
Created
<DateTime :date="label?.createdAt" />
</div>
<BaseButton class="ml-auto" size="sm" @click="openUpdate">
<Icon class="mr-1" name="mdi-pencil" />
Edit
</BaseButton>
<BaseButton size="sm" @click="confirmDelete">
<Icon class="mr-1" name="mdi-delete" />
<div>
<Icon name="mdi-circle-small" />
</div>
<div>
Last Updated
<DateTime :date="label?.updatedAt" />
</div>
</div>
<div class="flex flex-wrap items-center justify-between mb-6 mt-3">
<div class="btn-group">
<PageQRCode class="dropdown-right" />
<BaseButton class="ml-auto" size="sm" @click="openUpdate">
<Icon class="mr-1" name="mdi-pencil" />
Edit
</BaseButton>
</div>
<BaseButton class="btn btn-sm" @click="confirmDelete()">
<Icon name="mdi-delete" class="mr-2" />
Delete
</BaseButton>
<PageQRCode />
</div>
</template>
</section>
</BaseContainer>
<DetailsSection :details="details" />
</BaseCard>
<section v-if="label && label.items && label.items.length > 0">
<section v-if="label && label.items">
<ItemViewSelectable :items="label.items" />
</section>
</BaseContainer>

View file

@ -1,5 +1,4 @@
<script setup lang="ts">
import { AnyDetail, Details } from "~~/components/global/DetailsSection/types";
import { LocationSummary, LocationUpdate } from "~~/lib/api/types/data-contracts";
import { useLocationStore } from "~~/stores/locations";
@ -11,8 +10,6 @@
const api = useUserApi();
const toast = useNotifier();
const preferences = useViewPreferences();
const locationId = computed<string>(() => route.params.id as string);
const { data: location } = useAsyncData(locationId.value, async () => {
@ -30,42 +27,6 @@
return data;
});
const details = computed<Details>(() => {
const details = [
{
name: "Name",
text: location.value?.name ?? "",
},
{
name: "Description",
type: "markdown",
text: location.value?.description ?? "",
} as AnyDetail,
];
if (preferences.value.showDetails) {
return [
...details,
{
name: "Created",
text: location.value?.createdAt,
type: "date",
} as AnyDetail,
{
name: "Updated",
text: location.value?.updatedAt,
type: "date",
} as AnyDetail,
{
name: "Database ID",
text: location.value?.id,
} as AnyDetail,
];
}
return details;
});
const confirm = useConfirm();
async function confirmDelete() {