From 4dd925caf05909ecb80a59724d79ab59e5eb0c84 Mon Sep 17 00:00:00 2001 From: Hayden <64056131+hay-kot@users.noreply.github.com> Date: Sat, 1 Apr 2023 22:01:21 -0800 Subject: [PATCH] fix: other minor fixes (#388) * remove overflow-hidden on when no collapsed * fix recently added on homescreen * fix delete account formatting * add manufacturer to search * move nav button to left --- backend/app/api/handlers/v1/v1_ctrl_items.go | 1 + backend/internal/data/repo/repo_items.go | 28 ++++++++++++++------ frontend/components/Base/Card.vue | 6 ++--- frontend/components/Item/View/Table.vue | 6 ++++- frontend/layouts/default.vue | 8 +++--- frontend/lib/api/classes/items.ts | 1 + frontend/pages/home/table.ts | 1 + frontend/pages/profile.vue | 7 +++-- 8 files changed, 38 insertions(+), 20 deletions(-) diff --git a/backend/app/api/handlers/v1/v1_ctrl_items.go b/backend/app/api/handlers/v1/v1_ctrl_items.go index 062fbad..7e7600c 100644 --- a/backend/app/api/handlers/v1/v1_ctrl_items.go +++ b/backend/app/api/handlers/v1/v1_ctrl_items.go @@ -58,6 +58,7 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc { LabelIDs: queryUUIDList(params, "labels"), IncludeArchived: queryBool(params.Get("includeArchived")), Fields: filterFieldItems(params["fields"]), + OrderBy: params.Get("orderBy"), } if strings.HasPrefix(v.Search, "#") { diff --git a/backend/internal/data/repo/repo_items.go b/backend/internal/data/repo/repo_items.go index 103c3e9..3e263cc 100644 --- a/backend/internal/data/repo/repo_items.go +++ b/backend/internal/data/repo/repo_items.go @@ -29,13 +29,14 @@ type ( ItemQuery struct { Page int PageSize int - Search string `json:"search"` - AssetID AssetID `json:"assetId"` - LocationIDs []uuid.UUID `json:"locationIds"` - LabelIDs []uuid.UUID `json:"labelIds"` - SortBy string `json:"sortBy"` - IncludeArchived bool `json:"includeArchived"` - Fields []FieldQuery + Search string `json:"search"` + AssetID AssetID `json:"assetId"` + LocationIDs []uuid.UUID `json:"locationIds"` + LabelIDs []uuid.UUID `json:"labelIds"` + SortBy string `json:"sortBy"` + IncludeArchived bool `json:"includeArchived"` + Fields []FieldQuery `json:"fields"` + OrderBy string `json:"orderBy"` } ItemField struct { @@ -326,6 +327,7 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite item.NameContainsFold(q.Search), item.DescriptionContainsFold(q.Search), item.NotesContainsFold(q.Search), + item.ManufacturerContainsFold(q.Search), ), ) } @@ -385,7 +387,17 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite return PaginationResult[ItemSummary]{}, err } - qb = qb.Order(ent.Asc(item.FieldName)). + // Order + switch q.OrderBy { + case "createdAt": + qb = qb.Order(ent.Desc(item.FieldCreatedAt)) + case "updatedAt": + qb = qb.Order(ent.Desc(item.FieldUpdatedAt)) + default: // "name" + qb = qb.Order(ent.Asc(item.FieldName)) + } + + qb = qb. WithLabel(). WithLocation() diff --git a/frontend/components/Base/Card.vue b/frontend/components/Base/Card.vue index 512748c..d89c1c0 100644 --- a/frontend/components/Base/Card.vue +++ b/frontend/components/Base/Card.vue @@ -23,10 +23,10 @@
diff --git a/frontend/components/Item/View/Table.vue b/frontend/components/Item/View/Table.vue index b9b7196..f6c3cf1 100644 --- a/frontend/components/Item/View/Table.vue +++ b/frontend/components/Item/View/Table.vue @@ -79,7 +79,7 @@ }; const props = defineProps(); - const sortByProperty = ref("name"); + const sortByProperty = ref(""); const headers = computed(() => { return [ @@ -136,6 +136,10 @@ } function itemSort(a: ItemSummary, b: ItemSummary) { + if (!sortByProperty.value) { + return 0; + } + const aLower = extractSortable(a, sortByProperty.value); const bLower = extractSortable(b, sortByProperty.value); diff --git a/frontend/layouts/default.vue b/frontend/layouts/default.vue index 393b4ee..8941b28 100644 --- a/frontend/layouts/default.vue +++ b/frontend/layouts/default.vue @@ -16,16 +16,16 @@