feat: primary images (#576)

* add support for primary images

* fix locked loading state issue

* add action to auto-set images

Former-commit-id: 318b8be192
This commit is contained in:
Hayden 2023-10-06 21:51:08 -05:00 committed by GitHub
parent ce16b37b97
commit b20c88e256
34 changed files with 649 additions and 207 deletions

View file

@ -9,7 +9,6 @@ import (
"github.com/hay-kot/homebox/backend/internal/core/services/reporting/eventbus"
"github.com/hay-kot/homebox/backend/internal/data/ent"
"github.com/hay-kot/homebox/backend/internal/data/ent/group"
"github.com/hay-kot/homebox/backend/internal/data/ent/item"
"github.com/hay-kot/homebox/backend/internal/data/ent/location"
"github.com/hay-kot/homebox/backend/internal/data/ent/predicate"
)
@ -49,7 +48,6 @@ type (
LocationOut struct {
Parent *LocationSummary `json:"parent,omitempty"`
LocationSummary
Items []ItemSummary `json:"items"`
Children []LocationSummary `json:"children"`
}
)
@ -88,7 +86,6 @@ func mapLocationOut(location *ent.Location) LocationOut {
CreatedAt: location.CreatedAt,
UpdatedAt: location.UpdatedAt,
},
Items: mapEach(location.Edges.Items, mapItemSummary),
}
}
@ -164,11 +161,6 @@ func (r *LocationRepository) getOne(ctx context.Context, where ...predicate.Loca
return mapLocationOutErr(r.db.Location.Query().
Where(where...).
WithGroup().
WithItems(func(iq *ent.ItemQuery) {
iq.Where(item.Archived(false)).
Order(ent.Asc(item.FieldName)).
WithLabel()
}).
WithParent().
WithChildren().
Only(ctx))