@@ -27,13 +27,11 @@
v-for="h in headers"
:key="h.value"
class="text-no-transform bg-secondary text-sm text-secondary-foreground hover:bg-secondary/90"
- @click="sortBy(h.value)"
>
@@ -50,11 +48,10 @@
:key="index"
class='cursor-pointer'
:class="{ selected: selectedRow === index }"
- @click="selectProduct(index, p)">
+ @click="selectProduct(index)">
@@ -76,11 +73,9 @@
-
+
+
+
@@ -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)
{