mirror of
https://github.com/hay-kot/homebox.git
synced 2025-08-04 00:30:27 +00:00
fix recently added on homescreen
This commit is contained in:
parent
84bdb8c9a5
commit
38095c1889
5 changed files with 27 additions and 9 deletions
|
@ -58,6 +58,7 @@ func (ctrl *V1Controller) HandleItemsGetAll() errchain.HandlerFunc {
|
||||||
LabelIDs: queryUUIDList(params, "labels"),
|
LabelIDs: queryUUIDList(params, "labels"),
|
||||||
IncludeArchived: queryBool(params.Get("includeArchived")),
|
IncludeArchived: queryBool(params.Get("includeArchived")),
|
||||||
Fields: filterFieldItems(params["fields"]),
|
Fields: filterFieldItems(params["fields"]),
|
||||||
|
OrderBy: params.Get("orderBy"),
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasPrefix(v.Search, "#") {
|
if strings.HasPrefix(v.Search, "#") {
|
||||||
|
|
|
@ -29,13 +29,14 @@ type (
|
||||||
ItemQuery struct {
|
ItemQuery struct {
|
||||||
Page int
|
Page int
|
||||||
PageSize int
|
PageSize int
|
||||||
Search string `json:"search"`
|
Search string `json:"search"`
|
||||||
AssetID AssetID `json:"assetId"`
|
AssetID AssetID `json:"assetId"`
|
||||||
LocationIDs []uuid.UUID `json:"locationIds"`
|
LocationIDs []uuid.UUID `json:"locationIds"`
|
||||||
LabelIDs []uuid.UUID `json:"labelIds"`
|
LabelIDs []uuid.UUID `json:"labelIds"`
|
||||||
SortBy string `json:"sortBy"`
|
SortBy string `json:"sortBy"`
|
||||||
IncludeArchived bool `json:"includeArchived"`
|
IncludeArchived bool `json:"includeArchived"`
|
||||||
Fields []FieldQuery
|
Fields []FieldQuery `json:"fields"`
|
||||||
|
OrderBy string `json:"orderBy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemField struct {
|
ItemField struct {
|
||||||
|
@ -385,7 +386,17 @@ func (e *ItemsRepository) QueryByGroup(ctx context.Context, gid uuid.UUID, q Ite
|
||||||
return PaginationResult[ItemSummary]{}, err
|
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().
|
WithLabel().
|
||||||
WithLocation()
|
WithLocation()
|
||||||
|
|
||||||
|
|
|
@ -79,7 +79,7 @@
|
||||||
};
|
};
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
const sortByProperty = ref<keyof ItemSummary>("name");
|
const sortByProperty = ref<keyof ItemSummary | "">("");
|
||||||
|
|
||||||
const headers = computed<TableHeader[]>(() => {
|
const headers = computed<TableHeader[]>(() => {
|
||||||
return [
|
return [
|
||||||
|
@ -136,6 +136,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function itemSort(a: ItemSummary, b: ItemSummary) {
|
function itemSort(a: ItemSummary, b: ItemSummary) {
|
||||||
|
if (!sortByProperty.value) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
const aLower = extractSortable(a, sortByProperty.value);
|
const aLower = extractSortable(a, sortByProperty.value);
|
||||||
const bLower = extractSortable(b, sortByProperty.value);
|
const bLower = extractSortable(b, sortByProperty.value);
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import { AttachmentTypes, PaginationResult } from "../types/non-generated";
|
||||||
import { Requests } from "~~/lib/requests";
|
import { Requests } from "~~/lib/requests";
|
||||||
|
|
||||||
export type ItemsQuery = {
|
export type ItemsQuery = {
|
||||||
|
orderBy?: string;
|
||||||
includeArchived?: boolean;
|
includeArchived?: boolean;
|
||||||
page?: number;
|
page?: number;
|
||||||
pageSize?: number;
|
pageSize?: number;
|
||||||
|
|
|
@ -5,6 +5,7 @@ export function itemsTable(api: UserClient) {
|
||||||
const { data } = await api.items.getAll({
|
const { data } = await api.items.getAll({
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 5,
|
pageSize: 5,
|
||||||
|
orderBy: "createdAt",
|
||||||
});
|
});
|
||||||
return data.items;
|
return data.items;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue