diff --git a/geneit_app/src/api/FamilyApi.ts b/geneit_app/src/api/FamilyApi.ts index 94128c0..1c3b929 100644 --- a/geneit_app/src/api/FamilyApi.ts +++ b/geneit_app/src/api/FamilyApi.ts @@ -85,9 +85,11 @@ export class Family implements FamilyAPI { export class ExtendedFamilyInfo extends Family { public disable_couple_photos: boolean; + public enable_genealogy: boolean; constructor(p: any) { super(p); 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: { id: number; name: string; + enable_genealogy: boolean; disable_couple_photos: boolean; }): Promise { await APIClient.exec({ @@ -237,6 +240,7 @@ export class FamilyApi { uri: `/family/${settings.id}`, jsonData: { name: settings.name, + enable_genealogy: settings.enable_genealogy, disable_couple_photos: settings.disable_couple_photos, }, }); diff --git a/geneit_app/src/routes/family/FamilySettingsRoute.tsx b/geneit_app/src/routes/family/FamilySettingsRoute.tsx index c99cfbd..5c1cc14 100644 --- a/geneit_app/src/routes/family/FamilySettingsRoute.tsx +++ b/geneit_app/src/routes/family/FamilySettingsRoute.tsx @@ -76,6 +76,9 @@ function FamilySettingsCard(): React.ReactElement { const family = useFamily(); const [newName, setNewName] = React.useState(family.family.name); + const [enableGenealogy, setEnableGenealogy] = React.useState( + family.family.enable_genealogy + ); const [disableCouplePhotos, setDisableCouplePhotos] = React.useState( family.family.disable_couple_photos ); @@ -93,6 +96,7 @@ function FamilySettingsCard(): React.ReactElement { await FamilyApi.UpdateFamily({ id: family.family.family_id, name: newName, + enable_genealogy: enableGenealogy, disable_couple_photos: disableCouplePhotos, }); @@ -144,18 +148,34 @@ function FamilySettingsCard(): React.ReactElement { maxLength: ServerApi.Config.constraints.family_name_len.max, }} /> - - setDisableCouplePhotos(c)} - /> - } - label="Désactiver les photos de couple" - /> - + + setEnableGenealogy(c)} + /> + } + label="Activer la généalogie" + /> + {enableGenealogy && ( + + setDisableCouplePhotos(c)} + /> + } + label="Désactiver les photos de couple" + /> + + )} diff --git a/geneit_backend/src/controllers/families_controller.rs b/geneit_backend/src/controllers/families_controller.rs index d5c3f92..1e37110 100644 --- a/geneit_backend/src/controllers/families_controller.rs +++ b/geneit_backend/src/controllers/families_controller.rs @@ -79,6 +79,7 @@ pub async fn list(token: LoginToken) -> HttpResult { struct RichFamilyInfo { #[serde(flatten)] membership: FamilyMembership, + enable_genealogy: 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?; Ok(HttpResponse::Ok().json(RichFamilyInfo { membership, + enable_genealogy: family.enable_genealogy, disable_couple_photos: family.disable_couple_photos, })) } @@ -102,6 +104,7 @@ pub async fn leave(f: FamilyInPath) -> HttpResult { #[derive(serde::Deserialize)] pub struct UpdateFamilyBody { name: String, + enable_genealogy: 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?; family.name = req.0.name; + family.enable_genealogy = req.0.enable_genealogy; family.disable_couple_photos = req.0.disable_couple_photos; families_service::update_family(&family).await?; diff --git a/geneit_backend/src/services/families_service.rs b/geneit_backend/src/services/families_service.rs index 77c6b0c..af6dd93 100644 --- a/geneit_backend/src/services/families_service.rs +++ b/geneit_backend/src/services/families_service.rs @@ -174,6 +174,7 @@ pub async fn update_family(family: &Family) -> anyhow::Result<()> { .set(( families::dsl::name.eq(family.name.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), )) .execute(conn)