Can disable couple photos (#5)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
Add an option in family settings to disable couple photos from Web UI Reviewed-on: #5
This commit is contained in:
@ -414,49 +414,52 @@ export function CouplePage(p: {
|
||||
</PropertiesBox>
|
||||
</Grid>
|
||||
|
||||
{/* Photo */}
|
||||
<Grid item sm={12} md={6}>
|
||||
<PropertiesBox title="Photo">
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<CouplePhoto couple={couple} width={150} />
|
||||
<br />
|
||||
{p.editing ? (
|
||||
<p>
|
||||
Veuillez enregistrer / annuler les modifications apportées à
|
||||
la fiche avant de changer la photo du couple.
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<UploadPhotoButton
|
||||
label={couple.hasPhoto ? "Remplacer" : "Ajouter"}
|
||||
onPhotoSelected={uploadNewPhoto}
|
||||
aspect={5 / 4}
|
||||
/>{" "}
|
||||
{couple.hasPhoto && (
|
||||
<RouterLink to={couple.photoURL!} target="_blank">
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<FileDownloadIcon />}
|
||||
>
|
||||
Télécharger
|
||||
</Button>
|
||||
</RouterLink>
|
||||
{
|
||||
/* Photo */ !family.family.disable_couple_photos && (
|
||||
<Grid item sm={12} md={6}>
|
||||
<PropertiesBox title="Photo">
|
||||
<div style={{ textAlign: "center" }}>
|
||||
<CouplePhoto couple={couple} width={150} />
|
||||
<br />
|
||||
{p.editing ? (
|
||||
<p>
|
||||
Veuillez enregistrer / annuler les modifications apportées
|
||||
à la fiche avant de changer la photo du couple.
|
||||
</p>
|
||||
) : (
|
||||
<>
|
||||
<UploadPhotoButton
|
||||
label={couple.hasPhoto ? "Remplacer" : "Ajouter"}
|
||||
onPhotoSelected={uploadNewPhoto}
|
||||
aspect={5 / 4}
|
||||
/>{" "}
|
||||
{couple.hasPhoto && (
|
||||
<RouterLink to={couple.photoURL!} target="_blank">
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<FileDownloadIcon />}
|
||||
>
|
||||
Télécharger
|
||||
</Button>
|
||||
</RouterLink>
|
||||
)}{" "}
|
||||
{couple.hasPhoto && (
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<DeleteIcon />}
|
||||
color="error"
|
||||
onClick={deletePhoto}
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}{" "}
|
||||
{couple.hasPhoto && (
|
||||
<Button
|
||||
variant="outlined"
|
||||
startIcon={<DeleteIcon />}
|
||||
color="error"
|
||||
onClick={deletePhoto}
|
||||
>
|
||||
Supprimer
|
||||
</Button>
|
||||
)}
|
||||
</>
|
||||
)}{" "}
|
||||
</div>
|
||||
</PropertiesBox>
|
||||
</Grid>
|
||||
</div>
|
||||
</PropertiesBox>
|
||||
</Grid>
|
||||
)
|
||||
}
|
||||
|
||||
{/* Children */}
|
||||
{p.children && (
|
||||
|
@ -225,6 +225,9 @@ function CouplesTable(p: {
|
||||
},
|
||||
];
|
||||
|
||||
// If couple photos are hidden, remove their column
|
||||
if (family.family.disable_couple_photos) columns.splice(0, 1);
|
||||
|
||||
return (
|
||||
<DataGrid
|
||||
style={{ flex: "1" }}
|
||||
@ -233,7 +236,7 @@ function CouplesTable(p: {
|
||||
autoPageSize
|
||||
getRowId={(c) => c.id}
|
||||
onCellDoubleClick={(p) => {
|
||||
let member;
|
||||
/*let member;
|
||||
if (p.field === "wife") member = family.members.get(p.row.wife);
|
||||
else if (p.field === "husband")
|
||||
member = family.members.get(p.row.husband);
|
||||
@ -241,7 +244,7 @@ function CouplesTable(p: {
|
||||
if (member) {
|
||||
n(family.family.memberURL(member));
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
n(family.family.coupleURL(p.row));
|
||||
}}
|
||||
|
@ -6,7 +6,10 @@ import {
|
||||
Button,
|
||||
CardActions,
|
||||
CardContent,
|
||||
Checkbox,
|
||||
FormControlLabel,
|
||||
TextField,
|
||||
Tooltip,
|
||||
Typography,
|
||||
} from "@mui/material";
|
||||
import React from "react";
|
||||
@ -73,6 +76,9 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
const family = useFamily();
|
||||
|
||||
const [newName, setNewName] = React.useState(family.family.name);
|
||||
const [disableCouplePhotos, setDisableCouplePhotos] = React.useState(
|
||||
family.family.disable_couple_photos
|
||||
);
|
||||
|
||||
const canEdit = family.family.is_admin;
|
||||
|
||||
@ -87,6 +93,7 @@ function FamilySettingsCard(): React.ReactElement {
|
||||
await FamilyApi.UpdateFamily({
|
||||
id: family.family.family_id,
|
||||
name: newName,
|
||||
disable_couple_photos: disableCouplePhotos,
|
||||
});
|
||||
|
||||
family.reloadFamilyInfo();
|
||||
@ -137,6 +144,18 @@ 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={disableCouplePhotos}
|
||||
onChange={(_e, c) => setDisableCouplePhotos(c)}
|
||||
/>
|
||||
}
|
||||
label="Désactiver les photos de couple"
|
||||
/>
|
||||
</Tooltip>
|
||||
</Box>
|
||||
</CardContent>
|
||||
<CardActions>
|
||||
|
Reference in New Issue
Block a user