mirror of
https://github.com/hay-kot/homebox.git
synced 2024-12-18 13:06:32 +00:00
feat: order labels and locations by name (#86)
* order labels and locations by name * sort items
This commit is contained in:
parent
72bdf524c2
commit
bb86a51b05
3 changed files with 7 additions and 2 deletions
|
@ -24,6 +24,7 @@ type (
|
||||||
Search string `json:"search"`
|
Search string `json:"search"`
|
||||||
LocationIDs []uuid.UUID `json:"locationIds"`
|
LocationIDs []uuid.UUID `json:"locationIds"`
|
||||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||||
|
SortBy string `json:"sortBy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemCreate struct {
|
ItemCreate struct {
|
||||||
|
@ -252,7 +253,8 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
||||||
}
|
}
|
||||||
|
|
||||||
items, err := mapItemsSummaryErr(
|
items, err := mapItemsSummaryErr(
|
||||||
qb.WithLabel().
|
qb.Order(ent.Asc(item.FieldName)).
|
||||||
|
WithLabel().
|
||||||
WithLocation().
|
WithLocation().
|
||||||
All(ctx),
|
All(ctx),
|
||||||
)
|
)
|
||||||
|
|
|
@ -84,6 +84,7 @@ func (r *LabelRepository) GetOneByGroup(ctx context.Context, gid, ld uuid.UUID)
|
||||||
func (r *LabelRepository) GetAll(ctx context.Context, groupId uuid.UUID) ([]LabelSummary, error) {
|
func (r *LabelRepository) GetAll(ctx context.Context, groupId uuid.UUID) ([]LabelSummary, error) {
|
||||||
return mapLabelsOut(r.db.Label.Query().
|
return mapLabelsOut(r.db.Label.Query().
|
||||||
Where(label.HasGroupWith(group.ID(groupId))).
|
Where(label.HasGroupWith(group.ID(groupId))).
|
||||||
|
Order(ent.Asc(label.FieldName)).
|
||||||
WithGroup().
|
WithGroup().
|
||||||
All(ctx),
|
All(ctx),
|
||||||
)
|
)
|
||||||
|
|
|
@ -94,7 +94,9 @@ func (r *LocationRepository) GetAll(ctx context.Context, groupId uuid.UUID) ([]L
|
||||||
locations
|
locations
|
||||||
WHERE
|
WHERE
|
||||||
locations.group_locations = ?
|
locations.group_locations = ?
|
||||||
`
|
ORDER BY
|
||||||
|
locations.name ASC
|
||||||
|
`
|
||||||
|
|
||||||
rows, err := r.db.Sql().QueryContext(ctx, query, groupId)
|
rows, err := r.db.Sql().QueryContext(ctx, query, groupId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue