mirror of
https://github.com/hay-kot/homebox.git
synced 2025-05-29 08:32:31 +00:00
feat: new-card-design (#196)
* card option 1 * UI updates for item card * fix test error * fix pagination issues on backend * add integer support * remove date from cards * implement pagination for search page * resolve search state problems * other fixes * fix broken datetime * attempt to fix scroll behavior
This commit is contained in:
parent
58d6f9a28c
commit
891d41b75f
19 changed files with 393 additions and 142 deletions
|
@ -326,23 +326,23 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
|||
)
|
||||
}
|
||||
|
||||
count, err := qb.Count(ctx)
|
||||
if err != nil {
|
||||
return PaginationResult[ItemSummary]{}, err
|
||||
}
|
||||
|
||||
qb = qb.Order(ent.Asc(item.FieldName)).
|
||||
WithLabel().
|
||||
WithLocation()
|
||||
|
||||
if q.Page != -1 || q.PageSize != -1 {
|
||||
qb = qb.
|
||||
Offset(calculateOffset(q.Page, q.PageSize)).
|
||||
Limit(q.PageSize)
|
||||
}
|
||||
|
||||
items, err := mapItemsSummaryErr(
|
||||
qb.Order(ent.Asc(item.FieldName)).
|
||||
WithLabel().
|
||||
WithLocation().
|
||||
All(ctx),
|
||||
)
|
||||
if err != nil {
|
||||
return PaginationResult[ItemSummary]{}, err
|
||||
}
|
||||
items, err := mapItemsSummaryErr(qb.All(ctx))
|
||||
|
||||
count, err := qb.Count(ctx)
|
||||
if err != nil {
|
||||
return PaginationResult[ItemSummary]{}, err
|
||||
}
|
||||
|
|
|
@ -8,14 +8,35 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
// get the previous month from the current month, accounts for errors when run
|
||||
// near the beginning or end of the month/year
|
||||
func getPrevMonth(now time.Time) time.Time {
|
||||
t := now.AddDate(0, -1, 0)
|
||||
|
||||
// avoid infinite loop
|
||||
max := 15
|
||||
for t.Month() == now.Month() {
|
||||
println("month is the same")
|
||||
t = t.AddDate(0, 0, -1)
|
||||
println(t.String())
|
||||
|
||||
max--
|
||||
if max == 0 {
|
||||
panic("max exceeded")
|
||||
}
|
||||
}
|
||||
|
||||
return t
|
||||
}
|
||||
|
||||
func TestMaintenanceEntryRepository_GetLog(t *testing.T) {
|
||||
item := useItems(t, 1)[0]
|
||||
|
||||
// Create 10 maintenance entries for the item
|
||||
created := make([]MaintenanceEntryCreate, 10)
|
||||
|
||||
lastMonth := time.Now().AddDate(0, -1, 0)
|
||||
thisMonth := time.Now()
|
||||
lastMonth := getPrevMonth(thisMonth)
|
||||
|
||||
for i := 0; i < 10; i++ {
|
||||
dt := lastMonth
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue