Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fetch images for item children
Browse files Browse the repository at this point in the history
  • Loading branch information
hay-kot committed Nov 16, 2023
1 parent 56a27ab commit 673b81c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
8 changes: 0 additions & 8 deletions backend/internal/data/repo/repo_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ type (

Attachments []ItemAttachment `json:"attachments"`
Fields []ItemField `json:"fields"`
Children []ItemSummary `json:"children"`
}
)

Expand Down Expand Up @@ -241,11 +240,6 @@ func mapItemOut(item *ent.Item) ItemOut {
fields = mapFields(item.Edges.Fields)
}

var children []ItemSummary
if item.Edges.Children != nil {
children = mapEach(item.Edges.Children, mapItemSummary)
}

var parent *ItemSummary
if item.Edges.Parent != nil {
v := mapItemSummary(item.Edges.Parent)
Expand Down Expand Up @@ -279,7 +273,6 @@ func mapItemOut(item *ent.Item) ItemOut {
Notes: item.Notes,
Attachments: attachments,
Fields: fields,
Children: children,
}
}

Expand All @@ -297,7 +290,6 @@ func (e *ItemsRepository) getOne(ctx context.Context, where ...predicate.Item) (
WithLabel().
WithLocation().
WithGroup().
WithChildren().
WithParent().
WithAttachments(func(aq *ent.AttachmentQuery) {
aq.WithDocument()
Expand Down
1 change: 1 addition & 0 deletions frontend/lib/api/classes/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export type ItemsQuery = {
pageSize?: number;
locations?: string[];
labels?: string[];
parentIds?: string[];
q?: string;
fields?: string[];
};
Expand Down
21 changes: 19 additions & 2 deletions frontend/pages/item/[id]/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,23 @@
},
];
});
const items = computedAsync(async () => {
if (!item.value) {
return [];
}
const resp = await api.items.getAll({
parentIds: [item.value.id],
});
if (resp.error) {
toast.error("Failed to load items");
return [];
}
return resp.data.items;
});
</script>

<template>
Expand Down Expand Up @@ -565,8 +582,8 @@
</div>
</section>

<section v-if="!hasNested && item.children.length > 0" class="my-6">
<ItemViewSelectable :items="item.children" />
<section v-if="items && items.length > 0" class="my-6">
<ItemViewSelectable :items="items" />
</section>
</BaseContainer>
</template>
Expand Down

0 comments on commit 673b81c

Please sign in to comment.