Skip to content

Commit

Permalink
maquette édition d'un guichet suite
Browse files Browse the repository at this point in the history
  • Loading branch information
pprev94 authored and ocruze committed Aug 23, 2024
1 parent de812bc commit 5d3413d
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 15 deletions.
10 changes: 4 additions & 6 deletions assets/components/Utils/ZoomRange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,11 @@ const ZoomRange: FC<ZoomRangeProps> = (props) => {

useEffect(() => {
if (leftMapTargetRef.current) {
const minValue = olDefaults.zoom_levels.TOP < min ? min : olDefaults.zoom_levels.TOP;
leftMapRef.current = createMap(leftMapTargetRef.current, minValue);
leftMapRef.current = createMap(leftMapTargetRef.current, Math.max(min, olDefaults.zoom_levels.TOP));
}

if (rightMapTargetRef.current) {
const maxValue = olDefaults.zoom_levels.BOTTOM > max ? max : olDefaults.zoom_levels.BOTTOM;
rightMapRef.current = createMap(rightMapTargetRef.current, maxValue);
rightMapRef.current = createMap(rightMapTargetRef.current, Math.min(max, olDefaults.zoom_levels.BOTTOM));
}

return () => {
Expand Down Expand Up @@ -142,15 +140,15 @@ const ZoomRange: FC<ZoomRangeProps> = (props) => {
{
value: values[0],
onChange: (e) => {
const v = values;
const v = [...values];
v[0] = Number(e.currentTarget.value);
onChange(v);
},
},
{
value: values[1],
onChange: (e) => {
const v = values;
const v = [...values];
v[1] = Number(e.currentTarget.value);
onChange(v);
},
Expand Down
17 changes: 10 additions & 7 deletions assets/espaceco/pages/communities/ManageCommunity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import api from "../../api";
import Description from "./management/Description";
import Grid from "./management/Grid";
import ZoomAndCentering from "./management/ZoomAndCentering";
import Layer from "./management/Layer";

type ManageCommunityProps = {
communityId: number;
Expand Down Expand Up @@ -57,13 +58,13 @@ const ManageCommunity: FC<ManageCommunityProps> = ({ communityId }) => {
<Tabs
selectedTabId={selectedTabId}
tabs={[
{ tabId: "tab1", label: t("tab1") },
{ tabId: "tab2", label: t("tab2") },
{ tabId: "tab3", label: t("tab3") },
{ tabId: "tab4", label: t("tab4") },
{ tabId: "tab5", label: t("tab5") },
{ tabId: "tab6", label: t("tab6") },
{ tabId: "tab7", label: t("tab7") },
{ tabId: "tab1", label: t("tab1") }, // Description
{ tabId: "tab2", label: t("tab2") }, // Bases de données
{ tabId: "tab3", label: t("tab3") }, // Zoom, centrage
{ tabId: "tab4", label: t("tab4") }, // Couches de la carte
{ tabId: "tab5", label: t("tab5") }, // Outils
{ tabId: "tab6", label: t("tab6") }, // Signalements
{ tabId: "tab7", label: t("tab7") }, // Emprises
]}
onTabChange={setSelectedTabId}
>
Expand All @@ -74,6 +75,8 @@ const ManageCommunity: FC<ManageCommunityProps> = ({ communityId }) => {
return <Description community={communityQuery.data} />;
case "tab3":
return <ZoomAndCentering community={communityQuery.data} />;
case "tab4":
return <Layer />;
case "tab7":
return <Grid grids={communityQuery.data?.grids ?? []} />; // TODO
default:
Expand Down
18 changes: 18 additions & 0 deletions assets/espaceco/pages/communities/ManageCommunityTr.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const { i18n } = declareComponentKeys<
| "tab5"
| "tab6"
| "tab7"
| "desc.tab.title"
| "desc.name"
| "desc.hint_name"
| "desc.description"
Expand All @@ -35,6 +36,7 @@ export const { i18n } = declareComponentKeys<
| "modal.document.name"
| "modal.document.file_hint"
| "zoom.consistant_error"
| "zoom.tab.title"
| "zoom.position"
| "zoom.position_hint"
| "zoom.zoom_range"
Expand All @@ -49,6 +51,10 @@ export const { i18n } = declareComponentKeys<
| "zoom.xmax"
| "zoom.ymin"
| "zoom.ymax"
| "layer.tab.title"
| "layer.tabl"
| "layer.tab2"
| "layer.tab3"
| "grid.grids"
| { K: "grid.explain"; R: JSX.Element }
>()("ManageCommunity");
Expand All @@ -65,6 +71,7 @@ export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"
tab5: "Outils",
tab6: "Signalements",
tab7: "Emprises",
"desc.tab.title": "Décrire le guichet",
"desc.name": "Nom du guichet",
"desc.hint_name": "Donnez un nom clair et compréhensible",
"desc.description": "Description",
Expand Down Expand Up @@ -94,6 +101,7 @@ export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"
"modal.document.name": "Titre",
"modal.document.file_hint": "Taille maximale : 5 Mo.",
"zoom.consistant_error": "Emprise et position ne sont pas cohérents",
"zoom.tab.title": "Définir l’état initial de la carte à l’ouverture du guichet",
"zoom.position": "Position",
"zoom.position_hint": "Fixer la position et définissez le niveau de zoom (utilisez votre souris ou la barre de recherche ci-dessous",
"zoom.zoom_range": "Gérer les niveaux de zoom minimum et maximum permis (optionnel)",
Expand All @@ -110,6 +118,10 @@ export const ManageCommunityFrTranslations: Translations<"fr">["ManageCommunity"
"zoom.xmax": "X max",
"zoom.ymin": "Y min",
"zoom.ymax": "Y max",
"layer.tab.title": "Gérer les couches de la carte",
"layer.tabl": "Mes données",
"layer.tab2": "Données de la géoplateforme",
"layer.tab3": "Fonds de carte",
"grid.grids": "Emprises du guichet (optionnel)",
"grid.explain": (
<p>
Expand All @@ -132,6 +144,7 @@ export const ManageCommunityEnTranslations: Translations<"en">["ManageCommunity"
tab5: undefined,
tab6: undefined,
tab7: undefined,
"desc.tab.title": undefined,
"desc.name": undefined,
"desc.hint_name": undefined,
"desc.description": undefined,
Expand Down Expand Up @@ -160,6 +173,7 @@ export const ManageCommunityEnTranslations: Translations<"en">["ManageCommunity"
"modal.document.name": "Title",
"modal.document.file_hint": "Maximum file size : 5 Mo.",
"zoom.consistant_error": undefined,
"zoom.tab.title": undefined,
"zoom.position": "Position",
"zoom.position_hint": undefined,
"zoom.zoom_range": undefined,
Expand All @@ -174,6 +188,10 @@ export const ManageCommunityEnTranslations: Translations<"en">["ManageCommunity"
"zoom.xmax": "X max",
"zoom.ymin": "Y min",
"zoom.ymax": "Y max",
"layer.tab.title": undefined,
"layer.tabl": "My datas",
"layer.tab2": "Geoplateforme datas",
"layer.tab3": "Base maps",
"grid.grids": undefined,
"grid.explain": undefined,
};
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const Description: FC<DescriptionProps> = ({ community }) => {

return (
<>
<h2>{t("tab1")}</h2>
<h2>{t("desc.tab.title")}</h2>
<div>
<p>{tCommon("mandatory_fields")}</p>
<Input
Expand Down
1 change: 0 additions & 1 deletion assets/espaceco/pages/communities/management/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const Grid: FC<GridProps> = ({ grids }) => {
const { t } = useTranslation("ManageCommunity");
return (
<>
<h2>{t("tab7")}</h2>
<h3>{t("grid.grids")}</h3>
{t("grid.explain")}
<GridList
Expand Down
71 changes: 71 additions & 0 deletions assets/espaceco/pages/communities/management/Layer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { fr } from "@codegouvfr/react-dsfr";
import Tabs from "@codegouvfr/react-dsfr/Tabs";
import { Options, optionsFromCapabilities } from "ol/source/WMTS";
import { FC, useMemo, useState } from "react";
import useCapabilities from "../../../../hooks/useCapabilities";
import { useTranslation } from "../../../../i18n/i18n";

const baseMaps = ["GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2", "GEOGRAPHICALGRIDSYSTEMS.MAPS.BDUNI.J1", "ORTHOIMAGERY.ORTHOPHOTOS", "CADASTRALPARCELS.PARCELS"];

const Layer: FC = () => {
const { t } = useTranslation("ManageCommunity");
const { data: capabilities } = useCapabilities();

/* const cbBaseMapsOptions = useMemo<ReactNode[]>(() => {
if (!capabilities) return [];
Array.from(baseMaps, (m) => <div key={m} className={fr.cx("fr-grid-row", "fr-grid-row--middle")}></div>);
}, [capabilities]); */

const cbBaseMapsOptions = useMemo<Options[]>(() => {
if (!capabilities) return [];

const options: Options[] = [];
baseMaps.forEach((m) => {
const wmtsOptions = optionsFromCapabilities(capabilities, { layer: m, style: "Légende générique" });
if (wmtsOptions) {
options.push(wmtsOptions);
}
});
return options;
}, [capabilities]);
console.log(cbBaseMapsOptions);

const [selectedTabId, setSelectedTabId] = useState("tab1");

return (
<>
<h2>{t("layer.tab.title")}</h2>
<div className={fr.cx("fr-grid-row")}>
<div className={fr.cx("fr-col-7")}>
<Tabs
selectedTabId={selectedTabId}
tabs={[
{ tabId: "my_datas", label: t("layer.tabl") },
{ tabId: "gp_datas", label: t("layer.tab2") },
{ tabId: "base_maps", label: t("layer.tab3") },
]}
onTabChange={setSelectedTabId}
>
<>
{(() => {
switch (selectedTabId) {
case "my_datas":
return <p>`Content of ${selectedTabId}`</p>;
case "gp_datas":
return <p>`Content of ${selectedTabId}`</p>;
case "base_maps":
return <p>`Content of ${selectedTabId}`</p>;
}
})()}
</>
</Tabs>
</div>
<div className={fr.cx("fr-col-5")} />
</div>
</>
);
};

export default Layer;
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const ZoomAndCentering: FC<ZoomAndCenteringProps> = ({ community }) => {
{consistent === false && (
<Alert severity="warning" title={tCommon("warning")} description={t("zoom.consistant_error")} className={fr.cx("fr-my-2w")} />
)}
<h2>{t("zoom.tab.title")}</h2>
<div className={fr.cx("fr-grid-row", "fr-grid-row--gutters")}>
<div className={fr.cx("fr-col-5")}>
<Search
Expand Down

0 comments on commit 5d3413d

Please sign in to comment.