Genealogy as a feature #175

Merged
pierre merged 16 commits from genealogy_as_a_feature into master 2024-05-16 19:15:16 +00:00
4 changed files with 41 additions and 12 deletions
Showing only changes of commit d2a4bfb8e8 - Show all commits

View File

@ -85,9 +85,11 @@ export class Family implements FamilyAPI {
export class ExtendedFamilyInfo extends Family { export class ExtendedFamilyInfo extends Family {
public disable_couple_photos: boolean; public disable_couple_photos: boolean;
public enable_genealogy: boolean;
constructor(p: any) { constructor(p: any) {
super(p); super(p);
this.disable_couple_photos = p.disable_couple_photos; this.disable_couple_photos = p.disable_couple_photos;
this.enable_genealogy = p.enable_genealogy;
} }
} }
@ -230,6 +232,7 @@ export class FamilyApi {
static async UpdateFamily(settings: { static async UpdateFamily(settings: {
id: number; id: number;
name: string; name: string;
enable_genealogy: boolean;
disable_couple_photos: boolean; disable_couple_photos: boolean;
}): Promise<void> { }): Promise<void> {
await APIClient.exec({ await APIClient.exec({
@ -237,6 +240,7 @@ export class FamilyApi {
uri: `/family/${settings.id}`, uri: `/family/${settings.id}`,
jsonData: { jsonData: {
name: settings.name, name: settings.name,
enable_genealogy: settings.enable_genealogy,
disable_couple_photos: settings.disable_couple_photos, disable_couple_photos: settings.disable_couple_photos,
}, },
}); });

View File

@ -76,6 +76,9 @@ function FamilySettingsCard(): React.ReactElement {
const family = useFamily(); const family = useFamily();
const [newName, setNewName] = React.useState(family.family.name); const [newName, setNewName] = React.useState(family.family.name);
const [enableGenealogy, setEnableGenealogy] = React.useState(
family.family.enable_genealogy
);
const [disableCouplePhotos, setDisableCouplePhotos] = React.useState( const [disableCouplePhotos, setDisableCouplePhotos] = React.useState(
family.family.disable_couple_photos family.family.disable_couple_photos
); );
@ -93,6 +96,7 @@ function FamilySettingsCard(): React.ReactElement {
await FamilyApi.UpdateFamily({ await FamilyApi.UpdateFamily({
id: family.family.family_id, id: family.family.family_id,
name: newName, name: newName,
enable_genealogy: enableGenealogy,
disable_couple_photos: disableCouplePhotos, disable_couple_photos: disableCouplePhotos,
}); });
@ -144,18 +148,34 @@ function FamilySettingsCard(): React.ReactElement {
maxLength: ServerApi.Config.constraints.family_name_len.max, maxLength: ServerApi.Config.constraints.family_name_len.max,
}} }}
/> />
<Tooltip title="Les photos de couple ne sont pas utilisées en pratique dans les arbres généalogiques. Il est possible de masquer les formulaires d'édition de photos de couple pour limiter le risque de confusion.">
<FormControlLabel <FormControlLabel
disabled={!canEdit} disabled={!canEdit}
control={ control={
<Checkbox <Checkbox
checked={disableCouplePhotos} checked={enableGenealogy}
onChange={(_e, c) => setDisableCouplePhotos(c)} onChange={(_e, c) => setEnableGenealogy(c)}
/> />
} }
label="Désactiver les photos de couple" label="Activer la généalogie"
/> />
</Tooltip> {enableGenealogy && (
<Tooltip
title="Les photos de couple ne sont pas utilisées en pratique dans les arbres généalogiques. Il est possible de masquer les formulaires d'édition de photos de couple pour limiter le risque de confusion."
arrow
>
<FormControlLabel
disabled={!canEdit}
control={
<Checkbox
checked={disableCouplePhotos}
onChange={(_e, c) => setDisableCouplePhotos(c)}
/>
}
label="Désactiver les photos de couple"
/>
</Tooltip>
)}
</Box> </Box>
</CardContent> </CardContent>
<CardActions> <CardActions>

View File

@ -79,6 +79,7 @@ pub async fn list(token: LoginToken) -> HttpResult {
struct RichFamilyInfo { struct RichFamilyInfo {
#[serde(flatten)] #[serde(flatten)]
membership: FamilyMembership, membership: FamilyMembership,
enable_genealogy: bool,
disable_couple_photos: bool, disable_couple_photos: bool,
} }
@ -88,6 +89,7 @@ pub async fn single_info(f: FamilyInPath) -> HttpResult {
let family = families_service::get_by_id(f.family_id()).await?; let family = families_service::get_by_id(f.family_id()).await?;
Ok(HttpResponse::Ok().json(RichFamilyInfo { Ok(HttpResponse::Ok().json(RichFamilyInfo {
membership, membership,
enable_genealogy: family.enable_genealogy,
disable_couple_photos: family.disable_couple_photos, disable_couple_photos: family.disable_couple_photos,
})) }))
} }
@ -102,6 +104,7 @@ pub async fn leave(f: FamilyInPath) -> HttpResult {
#[derive(serde::Deserialize)] #[derive(serde::Deserialize)]
pub struct UpdateFamilyBody { pub struct UpdateFamilyBody {
name: String, name: String,
enable_genealogy: bool,
disable_couple_photos: bool, disable_couple_photos: bool,
} }
@ -119,6 +122,7 @@ pub async fn update(
let mut family = families_service::get_by_id(f.family_id()).await?; let mut family = families_service::get_by_id(f.family_id()).await?;
family.name = req.0.name; family.name = req.0.name;
family.enable_genealogy = req.0.enable_genealogy;
family.disable_couple_photos = req.0.disable_couple_photos; family.disable_couple_photos = req.0.disable_couple_photos;
families_service::update_family(&family).await?; families_service::update_family(&family).await?;

View File

@ -174,6 +174,7 @@ pub async fn update_family(family: &Family) -> anyhow::Result<()> {
.set(( .set((
families::dsl::name.eq(family.name.clone()), families::dsl::name.eq(family.name.clone()),
families::dsl::invitation_code.eq(family.invitation_code.clone()), families::dsl::invitation_code.eq(family.invitation_code.clone()),
families::dsl::enable_genealogy.eq(family.enable_genealogy),
families::dsl::disable_couple_photos.eq(family.disable_couple_photos), families::dsl::disable_couple_photos.eq(family.disable_couple_photos),
)) ))
.execute(conn) .execute(conn)