Skip to content

A continuation of HomeBox the inventory and organization system built for the Home User

label generation tool prefills already allocated items

zak4e9647651c56
diff --git a/frontend/pages/reports/label-generator.vue b/frontend/pages/reports/label-generator.vue
index e7281bf4..c010a28c 100644
--- a/frontend/pages/reports/label-generator.vue
+++ b/frontend/pages/reports/label-generator.vue
@@ -181,7 +181,7 @@
return route(`/qrcode`, { data: encodeURIComponent(data) });
}
- function getItem(n: number): LabelData {
+ function getItem(n: number, item: { value: { name: string, location: string } } | null): LabelData {
// format n into - seperated string with leading zeros
const assetID = fmtAssetID(n);
@@ -189,11 +189,21 @@
return {
url: getQRCodeUrl(assetID),
assetID,
- name: "_______________",
- location: "_______________",
+ name: item?.value?.name ?? "_______________",
+ location: item?.value?.location ?? "_______________",
};
}
+ const { data: allFields } = useAsyncData(async () => {
+ const { data, error } = await api.items.fields.getAll();
+
+ if (error) {
+ return [];
+ }
+
+ return data;
+ });
+
const items = computed(() => {
if (displayProperties.assetRange > displayProperties.assetRangeMax) {
return [];
@@ -207,7 +217,7 @@
const items: LabelData[] = [];
for (let i = displayProperties.assetRange; i < displayProperties.assetRangeMax; i++) {
- items.push(getItem(i));
+ items.push(getItem(i, allFields[i] ?? null));
}
return items;
});