Compare commits
3 Commits
cd7462ffb1
...
d2a4bfb8e8
| Author | SHA1 | Date | |
|---|---|---|---|
| d2a4bfb8e8 | |||
| 88e40fece6 | |||
| c6b518d8de |
@@ -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<void> {
|
||||
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,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -132,7 +132,13 @@ function CouplesTable(p: {
|
||||
sortable: false,
|
||||
width: 60,
|
||||
renderCell(params) {
|
||||
return <CouplePhoto couple={params.row} />;
|
||||
return (
|
||||
<div
|
||||
style={{ display: "flex", alignItems: "center", height: "100%" }}
|
||||
>
|
||||
<CouplePhoto couple={params.row} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -113,7 +113,13 @@ function MembersTable(p: {
|
||||
sortable: false,
|
||||
width: 60,
|
||||
renderCell(params) {
|
||||
return <MemberPhoto member={params.row} />;
|
||||
return (
|
||||
<div
|
||||
style={{ display: "flex", alignItems: "center", height: "100%" }}
|
||||
>
|
||||
<MemberPhoto member={params.row} />
|
||||
</div>
|
||||
);
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
@@ -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,7 +148,22 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
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
|
||||
disabled={!canEdit}
|
||||
control={
|
||||
<Checkbox
|
||||
checked={enableGenealogy}
|
||||
onChange={(_e, c) => setEnableGenealogy(c)}
|
||||
/>
|
||||
}
|
||||
label="Activer la généalogie"
|
||||
/>
|
||||
{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={
|
||||
@@ -156,6 +175,7 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
label="Désactiver les photos de couple"
|
||||
/>
|
||||
</Tooltip>
|
||||
)}
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Remove column to toggle genealogy
|
||||
ALTER TABLE public.families
|
||||
DROP COLUMN enable_genealogy;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Add column to toggle genealogy
|
||||
ALTER TABLE public.families
|
||||
ADD enable_genealogy boolean NOT NULL DEFAULT false;
|
||||
COMMENT
|
||||
ON COLUMN public.families.enable_genealogy IS 'Specify whether genealogy feature is enabled for the family';
|
||||
@@ -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?;
|
||||
|
||||
|
||||
@@ -65,6 +65,7 @@ pub struct Family {
|
||||
pub name: String,
|
||||
pub invitation_code: String,
|
||||
pub disable_couple_photos: bool,
|
||||
pub enable_genealogy: bool,
|
||||
}
|
||||
|
||||
impl Family {
|
||||
|
||||
@@ -29,6 +29,7 @@ diesel::table! {
|
||||
#[max_length = 7]
|
||||
invitation_code -> Varchar,
|
||||
disable_couple_photos -> Bool,
|
||||
enable_genealogy -> Bool,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user