Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
+104
@@ -0,0 +1,104 @@
|
||||
import { Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import CheckIcon from "~/components/ui/icons/CheckIcon";
|
||||
import XIcon from "~/components/ui/icons/XIcon";
|
||||
import OrderListButtons from "~/components/ui/sort/OrderListButtons";
|
||||
import TableSimple from "~/components/ui/tables/TableSimple";
|
||||
import { EntityRelationshipWithDetails } from "~/utils/db/entities/entityRelationships.db.server";
|
||||
import { translateLabel } from "~/utils/i18n/translateLabel";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
|
||||
export default function EntityRelationshipsTable({
|
||||
items,
|
||||
editable,
|
||||
}: {
|
||||
items: (EntityRelationshipWithDetails & { _count: { rows: number } })[];
|
||||
editable: boolean;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<TableSimple
|
||||
headers={[
|
||||
{
|
||||
name: "order",
|
||||
title: "shared.order",
|
||||
value: (_item, idx) => (
|
||||
<div>
|
||||
{/* {item.order} */}
|
||||
<OrderListButtons index={idx} items={items.map((f) => ({ ...f, order: f.order ?? 0 }))} editable={true} />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "type",
|
||||
title: "shared.type",
|
||||
value: (item) => (
|
||||
<Link to={item.id} className="font-medium underline">
|
||||
{t("shared.relationships." + item.type)}
|
||||
</Link>
|
||||
),
|
||||
className: "w-full",
|
||||
},
|
||||
{
|
||||
name: "parent",
|
||||
title: "admin.entities.relationships.table.parent",
|
||||
value: (item) => (
|
||||
<div>
|
||||
{translateLabel(t, i18n, item.parent.title)} {item.parentEntityView && <span className="text-muted-foreground text-xs italic">({item.parentEntityView.name})</span>}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "child",
|
||||
title: "admin.entities.relationships.table.child",
|
||||
value: (item) => (
|
||||
<div>
|
||||
{translateLabel(t, i18n, item.child.title)} {item.childEntityView && <span className="text-muted-foreground text-xs italic">({item.childEntityView.name})</span>}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "count",
|
||||
title: "admin.entities.relationships.table.count",
|
||||
value: (item) => <div>{formatters.number(item._count.rows)}</div>,
|
||||
},
|
||||
{
|
||||
name: "required",
|
||||
title: "shared.required",
|
||||
value: (item) => <div>{item.required ? <CheckIcon className="h-5 w-5 text-teal-500" /> : <XIcon className="text-muted-foreground h-5 w-5" />}</div>,
|
||||
},
|
||||
{
|
||||
name: "cascade",
|
||||
title: "admin.entities.relationships.table.cascadeDelete",
|
||||
value: (item) => <div>{item.cascade ? <CheckIcon className="h-5 w-5 text-teal-500" /> : <XIcon className="text-muted-foreground h-5 w-5" />}</div>,
|
||||
},
|
||||
{
|
||||
name: "readOnly",
|
||||
title: "admin.entities.relationships.table.readOnly",
|
||||
value: (item) => <div>{item.readOnly ? <CheckIcon className="h-5 w-5 text-teal-500" /> : <XIcon className="text-muted-foreground h-5 w-5" />}</div>,
|
||||
},
|
||||
{
|
||||
name: "hiddenIfEmpty",
|
||||
title: "admin.entities.relationships.table.hiddenIfEmpty",
|
||||
value: (item) => (
|
||||
<div>{item.hiddenIfEmpty ? <CheckIcon className="h-5 w-5 text-teal-500" /> : <XIcon className="text-muted-foreground h-5 w-5" />}</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: "title",
|
||||
title: "shared.title",
|
||||
value: (item) => <div>{translateLabel(t, i18n, item.title)}</div>,
|
||||
},
|
||||
]}
|
||||
items={items}
|
||||
actions={[
|
||||
{
|
||||
title: t("shared.edit"),
|
||||
onClickRoute: (_, item) => item.id,
|
||||
hidden: () => !editable,
|
||||
},
|
||||
]}
|
||||
></TableSimple>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user