Skip to content

Commit

Permalink
fix: #289 Corrects the asset ID to always be correct for the descript…
Browse files Browse the repository at this point in the history
…ion data. (#351)
  • Loading branch information
tankerkiller125 authored Nov 29, 2024
1 parent 19ccfee commit 5e81e60
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 7 deletions.
4 changes: 4 additions & 0 deletions backend/app/api/static/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2286,6 +2286,10 @@ const docTemplate = `{
"archived": {
"type": "boolean"
},
"assetId": {
"type": "string",
"example": "0"
},
"createdAt": {
"type": "string"
},
Expand Down
4 changes: 4 additions & 0 deletions backend/app/api/static/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@
"archived": {
"type": "boolean"
},
"assetId": {
"type": "string",
"example": "0"
},
"createdAt": {
"type": "string"
},
Expand Down
3 changes: 3 additions & 0 deletions backend/app/api/static/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ definitions:
properties:
archived:
type: boolean
assetId:
example: "0"
type: string
createdAt:
type: string
description:
Expand Down
4 changes: 4 additions & 0 deletions backend/internal/data/repo/repo_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type (
ItemSummary struct {
ImportRef string `json:"-"`
ID uuid.UUID `json:"id"`
AssetID AssetID `json:"assetId,string"`
Name string `json:"name"`
Description string `json:"description"`
Quantity int `json:"quantity"`
Expand Down Expand Up @@ -190,6 +191,7 @@ func mapItemSummary(item *ent.Item) ItemSummary {

return ItemSummary{
ID: item.ID,
AssetID: AssetID(item.AssetID),
Name: item.Name,
Description: item.Description,
ImportRef: item.ImportRef,
Expand Down Expand Up @@ -422,6 +424,8 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
qb = qb.Order(ent.Desc(item.FieldCreatedAt))
case "updatedAt":
qb = qb.Order(ent.Desc(item.FieldUpdatedAt))
case "assetId":
qb = qb.Order(ent.Asc(item.FieldAssetID))
default: // "name"
qb = qb.Order(ent.Asc(item.FieldName))
}
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/api/openapi-2.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -2279,6 +2279,10 @@
"archived": {
"type": "boolean"
},
"assetId": {
"type": "string",
"example": "0"
},
"createdAt": {
"type": "string"
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/lib/api/types/data-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export interface ItemPath {

export interface ItemSummary {
archived: boolean;
/** @example "0" */
assetId: string;
createdAt: Date | string;
description: string;
id: string;
Expand Down
13 changes: 6 additions & 7 deletions frontend/pages/reports/label-generator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,21 +183,20 @@
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
const assetID = fmtAssetID(n);
const assetID = fmtAssetID(n + 1);
return {
url: getQRCodeUrl(assetID),
assetID,
assetID: item?.assetId ?? assetID,
name: item?.name ?? "_______________",
location: item?.location?.name ?? "_______________",
};
}
const { data: allFields } = await useAsyncData(async () => {
const { data, error } = await api.items.getAll();
const { data, error } = await api.items.getAll({ orderBy: "assetId" });
if (error) {
return {
Expand All @@ -220,10 +219,10 @@
}
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];
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 {
items.push(getItem(i, null));
}
Expand Down

0 comments on commit 5e81e60

Please sign in to comment.