Skip to content

Commit

Permalink
fix: other minor fixes (#388)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
hay-kot committed Apr 2, 2023
1 parent ced5aef commit 4dd925c
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 20 deletions.
1 change: 1 addition & 0 deletions backend/app/api/handlers/v1/v1_ctrl_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, "#") {
Expand Down
28 changes: 20 additions & 8 deletions backend/internal/data/repo/repo_items.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
),
)
}
Expand Down Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions frontend/components/Base/Card.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
</div>
<div
:class="{
'max-h-[99999px]': !collapsed,
'max-h-0': collapsed,
'max-h-[9000px]': collapsable && !collapsed,
'max-h-0 overflow-hidden': collapsed,
}"
class="transition-[max-height] duration-200 overflow-hidden"
class="transition-[max-height] duration-200"
>
<slot />
</div>
Expand Down
6 changes: 5 additions & 1 deletion frontend/components/Item/View/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
};
const props = defineProps<Props>();
const sortByProperty = ref<keyof ItemSummary>("name");
const sortByProperty = ref<keyof ItemSummary | "">("");
const headers = computed<TableHeader[]>(() => {
return [
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions frontend/layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
<AppHeaderDecor class="-mt-10 hidden lg:block" />
<!-- Button -->
<div class="navbar z-[99] lg:hidden top-0 fixed bg-primary shadow-md drawer-button">
<label for="my-drawer-2" class="btn btn-square btn-ghost text-base-100 drawer-button lg:hidden">
<Icon name="mdi-menu" class="h-6 w-6" />
</label>
<NuxtLink to="/home">
<h2 class="mt-1 ml-1 text-3xl font-bold tracking-tight text-base-100 flex">
<h2 class="text-3xl font-bold tracking-tight text-base-100 flex">
HomeB
<AppLogo class="w-8 -mb-3" />
x
</h2>
</NuxtLink>
<label for="my-drawer-2" class="btn btn-square btn-ghost ml-auto text-base-100 drawer-button lg:hidden">
<Icon name="mdi-menu" class="h-6 w-6" />
</label>
</div>

<slot></slot>
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 @@ -15,6 +15,7 @@ import { AttachmentTypes, PaginationResult } from "../types/non-generated";
import { Requests } from "~~/lib/requests";

export type ItemsQuery = {
orderBy?: string;
includeArchived?: boolean;
page?: number;
pageSize?: number;
Expand Down
1 change: 1 addition & 0 deletions frontend/pages/home/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function itemsTable(api: UserClient) {
const { data } = await api.items.getAll({
page: 1,
pageSize: 5,
orderBy: "createdAt",
});
return data.items;
});
Expand Down
7 changes: 3 additions & 4 deletions frontend/pages/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -473,11 +473,10 @@
<span class="text-base-600"> Delete Account</span>
<template #description> Delete your account and all it's associated data </template>
</BaseSectionHeader>

<div class="py-4 border-t-2 border-gray-300">
<BaseButton size="sm" class="btn-error" @click="deleteProfile"> Delete Account </BaseButton>
</div>
</template>
<div class="p-4 px-6 border-t-2 border-gray-300">
<BaseButton size="sm" class="btn-error" @click="deleteProfile"> Delete Account </BaseButton>
</div>
</BaseCard>
</BaseContainer>
<footer v-if="status" class="text-center w-full bottom-0 pb-4">
Expand Down

0 comments on commit 4dd925c

Please sign in to comment.