mirror of
https://github.com/sysadminsmedia/homebox.git
synced 2025-12-24 06:28:34 +01:00
This commit is contained in:
@@ -2286,6 +2286,10 @@ const docTemplate = `{
|
|||||||
"archived": {
|
"archived": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"assetId": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "0"
|
||||||
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2279,6 +2279,10 @@
|
|||||||
"archived": {
|
"archived": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"assetId": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "0"
|
||||||
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -217,6 +217,9 @@ definitions:
|
|||||||
properties:
|
properties:
|
||||||
archived:
|
archived:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
assetId:
|
||||||
|
example: "0"
|
||||||
|
type: string
|
||||||
createdAt:
|
createdAt:
|
||||||
type: string
|
type: string
|
||||||
description:
|
description:
|
||||||
|
|||||||
@@ -115,6 +115,7 @@ type (
|
|||||||
ItemSummary struct {
|
ItemSummary struct {
|
||||||
ImportRef string `json:"-"`
|
ImportRef string `json:"-"`
|
||||||
ID uuid.UUID `json:"id"`
|
ID uuid.UUID `json:"id"`
|
||||||
|
AssetID AssetID `json:"assetId,string"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Description string `json:"description"`
|
Description string `json:"description"`
|
||||||
Quantity int `json:"quantity"`
|
Quantity int `json:"quantity"`
|
||||||
@@ -190,6 +191,7 @@ func mapItemSummary(item *ent.Item) ItemSummary {
|
|||||||
|
|
||||||
return ItemSummary{
|
return ItemSummary{
|
||||||
ID: item.ID,
|
ID: item.ID,
|
||||||
|
AssetID: AssetID(item.AssetID),
|
||||||
Name: item.Name,
|
Name: item.Name,
|
||||||
Description: item.Description,
|
Description: item.Description,
|
||||||
ImportRef: item.ImportRef,
|
ImportRef: item.ImportRef,
|
||||||
@@ -422,6 +424,8 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
|||||||
qb = qb.Order(ent.Desc(item.FieldCreatedAt))
|
qb = qb.Order(ent.Desc(item.FieldCreatedAt))
|
||||||
case "updatedAt":
|
case "updatedAt":
|
||||||
qb = qb.Order(ent.Desc(item.FieldUpdatedAt))
|
qb = qb.Order(ent.Desc(item.FieldUpdatedAt))
|
||||||
|
case "assetId":
|
||||||
|
qb = qb.Order(ent.Asc(item.FieldAssetID))
|
||||||
default: // "name"
|
default: // "name"
|
||||||
qb = qb.Order(ent.Asc(item.FieldName))
|
qb = qb.Order(ent.Asc(item.FieldName))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2279,6 +2279,10 @@
|
|||||||
"archived": {
|
"archived": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
"assetId": {
|
||||||
|
"type": "string",
|
||||||
|
"example": "0"
|
||||||
|
},
|
||||||
"createdAt": {
|
"createdAt": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -134,6 +134,8 @@ export interface ItemPath {
|
|||||||
|
|
||||||
export interface ItemSummary {
|
export interface ItemSummary {
|
||||||
archived: boolean;
|
archived: boolean;
|
||||||
|
/** @example "0" */
|
||||||
|
assetId: string;
|
||||||
createdAt: Date | string;
|
createdAt: Date | string;
|
||||||
description: string;
|
description: string;
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -183,21 +183,20 @@
|
|||||||
return route(`/qrcode`, { data: encodeURIComponent(data) });
|
return route(`/qrcode`, { data: encodeURIComponent(data) });
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItem(n: number, item: { name: string; location: { name: string } } | null): LabelData {
|
function getItem(n: number, item: { assetId: string; name: string; location: { name: string } } | null): LabelData {
|
||||||
// format n into - seperated string with leading zeros
|
// format n into - seperated string with leading zeros
|
||||||
|
const assetID = fmtAssetID(n + 1);
|
||||||
const assetID = fmtAssetID(n);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
url: getQRCodeUrl(assetID),
|
url: getQRCodeUrl(assetID),
|
||||||
assetID,
|
assetID: item?.assetId ?? assetID,
|
||||||
name: item?.name ?? "_______________",
|
name: item?.name ?? "_______________",
|
||||||
location: item?.location?.name ?? "_______________",
|
location: item?.location?.name ?? "_______________",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const { data: allFields } = await useAsyncData(async () => {
|
const { data: allFields } = await useAsyncData(async () => {
|
||||||
const { data, error } = await api.items.getAll();
|
const { data, error } = await api.items.getAll({ orderBy: "assetId" });
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
return {
|
return {
|
||||||
@@ -220,10 +219,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
const items: LabelData[] = [];
|
const items: LabelData[] = [];
|
||||||
for (let i = displayProperties.assetRange; i < displayProperties.assetRangeMax; i++) {
|
for (let i = displayProperties.assetRange - 1; i < displayProperties.assetRangeMax - 1; i++) {
|
||||||
const item = allFields?.value?.items?.[i];
|
const item = allFields?.value?.items?.[i];
|
||||||
if (item?.location) {
|
if (item?.location) {
|
||||||
items.push(getItem(i, item as { location: { name: string }; name: string }));
|
items.push(getItem(i, item as { assetId: string; location: { name: string }; name: string }));
|
||||||
} else {
|
} else {
|
||||||
items.push(getItem(i, null));
|
items.push(getItem(i, null));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user