Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+4
-69
@@ -1,22 +1,13 @@
|
||||
import { Property } from "@toolctrl/db/prisma-browser";
|
||||
import { RowFiltersDto } from "~/application/dtos/data/RowFiltersDto";
|
||||
import { SortedByDto } from "~/application/dtos/data/SortedByDto";
|
||||
import { EntityWithDetails } from "../db/entities/entities.db.server";
|
||||
import { FiltersDto } from "~/application/dtos/data/FiltersDto";
|
||||
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
import Constants from "~/application/Constants";
|
||||
import { EntityViewWithDetails } from "../db/entities/entityViews.db.server";
|
||||
import { EntityRelationshipWithDetails } from "../db/entities/entityRelationships.db.server";
|
||||
|
||||
export function getPaginationFromCurrentUrl(
|
||||
urlSearchParams: URLSearchParams,
|
||||
entity?: EntityWithDetails,
|
||||
entityView?: EntityViewWithDetails | null
|
||||
): { page: number; pageSize: number; sortedBy: SortedByDto[]; query: string } {
|
||||
export function getPaginationFromCurrentUrl(urlSearchParams: URLSearchParams): { page: number; pageSize: number; sortedBy: SortedByDto[]; query: string } {
|
||||
return {
|
||||
page: getPageFromCurrentUrl(urlSearchParams),
|
||||
pageSize: getPageSizeFromCurrentUrl(urlSearchParams),
|
||||
sortedBy: getSortByFromCurrentUrl(urlSearchParams, entity, entityView),
|
||||
sortedBy: getSortByFromCurrentUrl(urlSearchParams),
|
||||
query: getSearchQueryFromCurrentUrl(urlSearchParams),
|
||||
};
|
||||
}
|
||||
@@ -38,61 +29,6 @@ export function getFiltersFromCurrentUrl(request: Request, properties: Filterabl
|
||||
return { query, properties };
|
||||
}
|
||||
|
||||
export function getEntityFiltersFromCurrentUrl(
|
||||
customRow: boolean,
|
||||
entity: EntityWithDetails,
|
||||
urlSearchParams: URLSearchParams,
|
||||
entityView?: EntityViewWithDetails | null | null
|
||||
): RowFiltersDto {
|
||||
const tags: string[] = [];
|
||||
const properties: {
|
||||
property?: Property;
|
||||
name?: string;
|
||||
value: string | string[] | null;
|
||||
condition?: string;
|
||||
match?: "and" | "or";
|
||||
parentEntity?: EntityRelationshipWithDetails;
|
||||
}[] = [];
|
||||
entity.properties.forEach((property) => {
|
||||
if (urlSearchParams.getAll(property.name).length > 1) {
|
||||
properties.push({ property, value: urlSearchParams.getAll(property.name) });
|
||||
} else {
|
||||
const param = urlSearchParams.get(property.name);
|
||||
properties.push({ property, value: param ?? null });
|
||||
}
|
||||
});
|
||||
|
||||
entityView?.filters.forEach((filter) => {
|
||||
const property = entity.properties.find((f) => f.name === filter.name);
|
||||
const match = filter.match === "or" ? "or" : "and";
|
||||
if (property) {
|
||||
properties.push({ property, value: filter.value ?? null, condition: filter.condition, match });
|
||||
} else {
|
||||
properties.push({ name: filter.name, value: filter.value ?? null, condition: filter.condition, match });
|
||||
}
|
||||
});
|
||||
|
||||
urlSearchParams.getAll("tag").forEach((tag) => {
|
||||
tags.push(tag);
|
||||
});
|
||||
|
||||
entity.parentEntities.forEach((parentRel) => {
|
||||
const id = urlSearchParams.get(`${parentRel.parent.name}_id`);
|
||||
if (id) {
|
||||
properties.push({
|
||||
name: `${parentRel.parent.name}_id`,
|
||||
value: id,
|
||||
parentEntity: parentRel,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const query = urlSearchParams.get("q");
|
||||
|
||||
// console.log({ tags });
|
||||
return { customRow, entity, properties, query, tags };
|
||||
}
|
||||
|
||||
function getPageFromCurrentUrl(urlSearchParams: URLSearchParams): number {
|
||||
const paramsPage = urlSearchParams.get("page");
|
||||
const page = paramsPage ? Number(paramsPage) : 1;
|
||||
@@ -118,7 +54,7 @@ function getSearchQueryFromCurrentUrl(urlSearchParams: URLSearchParams): string
|
||||
return urlSearchParams.get("q")?.toString() ?? "";
|
||||
}
|
||||
|
||||
function getSortByFromCurrentUrl(urlSearchParams: URLSearchParams, entity?: EntityWithDetails, entityView?: EntityViewWithDetails | null): SortedByDto[] {
|
||||
function getSortByFromCurrentUrl(urlSearchParams: URLSearchParams): SortedByDto[] {
|
||||
let sorts = urlSearchParams.get("sort")?.toString().split(",") ?? [];
|
||||
return sorts.map((sort) => {
|
||||
let direction: "asc" | "desc" = "asc";
|
||||
@@ -131,8 +67,7 @@ function getSortByFromCurrentUrl(urlSearchParams: URLSearchParams, entity?: Enti
|
||||
}
|
||||
}
|
||||
const sortName = sort.replace("-", "").replace("+", "");
|
||||
const property = entity?.properties.find((p) => p.name === sortName);
|
||||
return { entity, name: sortName, direction, property };
|
||||
return { name: sortName, direction };
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user