Can access family tree from member page
This commit is contained in:
parent
8cfe51fb0d
commit
4eaaa11cc6
@ -64,6 +64,15 @@ export class Family implements FamilyAPI {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get family tree URL for member
|
||||||
|
*/
|
||||||
|
familyTreeURL(member: Member | number): string {
|
||||||
|
return `/family/${this.family_id}/tree/${
|
||||||
|
typeof member === "number" ? member : member.id
|
||||||
|
}`;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get application URL for couple page
|
* Get application URL for couple page
|
||||||
*/
|
*/
|
||||||
|
@ -37,6 +37,8 @@ import { PropSelect } from "../../widgets/forms/PropSelect";
|
|||||||
import { SexSelection } from "../../widgets/forms/SexSelection";
|
import { SexSelection } from "../../widgets/forms/SexSelection";
|
||||||
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
|
import { UploadPhotoButton } from "../../widgets/forms/UploadPhotoButton";
|
||||||
import { useQuery } from "../../hooks/useQuery";
|
import { useQuery } from "../../hooks/useQuery";
|
||||||
|
import { mdiFamilyTree } from "@mdi/js";
|
||||||
|
import Icon from "@mdi/react";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new member route
|
* Create a new member route
|
||||||
@ -150,6 +152,7 @@ export function FamilyMemberRoute(): React.ReactElement {
|
|||||||
couples={family.couples.getAllOf(member!)}
|
couples={family.couples.getAllOf(member!)}
|
||||||
creating={false}
|
creating={false}
|
||||||
editing={false}
|
editing={false}
|
||||||
|
onrequestOpenTree={() => n(family.family.familyTreeURL(member!))}
|
||||||
onRequestDelete={deleteMember}
|
onRequestDelete={deleteMember}
|
||||||
onRequestEdit={() =>
|
onRequestEdit={() =>
|
||||||
n(family.family.URL(`member/${member!.id}/edit`))
|
n(family.family.URL(`member/${member!.id}/edit`))
|
||||||
@ -234,6 +237,7 @@ export function MemberPage(p: {
|
|||||||
onRequestEdit?: () => void;
|
onRequestEdit?: () => void;
|
||||||
onRequestDelete?: () => void;
|
onRequestDelete?: () => void;
|
||||||
onForceReload?: () => void;
|
onForceReload?: () => void;
|
||||||
|
onrequestOpenTree?: () => void;
|
||||||
}): React.ReactElement {
|
}): React.ReactElement {
|
||||||
const confirm = useConfirm();
|
const confirm = useConfirm();
|
||||||
const snackbar = useSnackbar();
|
const snackbar = useSnackbar();
|
||||||
@ -308,6 +312,17 @@ export function MemberPage(p: {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Stack direction="row" spacing={1}>
|
<Stack direction="row" spacing={1}>
|
||||||
|
{/* Family tree button */}
|
||||||
|
{p.onrequestOpenTree && (
|
||||||
|
<Button
|
||||||
|
variant="outlined"
|
||||||
|
startIcon={<Icon path={mdiFamilyTree} size={1} />}
|
||||||
|
onClick={p.onrequestOpenTree}
|
||||||
|
size="large"
|
||||||
|
>
|
||||||
|
Arbre
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
{/* Edit button */}
|
{/* Edit button */}
|
||||||
{p.onRequestEdit && (
|
{p.onRequestEdit && (
|
||||||
<Button
|
<Button
|
||||||
|
@ -8,7 +8,7 @@ export function FamilyTreeRoute(): React.ReactElement {
|
|||||||
const family = useFamily();
|
const family = useFamily();
|
||||||
|
|
||||||
const onMemberSelected = (id: number | undefined) => {
|
const onMemberSelected = (id: number | undefined) => {
|
||||||
if (id) n(family.family.URL(`tree/${id}`));
|
if (id) n(family.family.familyTreeURL(id));
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
Loading…
Reference in New Issue
Block a user