Skip to content

Commit

Permalink
Merge branch 'main' into feat-newsletter
Browse files Browse the repository at this point in the history
  • Loading branch information
slafayIGN authored Nov 19, 2024
2 parents 1dba358 + 8a86eeb commit 993866e
Show file tree
Hide file tree
Showing 11 changed files with 407 additions and 393 deletions.
1 change: 1 addition & 0 deletions assets/components/Input/DatePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ const DatePicker = (props: DatePickerProps) => {
minDate={minDate}
onChange={(v) => {
if (v) onChange?.(v);
else onChange?.(undefined);
}}
/>
</LocalizationProvider>
Expand Down
25 changes: 16 additions & 9 deletions assets/data/md_resolutions.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
{
"Nationale": 1000000,
"Régionale": 250000,
"Départementale": 150000,
"Top 200": 200000,
"Top 100": 100000,
"Top 75": 75000,
"Top 25": 25000
}
[
200,
500,
1000,
2000,
5000,
10000,
25000,
50000,
100000,
250000,
500000,
1000000,
5000000,
10000000
]
23 changes: 9 additions & 14 deletions assets/entrepot/pages/service/metadatas/AdditionalInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { fr } from "@codegouvfr/react-dsfr";
import Input from "@codegouvfr/react-dsfr/Input";
import Select from "@codegouvfr/react-dsfr/Select";
import { Select as SelectNext } from "@codegouvfr/react-dsfr/SelectNext";
import { FC, useMemo } from "react";
import { Controller, UseFormReturn } from "react-hook-form";

import type { Pyramid, ServiceFormValuesBaseType, VectorDb } from "../../../../@types/app";
import AutocompleteSelect from "../../../../components/Input/AutocompleteSelect";
import ignProducts from "../../../../data/md_resolutions.json";
import resolutions from "../../../../data/md_resolutions.json";
import { getTranslation } from "../../../../i18n/i18n";
import { LanguageType, charsets, getLanguages } from "../../../../utils";

Expand Down Expand Up @@ -148,25 +149,19 @@ const AdditionalInfo: FC<AdditionalInfoProps> = ({ /*storedData, datastoreId,*/
defaultValue: fileType,
}}
/> */}
<Select
label={t("metadata.additionnal_infos_form.hint_spatial_resolution")}
<SelectNext
label={t("metadata.additionnal_infos_form.spatial_resolution")}
hint={t("metadata.additionnal_infos_form.hint_spatial_resolution")}
state={errors.resolution ? "error" : "default"}
stateRelatedMessage={errors?.resolution?.message?.toString()}
options={["", ...resolutions].map((res) => ({
value: res.toString(),
label: res === "" ? "Aucune" : `1:${res.toLocaleString()}`,
}))}
nativeSelectProps={{
...register("resolution"),
}}
>
<option value="">Aucune</option>
{Object.keys(ignProducts).map((product) => {
const text = `${product} (1/${ignProducts[product]})`;
return (
<option key={product} value={ignProducts[product]}>
{text}
</option>
);
})}
</Select>
/>
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const { i18n } = declareComponentKeys<
| "metadata.additionnal_infos_form.encoding"
| "metadata.additionnal_infos_form.hint_encoding"
| "metadata.additionnal_infos_form.spatial_resolution"
| "metadata.additionnal_infos_form.hint_spatial_resolution"
| { K: "metadata.additionnal_infos_form.hint_spatial_resolution"; R: JSX.Element }
>()("MetadatasForm");

export const MetadatasFormFrTranslations: Translations<"fr">["MetadatasForm"] = {
Expand Down Expand Up @@ -105,8 +105,14 @@ export const MetadatasFormFrTranslations: Translations<"fr">["MetadatasForm"] =
"Permet de décrire le système de coordonnées, pour une donnée géographique, il s’agit de son système de projection",
"metadata.additionnal_infos_form.encoding": "Encodage de la ressource",
"metadata.additionnal_infos_form.hint_encoding": "[TODO]",
"metadata.additionnal_infos_form.spatial_resolution": "Résolution indiquée en échelle (1/x)",
"metadata.additionnal_infos_form.hint_spatial_resolution": "Sélectionnez un produit (série) (optionnel)",
"metadata.additionnal_infos_form.spatial_resolution": "Résolution spatiale (optionnelle)",
"metadata.additionnal_infos_form.hint_spatial_resolution": (
<>
{"Échelle approximative à laquelle les données sont les plus pertinentes."}
<br />
{"Exemple : 25 000 si les données sont faites pour un affichage à l’échelle d'une carte topographique."}
</>
),
};

