Can toggle accommodations module
This commit is contained in:
parent
32d3793025
commit
2f1df6c117
@ -88,10 +88,12 @@ 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;
|
public enable_genealogy: boolean;
|
||||||
|
public enable_accommodations: 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;
|
this.enable_genealogy = p.enable_genealogy;
|
||||||
|
this.enable_accommodations = p.enable_accommodations;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +237,7 @@ export class FamilyApi {
|
|||||||
id: number;
|
id: number;
|
||||||
name?: string;
|
name?: string;
|
||||||
enable_genealogy?: boolean;
|
enable_genealogy?: boolean;
|
||||||
|
enable_accommodations?: boolean;
|
||||||
disable_couple_photos?: boolean;
|
disable_couple_photos?: boolean;
|
||||||
}): Promise<void> {
|
}): Promise<void> {
|
||||||
await APIClient.exec({
|
await APIClient.exec({
|
||||||
@ -243,6 +246,7 @@ export class FamilyApi {
|
|||||||
jsonData: {
|
jsonData: {
|
||||||
name: settings.name,
|
name: settings.name,
|
||||||
enable_genealogy: settings.enable_genealogy,
|
enable_genealogy: settings.enable_genealogy,
|
||||||
|
enable_accommodations: settings.enable_accommodations,
|
||||||
disable_couple_photos: settings.disable_couple_photos,
|
disable_couple_photos: settings.disable_couple_photos,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -71,6 +71,9 @@ function FamilySettingsCard(): React.ReactElement {
|
|||||||
const [enableGenealogy, setEnableGenealogy] = React.useState(
|
const [enableGenealogy, setEnableGenealogy] = React.useState(
|
||||||
family.family.enable_genealogy
|
family.family.enable_genealogy
|
||||||
);
|
);
|
||||||
|
const [enableAccommodations, setEnableAccommodations] = React.useState(
|
||||||
|
family.family.enable_accommodations
|
||||||
|
);
|
||||||
|
|
||||||
const canEdit = family.family.is_admin;
|
const canEdit = family.family.is_admin;
|
||||||
|
|
||||||
@ -86,6 +89,7 @@ function FamilySettingsCard(): React.ReactElement {
|
|||||||
id: family.family.family_id,
|
id: family.family.family_id,
|
||||||
name: newName,
|
name: newName,
|
||||||
enable_genealogy: enableGenealogy,
|
enable_genealogy: enableGenealogy,
|
||||||
|
enable_accommodations: enableAccommodations,
|
||||||
});
|
});
|
||||||
|
|
||||||
family.reloadFamilyInfo();
|
family.reloadFamilyInfo();
|
||||||
@ -118,14 +122,12 @@ function FamilySettingsCard(): React.ReactElement {
|
|||||||
label="Identifiant"
|
label="Identifiant"
|
||||||
value={family.family.family_id}
|
value={family.family.family_id}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
disabled
|
disabled
|
||||||
fullWidth
|
fullWidth
|
||||||
label="Création de la famille"
|
label="Création de la famille"
|
||||||
value={formatDate(family.family.time_create)}
|
value={formatDate(family.family.time_create)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
label="Nom de la famille"
|
label="Nom de la famille"
|
||||||
@ -136,7 +138,6 @@ function FamilySettingsCard(): React.ReactElement {
|
|||||||
maxLength: ServerApi.Config.constraints.family_name_len.max,
|
maxLength: ServerApi.Config.constraints.family_name_len.max,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
disabled={!canEdit}
|
disabled={!canEdit}
|
||||||
control={
|
control={
|
||||||
@ -147,6 +148,16 @@ function FamilySettingsCard(): React.ReactElement {
|
|||||||
}
|
}
|
||||||
label="Activer le module de généalogie"
|
label="Activer le module de généalogie"
|
||||||
/>
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
disabled={!canEdit}
|
||||||
|
control={
|
||||||
|
<Switch
|
||||||
|
checked={enableAccommodations}
|
||||||
|
onChange={(_e, c) => setEnableAccommodations(c)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
label="Activer le module de réservation de logements"
|
||||||
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
<CardActions>
|
<CardActions>
|
||||||
|
@ -1,2 +1,5 @@
|
|||||||
|
ALTER TABLE public.families
|
||||||
|
DROP COLUMN enable_accommodations;
|
||||||
|
|
||||||
DROP TABLE IF EXISTS accomodations_reservations;
|
DROP TABLE IF EXISTS accomodations_reservations;
|
||||||
DROP TABLE IF EXISTS accomodations_list;
|
DROP TABLE IF EXISTS accomodations_list;
|
@ -1,3 +1,10 @@
|
|||||||
|
-- Add column to toggle accommodations module
|
||||||
|
ALTER TABLE public.families
|
||||||
|
ADD enable_accommodations boolean NOT NULL DEFAULT false;
|
||||||
|
COMMENT
|
||||||
|
ON COLUMN public.families.enable_accommodations IS 'Specify whether accommodations feature is enabled for the family';
|
||||||
|
|
||||||
|
|
||||||
-- Create tables
|
-- Create tables
|
||||||
CREATE TABLE IF NOT EXISTS accommodations_list
|
CREATE TABLE IF NOT EXISTS accommodations_list
|
||||||
(
|
(
|
||||||
|
@ -80,6 +80,7 @@ struct RichFamilyInfo {
|
|||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
membership: FamilyMembership,
|
membership: FamilyMembership,
|
||||||
enable_genealogy: bool,
|
enable_genealogy: bool,
|
||||||
|
enable_accommodations: bool,
|
||||||
disable_couple_photos: bool,
|
disable_couple_photos: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,6 +91,7 @@ pub async fn single_info(f: FamilyInPath) -> HttpResult {
|
|||||||
Ok(HttpResponse::Ok().json(RichFamilyInfo {
|
Ok(HttpResponse::Ok().json(RichFamilyInfo {
|
||||||
membership,
|
membership,
|
||||||
enable_genealogy: family.enable_genealogy,
|
enable_genealogy: family.enable_genealogy,
|
||||||
|
enable_accommodations: family.enable_accommodations,
|
||||||
disable_couple_photos: family.disable_couple_photos,
|
disable_couple_photos: family.disable_couple_photos,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -105,6 +107,7 @@ pub async fn leave(f: FamilyInPath) -> HttpResult {
|
|||||||
pub struct UpdateFamilyBody {
|
pub struct UpdateFamilyBody {
|
||||||
name: Option<String>,
|
name: Option<String>,
|
||||||
enable_genealogy: Option<bool>,
|
enable_genealogy: Option<bool>,
|
||||||
|
enable_accommodations: Option<bool>,
|
||||||
disable_couple_photos: Option<bool>,
|
disable_couple_photos: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,6 +130,10 @@ pub async fn update(
|
|||||||
family.enable_genealogy = enable_genealogy;
|
family.enable_genealogy = enable_genealogy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(enable_accommodations) = req.enable_accommodations {
|
||||||
|
family.enable_accommodations = enable_accommodations;
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(disable_couple_photos) = req.disable_couple_photos {
|
if let Some(disable_couple_photos) = req.disable_couple_photos {
|
||||||
family.disable_couple_photos = disable_couple_photos;
|
family.disable_couple_photos = disable_couple_photos;
|
||||||
}
|
}
|
||||||
|
@ -204,6 +204,17 @@ async fn main() -> std::io::Result<()> {
|
|||||||
"/family/{id}/genealogy/data/import",
|
"/family/{id}/genealogy/data/import",
|
||||||
web::put().to(data_controller::import_family),
|
web::put().to(data_controller::import_family),
|
||||||
)
|
)
|
||||||
|
// [ACCOMODATIONS] List controller
|
||||||
|
// TODO : create
|
||||||
|
// TODO : update
|
||||||
|
// TODO : delete
|
||||||
|
// TODO : list
|
||||||
|
// [ACCOMODATIONS] Reservations controller
|
||||||
|
// TODO : create
|
||||||
|
// TODO : update
|
||||||
|
// TODO : delete
|
||||||
|
// TODO : list
|
||||||
|
// TODO : validate or reject
|
||||||
// Photos controller
|
// Photos controller
|
||||||
.route(
|
.route(
|
||||||
"/photo/{id}",
|
"/photo/{id}",
|
||||||
|
@ -66,6 +66,7 @@ pub struct Family {
|
|||||||
pub invitation_code: String,
|
pub invitation_code: String,
|
||||||
pub disable_couple_photos: bool,
|
pub disable_couple_photos: bool,
|
||||||
pub enable_genealogy: bool,
|
pub enable_genealogy: bool,
|
||||||
|
pub enable_accommodations: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Family {
|
impl Family {
|
||||||
|
@ -56,6 +56,7 @@ diesel::table! {
|
|||||||
invitation_code -> Varchar,
|
invitation_code -> Varchar,
|
||||||
disable_couple_photos -> Bool,
|
disable_couple_photos -> Bool,
|
||||||
enable_genealogy -> Bool,
|
enable_genealogy -> Bool,
|
||||||
|
enable_accommodations -> Bool,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,6 +175,7 @@ pub async fn update_family(family: &Family) -> anyhow::Result<()> {
|
|||||||
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::enable_genealogy.eq(family.enable_genealogy),
|
||||||
|
families::dsl::enable_accommodations.eq(family.enable_accommodations),
|
||||||
families::dsl::disable_couple_photos.eq(family.disable_couple_photos),
|
families::dsl::disable_couple_photos.eq(family.disable_couple_photos),
|
||||||
))
|
))
|
||||||
.execute(conn)
|
.execute(conn)
|
||||||
|
Loading…
Reference in New Issue
Block a user