diff --git a/frontend/components/Item/BarcodeModal.vue b/frontend/components/Item/BarcodeModal.vue index 6b75a153..4b125e92 100644 --- a/frontend/components/Item/BarcodeModal.vue +++ b/frontend/components/Item/BarcodeModal.vue @@ -6,7 +6,7 @@
- + - - + + + @@ -90,25 +85,34 @@ import type { BarcodeProduct } from "~~/lib/api/types/data-contracts"; import { useDialog } from "~/components/ui/dialog-provider"; import MdiBarcode from "~icons/mdi/barcode"; - + import type { TableData } from "~/components/Item/View/Table.types"; const { openDialog, activeDialog, closeDialog } = useDialog(); const searching = ref(false); - const barcode = ref(null); + const barcode = ref(""); const products = ref(null); const selectedRow = ref(-1); + import type { ItemSummary } from "~~/lib/api/types/data-contracts"; + + type BarcodeTableHeader = { + text: string; + value: string; + align?: "left" | "center" | "right"; + type?: "name"; + }; + const defaultHeaders = [ { text: "items.name", value: "name", - enabled: true, + align: "left", type: "name", }, - { text: "items.manufacturer", value: "manufacturer", align: "center", enabled: true }, - { text: "items.model_number", value: "modelNumber", align: "center", enabled: true }, - { text: "DB source", value: "search_engine_name", align: "center", enabled: true }, - ] satisfies TableHeaderType[]; + { text: "items.manufacturer", value: "manufacturer", align: "center"}, + { text: "items.model_number", value: "modelNumber", align: "center"}, + { text: "DB source", value: "search_engine_name", align: "center"}, + ] satisfies BarcodeTableHeader[]; // Need for later filtering const headers = defaultHeaders; @@ -134,7 +138,7 @@ } else { - barcode.value = null; + barcode.value = ""; products.value = null; } } @@ -144,9 +148,11 @@ const api = useUserApi(); async function createItem(close = true) { - var p = products.value[selectedRow.value]; - closeDialog("product-import"); - openDialog("create-item", p); + if (products !== null) + { + var p = products.value![selectedRow.value]; + openDialog("create-item", p); + } } async function retrieveProductInfo(barcode: string) { @@ -185,11 +191,11 @@ return current; } - function cell(h: TableHeaderType) { + function cell(h: BarcodeTableHeader) { return `cell-${h.value.replace(".", "_")}`; } - function selectProduct(index) { + function selectProduct(index: number) { // Unselect if already selected if(selectedRow.value == index) {