export const MetadatasFormEnTranslations: Translations<"en">["MetadatasForm"] = {
Expand Down Expand Up @@ -159,6 +165,6 @@ export const MetadatasFormEnTranslations: Translations<"en">["MetadatasForm"] =
"metadata.additionnal_infos_form.hint_projection": "Describe the coordinate system, for geographic data, this is its projection system",
"metadata.additionnal_infos_form.encoding": "Resource encoding",
"metadata.additionnal_infos_form.hint_encoding": "[TODO] Codification utilisée dans la ressource pour restituer les caractères",
"metadata.additionnal_infos_form.spatial_resolution": "Resolution indicated in scale (1/x)",
"metadata.additionnal_infos_form.hint_spatial_resolution": "Select a product (series)",
"metadata.additionnal_infos_form.spatial_resolution": "Spatial resolution (optional)",
"metadata.additionnal_infos_form.hint_spatial_resolution": undefined,
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ export const { i18n } = declareComponentKeys<

export const ValidationMetadatasFrTranslations: Translations<"fr">["ValidationMetadatas"] = {
"metadatas.technical_name_error": "Le nom technique est obligatoire",
"metadatas.technical_name_regex": "Le nom technique ne doit contenir que des lettres, chiffres, tirets (-), underscores (_), ou points (.)",
"metadatas.technical_name_regex":
"Le nom technique doit commencer par une lettre ou un underscore et ne doit contenir que des lettres, chiffres, tirets (-), underscores (_), ou points (.)",
"metadatas.technical_name_unicity_error": "Ce nom technique existe déjà",
"metadatas.public_name_error": "L’intitulé (nom public) est obligatoire",
"metadatas.description_error": "Un résumé est obligatoire",
Expand All @@ -60,7 +61,8 @@ export const ValidationMetadatasFrTranslations: Translations<"fr">["ValidationMe

export const ValidationMetadatasEnTranslations: Translations<"en">["ValidationMetadatas"] = {
"metadatas.technical_name_error": "Technical name is required",
"metadatas.technical_name_regex": "Technical name must contain only letters, numbers, hyphens (-), underscores (_), or dots (.)",
"metadatas.technical_name_regex":
"Technical name must start with a letter or an underscore and must contain only letters, numbers, hyphens (-), underscores (_), or dots (.)",
"metadatas.technical_name_unicity_error": "This technical name already exists",
"metadatas.public_name_error": "Title (public name) is required",
"metadatas.description_error": "A summary is required",
Expand Down
2 changes: 1 addition & 1 deletion assets/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const regex = {
datasheet_name: /^[\wÀ-ÿ\-._~!$&'()*+,;:@%\s]+$/g, // alphanumérique avec accents, certains caractères spéciaux, espaces blancs
// file_identifier: /^[\wÀ-ÿ\-._~!$&'()*+,;:@%]+$/g, // alphanumérique avec accents, certains caractères spéciaux
file_identifier: /^[\w-.]+$/g, // alphanumérique sans accents, certains caractères spéciaux
technical_name: /^[\w-.]+$/,
technical_name: /^[A-Za-z_][A-Za-z0-9_.-]*$/, // chaîne alphanumérique qui commence par une lettre ou un underscore et ne doit contenir que des lettres, chiffres, tirets (-), underscores (_), ou points (.)
email: /^[\w-.]+@([\w-]+\.)+[\w-]{2,}$/,
uuid: /^[A-F\d]{8}-[A-F\d]{4}-[A-F\d]{4}-[A-F\d]{4}-[A-F\d]{12}$/i,
};
Expand Down
Loading

0 comments on commit 993866e

Please sign in to comment.