Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #289 Corrects the asset ID to always be correct for the descript… #351

Merged
merged 2 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading