Skip to content

Commit

Permalink
feat: Toujours la modification d'une communauté espace co
Browse files Browse the repository at this point in the history
  • Loading branch information
pprev94 committed Oct 7, 2024
1 parent 25c518c commit 3b88458
Show file tree
Hide file tree
Showing 44 changed files with 1,641 additions and 358 deletions.
Binary file added Topic_category_cartesgouv.xlsx
Binary file not shown.
65 changes: 41 additions & 24 deletions assets/@types/espaceco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@ export interface ConstraintsDTO {
}

export const AttributeTypes = ["text", "integer", "double", "checkbox", "list", "date"];

export type AttributeType = (typeof AttributeTypes)[number];
export interface AttributeDTO {
export type AttributeDTO = {
name: string;
type: AttributeType;
default?: string;
default?: string | null;
mandatory?: boolean;
values?: string[];
help?: string;
multiple?: boolean;
values?: string[] | null;
help?: string | null;
title?: string;
input_constraints?: ConstraintsDTO;
json_schema?: object;
input_constraints?: ConstraintsDTO | null;
json_schema?: object | null;
required?: boolean;
condition_field?: string;
}
};

export interface ThemeDTO {
theme: string;
Expand All @@ -33,28 +35,38 @@ export interface ThemeDTO {
global?: boolean;
}

export type ReportStatuses = keyof typeof statuses;
export type ReportStatusesDTO = Record<
ReportStatuses,
{
wording: string;
help?: string;
}
>;

export type ReportStatusesDTO2 = {
status: ReportStatuses;
wording: string;
help?: string;
}[];
export type UserSharedThemesDTO = {
community_id: number;
community_name: string;
themes: ThemeDTO[];
};

export type SharedThemesDTO = {
community_id: number;
community_name: string;
themes: string[];
};

export type ReportStatusesType = keyof typeof statuses;

export type ReportStatusParams = {
title: string;
description?: string;
active: boolean;
};
export type ReportStatusesDTO = Record<string, ReportStatusParams>;

const SharedGeoremOptions = ["all", "restrained", "personal"];
export type SharedGeorem = (typeof SharedGeoremOptions)[number];
export interface CommunityResponseDTO {
id: number;
description: string | null;
detailed_description?: string | null;
name: string;
active: boolean;
listed: boolean;
shared_georem: "all" | "restrained" | "personal";
shared_extractions: boolean;
email: string | null;
attributes: ThemeDTO[];
default_comment: string | null;
Expand All @@ -67,14 +79,14 @@ export interface CommunityResponseDTO {
open_without_affiliation: boolean;
open_with_email?: string[];
offline_allowed: boolean;
shared_extractions: boolean;
/** @format date-time */
creation: string;
grids: Grid[];
logo_url: string | null;
keywords?: string[];
documents?: DocumentDTO[];
report_statuses?: ReportStatusesDTO2;
report_statuses?: ReportStatusesDTO;
shared_themes?: SharedThemesDTO[];
}

export interface DocumentDTO {
Expand Down Expand Up @@ -176,5 +188,10 @@ export interface TableResponseDTO {

export type ReportFormType = {
attributes: ThemeDTO[];
report_statuses?: ReportStatusesDTO2;
report_statuses: ReportStatusesDTO;
shared_themes?: SharedThemesDTO[];
shared_georem: SharedGeorem;
all_members_can_valid: boolean;
};

export { SharedGeoremOptions };
3 changes: 1 addition & 2 deletions assets/data/report_statuses.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"valid": "Pris en compte",
"valid0": "Déjà pris en compte",
"reject": "Rejeté (hors spéc.)",
"reject0": "Rejeté (hors de propos)",
"test": "En mode test"
"reject0": "Rejeté (hors de propos)"
}
14 changes: 11 additions & 3 deletions assets/entrepot/pages/dashboard/DashboardPro.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fr } from "@codegouvfr/react-dsfr";
import Button from "@codegouvfr/react-dsfr/Button";
import { Tile } from "@codegouvfr/react-dsfr/Tile";
import { useMutation } from "@tanstack/react-query";
import { declareComponentKeys } from "i18nifty";
Expand All @@ -17,6 +16,7 @@ import { useAuthStore } from "../../../stores/AuthStore";
import api from "../../api";

import avatarSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/digital/avatar.svg";
import internetSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/digital/internet.svg";
import mailSendSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/digital/mail-send.svg";
import humanCoopSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/environment/human-cooperation.svg";
import padlockSvgUrl from "@codegouvfr/react-dsfr/dsfr/artwork/pictograms/system/padlock.svg";
Expand Down Expand Up @@ -124,8 +124,16 @@ const DashboardPro = () => {
</div>

{isApiEspaceCoDefined() && (
<div className={fr.cx("fr-grid-row", "fr-grid-row--left", "fr-mt-4w")}>
<Button linkProps={routes.espaceco_community_list().link}>{t("espaceco_frontoffice_list")}</Button>
<div className={fr.cx("fr-grid-row", "fr-grid-row--gutters")}>
<div className={fr.cx("fr-col-12", "fr-col-sm-6")}>
<Tile
linkProps={routes.espaceco_community_list().link}
imageUrl={internetSvgUrl}
desc="Voir la liste des guichets"
orientation="horizontal"
title={t("espaceco_frontoffice_list")}
/>
</div>
</div>
)}
</>
Expand Down
2 changes: 2 additions & 0 deletions assets/espaceco/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import community from "./community";
import grid from "./grid";
import permission from "./permission";
import user from "./users";

const api = {
user,
community,
permission,
grid,
Expand Down
12 changes: 12 additions & 0 deletions assets/espaceco/api/users.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { UserSharedThemesDTO } from "../../@types/espaceco";
import { jsonFetch } from "../../modules/jsonFetch";
import SymfonyRouting from "../../modules/Routing";

const getSharedThemes = () => {
const url = SymfonyRouting.generate("cartesgouvfr_api_espaceco_user_shared_themes");
return jsonFetch<UserSharedThemesDTO[]>(url);
};

const user = { getSharedThemes };

export default user;
11 changes: 10 additions & 1 deletion assets/espaceco/pages/communities/Communities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type QueryParamsType = {
const Communities: FC = () => {
const route = useRoute();
const { t } = useTranslation("CommunityList");
const { t: tBreadcrumb } = useTranslation("Breadcrumb");

const filter = useMemo<CommunityListFilter>(() => {
const f = route.params["filter"];
Expand Down Expand Up @@ -71,7 +72,15 @@ const Communities: FC = () => {
};

return (
<AppLayout navItems={navItems} documentTitle={t("title")}>
<AppLayout
navItems={navItems}
customBreadcrumbProps={{
homeLinkProps: routes.home().link,
segments: [{ label: tBreadcrumb("dashboard_pro"), linkProps: routes.dashboard_pro().link }],
currentPageLabel: tBreadcrumb("espaceco_community_list"),
}}
documentTitle={t("title")}
>
<h1>{t("title")}</h1>
<div>
{communityQuery.isError && <Alert severity="error" closable={false} title={communityQuery.error?.message} />}
Expand Down
18 changes: 15 additions & 3 deletions assets/espaceco/pages/communities/ManageCommunity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import { routes } from "../../../router/router";
import api from "../../api";
import Description from "./management/Description";
import Grid from "./management/Grid";
import ZoomAndCentering from "./management/ZoomAndCentering";
import Layer from "./management/Layer";
import Reports from "./management/Reports";
import ZoomAndCentering from "./management/ZoomAndCentering";

type ManageCommunityProps = {
communityId: number;
Expand All @@ -27,6 +27,7 @@ const navItems = datastoreNavItems();

const ManageCommunity: FC<ManageCommunityProps> = ({ communityId }) => {
const { t } = useTranslation("ManageCommunity");
const { t: tBreadcrumb } = useTranslation("Breadcrumb");

const communityQuery = useQuery<CommunityResponseDTO, CartesApiException>({
queryKey: RQKeys.community(communityId),
Expand All @@ -37,7 +38,18 @@ const ManageCommunity: FC<ManageCommunityProps> = ({ communityId }) => {
const [selectedTabId, setSelectedTabId] = useState("tab1");

return (
<AppLayout navItems={navItems} documentTitle={t("title", { name: communityQuery.data?.name })}>
<AppLayout
navItems={navItems}
customBreadcrumbProps={{
homeLinkProps: routes.home().link,
segments: [
{ label: tBreadcrumb("dashboard_pro"), linkProps: routes.dashboard_pro().link },
{ label: tBreadcrumb("espaceco_community_list"), linkProps: routes.espaceco_community_list().link },
],
currentPageLabel: tBreadcrumb("espaceco_manage_community", { communityName: communityQuery.data?.name }),
}}
documentTitle={t("title", { name: communityQuery.data?.name })}
>
<h1>{t("title", { name: communityQuery.data?.name })}</h1>
{communityQuery.isError ? (
<Alert
Expand All @@ -54,7 +66,7 @@ const ManageCommunity: FC<ManageCommunityProps> = ({ communityId }) => {
) : communityQuery.isLoading ? (
<LoadingText message={t("loading")} />
) : (
communityQuery.data !== undefined && (
communityQuery.data && (
<div className={fr.cx("fr-container", "fr-py-2w")}>
<Tabs
selectedTabId={selectedTabId}
Expand Down
47 changes: 46 additions & 1 deletion assets/espaceco/pages/communities/ManageCommunityTr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type logoAction = "add" | "modify" | "delete";
export const { i18n } = declareComponentKeys<
| { K: "title"; P: { name: string | undefined }; R: string }
| "loading"
| "loading_tables"
| "fetch_failed"
| "back_to_list"
| "tab1"
Expand Down Expand Up @@ -57,15 +58,25 @@ export const { i18n } = declareComponentKeys<
| "layer.tab3"
| "report.configure_themes"
| "report.configure_themes.explain"
| "report.configure_shared_themes"
| "report.configure_shared_themes.explain"
| "report.configure_statuses"
| "report.configure_statuses.explain"
| "report.manage_permissions"
| "report.manage_permissions.shared_report"
| "report.manage_permissions.shared_report_hint"
| { K: "report.manage_permissions.shared_report.option"; P: { option: string }; R: string }
| "report.manage_permissions.report_answers"
| "report.manage_permissions.authorize"
| "report.manage_permissions.authorize_hint"
| "grid.grids"
| { K: "grid.explain"; R: JSX.Element }
>()("ManageCommunity");

export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"] = {
title: ({ name }) => (name === undefined ? "Gérer le guichet" : `Gérer le guichet - ${name}`),
loading: "Recherche du guichet en cours ...",
loading_tables: "Recherche des tables pour la configuration des thèmes en cours ...",
fetch_failed: "La récupération des informations sur le guichet a échoué",
back_to_list: "Retour à la liste des guichets",
tab1: "Description",
Expand Down Expand Up @@ -129,9 +140,31 @@ export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"
"report.configure_themes": "Configurer les thèmes et attributs des signalements (optionnel)",
"report.configure_themes.explain":
"Afin de permettre aux membres de votre groupe de soumettre des signalements sur d'autres thématiques que celles IGN (Adresse, Bâti, Points d'intérêts...), vous pouvez ajouter vos propres thèmes et personnaliser le formulaire de saisie d'un nouveau signalement pour l'adapter à vos besoins métier. Les membres de votre groupe verront ces thèmes, en plus ou à la place des thèmes IGN, sur l'interface de saisie d'un nouveau signalement sur l'espace collaboratif, les plugins SIG et l'application mobile.",
"report.configure_shared_themes": "Afficher des thèmes partagés (optionnel)",
"report.configure_shared_themes.explain": "Vous pouvez également choisir des thèmes partagés qui apparaitront sur ce guichet.",
"report.configure_statuses": "Paramétrer les status des signalements (optionnel)",
"report.configure_statuses.explain":
"Vous pouvez supprimer un maximum de 2 status en les décochant, changer le nom des status et ajouter une explication des status pour améliorer la compréhension de vos utilisateurs.",
"Vous pouvez supprimer un maximum de 2 status en les décochant, changer leur nom et ajouter une explication pour améliorer la compréhension de vos utilisateurs.",
"report.manage_permissions": "Gérer les permissions (optionnel)",
"report.manage_permissions.shared_report": "Partage des signalements",
"report.manage_permissions.shared_report_hint":
"Vous pouvez déterminer quels utilisateurs ont accès aux signalements du groupe. Choisissez si les signalements du groupe sont :",
"report.manage_permissions.shared_report.option": ({ option }) => {
switch (option) {
case "all":
return "Visibles de tout le monde";
case "restrained":
return "Visibles uniquement des membres du guichet";
case "personal":
return "Visibles uniquement de leur auteur et des gestionnaires du guichet";
default:
return "";
}
},
"report.manage_permissions.report_answers": "Réponses aux signalements",
"report.manage_permissions.authorize": "Autoriser",
"report.manage_permissions.authorize_hint":
"Tous les membres d'un groupe peuvent répondre aux signalements le concernant mais seuls les gestionnaires peuvent valider ces réponses et donc clore les signalements. En cochant la case suivante vous autorisez tous les membres de ce groupe à apporter des réponses sans validation.",
"grid.grids": "Emprises du guichet (optionnel)",
"grid.explain": (
<p>
Expand All @@ -145,6 +178,7 @@ export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"
export const ManageCommunityEnTranslations: Translations<"en">["ManageCommunity"] = {
title: ({ name }) => (name === undefined ? "Manage front office" : `Manage front office - ${name}`),
loading: undefined,
loading_tables: undefined,
fetch_failed: undefined,
back_to_list: undefined,
tab1: undefined,
Expand Down Expand Up @@ -204,8 +238,19 @@ export const ManageCommunityEnTranslations: Translations<"en">["ManageCommunity"
"layer.tab3": "Base maps",
"report.configure_themes": undefined,
"report.configure_themes.explain": undefined,
"report.configure_shared_themes": undefined,
"report.configure_shared_themes.explain": undefined,
"report.configure_statuses": undefined,
"report.configure_statuses.explain": undefined,
"report.manage_permissions": undefined,
"report.manage_permissions.shared_report": undefined,
"report.manage_permissions.shared_report_hint": undefined,
"report.manage_permissions.shared_report.option": ({ option }) => {
return `${option}`;
},
"report.manage_permissions.report_answers": undefined,
"report.manage_permissions.authorize": undefined,
"report.manage_permissions.authorize_hint": undefined,
"grid.grids": undefined,
"grid.explain": undefined,
};
9 changes: 5 additions & 4 deletions assets/espaceco/pages/communities/management/GridList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type GridListProps = {

const GridList: FC<GridListProps> = ({ grids = [], onChange }) => {
const [grid, setGrid] = useState<Grid | null>(null);
console.log(grid);

const [internal, setInternal] = useState<Grid[]>([...grids]);

Expand Down Expand Up @@ -40,13 +41,13 @@ const GridList: FC<GridListProps> = ({ grids = [], onChange }) => {
}, [internal, handleRemove]);

return (
<>
<div>
<div className={fr.cx("fr-grid-row")}>
<div className={fr.cx("fr-col-6")}>
<SearchGrids
label={""}
filters={{
searchBy: ["name", "title"],
fields: ["name", "title", "type", "extent"],
}}
onChange={(grid) => setGrid(grid)}
/>
Expand All @@ -57,8 +58,8 @@ const GridList: FC<GridListProps> = ({ grids = [], onChange }) => {
</div>
</div>
</div>
<Table className={fr.cx("fr-table--sm")} caption={null} data={data} />
</>
<Table className={fr.cx("fr-table--sm")} bordered fixed noCaption data={data} />
</div>
);
};

Expand Down
Loading

0 comments on commit 3b88458

Please sign in to comment.