resolve serveral type errors

This commit is contained in:
Hayden 2023-02-17 21:34:02 -09:00
parent 3ba2858b04
commit 9d3295c167
No known key found for this signature in database
GPG key ID: 17CF79474E257545
10 changed files with 389 additions and 303 deletions

View file

@ -28,7 +28,7 @@
<li v-for="(obj, idx) in filtered" :key="idx"> <li v-for="(obj, idx) in filtered" :key="idx">
<div type="button" @click="select(obj)"> <div type="button" @click="select(obj)">
<slot name="display" v-bind="{ item: obj }"> <slot name="display" v-bind="{ item: obj }">
{{ usingObjects ? obj[itemText] : obj }} {{ extractor(obj, itemText) }}
</slot> </slot>
</div> </div>
</li> </li>
@ -94,6 +94,14 @@
} }
); );
function extractor(obj: string | ItemsObject, key: string | number): string {
if (typeof obj === "string") {
return obj;
}
return obj[key] as string;
}
const value = useVModel(props, "modelValue", emit); const value = useVModel(props, "modelValue", emit);
const usingObjects = computed(() => { const usingObjects = computed(() => {
@ -135,6 +143,7 @@
value.value = ""; value.value = "";
return; return;
} }
// @ts-ignore
value.value = obj; value.value = obj;
} else { } else {
if (obj === value.value) { if (obj === value.value) {
@ -142,6 +151,7 @@
return; return;
} }
// @ts-ignore
value.value = obj; value.value = obj;
} }
} }

View file

@ -36,7 +36,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ItemCreate, LocationOut } from "~~/lib/api/types/data-contracts"; import { ItemCreate, LabelOut, LocationOut } from "~~/lib/api/types/data-contracts";
import { useLabelStore } from "~~/stores/labels"; import { useLabelStore } from "~~/stores/labels";
import { useLocationStore } from "~~/stores/locations"; import { useLocationStore } from "~~/stores/locations";
@ -82,7 +82,7 @@
name: "", name: "",
description: "", description: "",
color: "", // Future! color: "", // Future!
labels: [], labels: [] as LabelOut[],
}); });
whenever( whenever(
@ -91,7 +91,10 @@
focused.value = true; focused.value = true;
if (locationId.value) { if (locationId.value) {
form.location = locations.value.find(l => l.id === locationId.value); const found = locations.value.find(l => l.id === locationId.value);
if (found) {
form.location = found;
}
} }
if (labelId.value) { if (labelId.value) {
@ -106,7 +109,7 @@
} }
const out: ItemCreate = { const out: ItemCreate = {
parentId: undefined, parentId: null,
name: form.name, name: form.name,
description: form.description, description: form.description,
locationId: form.location.id as string, locationId: form.location.id as string,

View file

@ -18,7 +18,7 @@
const emit = defineEmits(["update:modelValue", "drop"]); const emit = defineEmits(["update:modelValue", "drop"]);
const el = ref<HTMLDivElement>(null); const el = ref<HTMLDivElement>();
const { isOverDropZone } = useDropZone(el, files => { const { isOverDropZone } = useDropZone(el, files => {
emit("drop", files); emit("drop", files);
}); });

View file

@ -16,6 +16,8 @@
"devDependencies": { "devDependencies": {
"@faker-js/faker": "^7.5.0", "@faker-js/faker": "^7.5.0",
"@nuxtjs/eslint-config-typescript": "^12.0.0", "@nuxtjs/eslint-config-typescript": "^12.0.0",
"@types/dompurify": "^2.4.0",
"@types/markdown-it": "^12.2.3",
"@typescript-eslint/eslint-plugin": "^5.36.2", "@typescript-eslint/eslint-plugin": "^5.36.2",
"@typescript-eslint/parser": "^5.36.2", "@typescript-eslint/parser": "^5.36.2",
"eslint": "^8.23.0", "eslint": "^8.23.0",
@ -47,7 +49,7 @@
"pinia": "^2.0.21", "pinia": "^2.0.21",
"postcss": "^8.4.16", "postcss": "^8.4.16",
"tailwindcss": "^3.1.8", "tailwindcss": "^3.1.8",
"vue": "^3.2.38", "vue": "^3.2.45",
"vue-chartjs": "^4.1.2", "vue-chartjs": "^4.1.2",
"vue-router": "4" "vue-router": "4"
} }

View file

@ -101,6 +101,7 @@
toast.success("Logged in successfully"); toast.success("Logged in successfully");
// @ts-ignore
authStore.$patch({ authStore.$patch({
token: data.token, token: data.token,
expires: data.expiresAt, expires: data.expiresAt,

View file

@ -408,7 +408,7 @@
<template #description> <template #description>
<Markdown :source="item.description"> </Markdown> <Markdown :source="item.description"> </Markdown>
<div class="flex flex-wrap gap-2 mt-3"> <div class="flex flex-wrap gap-2 mt-3">
<NuxtLink ref="badge" class="badge p-3" :to="`/location/${item.location.id}`"> <NuxtLink v-if="item.location" ref="badge" class="badge p-3" :to="`/location/${item.location.id}`">
<Icon name="heroicons-map-pin" class="mr-2 swap-on"></Icon> <Icon name="heroicons-map-pin" class="mr-2 swap-on"></Icon>
{{ item.location.name }} {{ item.location.name }}
</NuxtLink> </NuxtLink>

View file

@ -392,7 +392,7 @@
:items="allFields ?? []" :items="allFields ?? []"
@change="fetchValues(f[0])" @change="fetchValues(f[0])"
> >
<option v-for="fv in allFields" :key="fv" :value="fv">{{ fv }}</option> <option v-for="(fv, _, i) in allFields" :key="i" :value="fv">{{ fv }}</option>
</select> </select>
</div> </div>
<div class="form-control w-full max-w-xs"> <div class="form-control w-full max-w-xs">

View file

@ -28,7 +28,7 @@
{ {
name: "Name", name: "Name",
text: label.value?.name, text: label.value?.name,
}, } as AnyDetail,
{ {
name: "Description", name: "Description",
type: "markdown", type: "markdown",
@ -43,16 +43,16 @@
name: "Created", name: "Created",
text: label.value?.createdAt, text: label.value?.createdAt,
type: "date", type: "date",
}, } as AnyDetail,
{ {
name: "Updated", name: "Updated",
text: label.value?.updatedAt, text: label.value?.updatedAt,
type: "date", type: "date",
}, } as AnyDetail,
{ {
name: "Database ID", name: "Database ID",
text: label.value?.id, text: label.value?.id,
}, } as AnyDetail,
]; ];
} }

View file

@ -102,8 +102,8 @@
const confirm = useConfirm(); const confirm = useConfirm();
const notify = useNotifier(); const notify = useNotifier();
async function getBillOfMaterials() { function getBillOfMaterials() {
await api.reports.billOfMaterials(); api.reports.billOfMaterialsURL();
} }
async function ensureAssetIDs() { async function ensureAssetIDs() {

646
frontend/pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff