Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intégration de l'Espace collaboratif #491

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
"request": "launch",
"port": 9003
},
{
"name": "Listen for Xdebug 2 (Legacy)",
"type": "php",
"request": "launch",
"port": 9000
},
{
"name": "Listen for Xdebug (in docker)",
"type": "php",
Expand Down
Binary file added Topic_category_cartesgouv.xlsx
Binary file not shown.
77 changes: 77 additions & 0 deletions assets/@types/app_espaceco.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { GridDTO, ReportStatusesDTO, SharedGeorem, SharedThemesDTO, ThemeDTO, UserDTO } from "./espaceco";

export type GetResponse<T> = {
content: T[];
totalPages: number;
Expand All @@ -7,3 +9,78 @@ export type GetResponse<T> = {

export const arrCommunityListFilters = ["public", "iam_member", "affiliation"];
export type CommunityListFilter = (typeof arrCommunityListFilters)[number];

export type Address = {
country: string;
city: string;
x: number;
y: number;
zipcode: string;
street: string;
classification: number;
kind: string;
fulltext: string;
metropole: boolean;
};

export type Poi = {
country: string;
city: string;
x: number;
y: number;
zipcode: string;
zipcodes: string[];
poiType: string[];
street: string;
classification: number;
kind: string;
fulltext: string;
metropole: boolean;
};

export type SearchResult = {
status: string;
results: (Address | Poi)[];
};

export type SearchGridFilters = {
searchBy?: ("name" | "title")[];
fields?: ("name" | "title" | "type" | "extent" | "deleted")[];
adm?: boolean;
};

export type UserType = {
user_id: number;
username: string;
firstname: string | null;
surname: string | null;
};

export type Role = "pending" | "member" | "admin";
export type CommunityMember = UserType & {
grids: GridDTO[];
role: Role;
active: boolean;
date: string;
};

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

export type DescriptionFormType = {
name: string;
description?: string;
keywords?: string[];
};

const isUser = (v: UserDTO | string): v is UserDTO => {
return (v as UserDTO).username !== undefined;
};

export { isUser };
181 changes: 174 additions & 7 deletions assets/@types/espaceco.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,196 @@
import statuses from "../data/report_statuses.json";

export interface ConstraintsDTO {
minLength?: number;
maxLength?: number;
minValue?: string;
maxValue?: string;
pattern?: string;
}

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

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

export interface ThemeDTO {
theme: string;
database?: string;
table?: string;
attributes: AttributeDTO[];
help?: string;
global?: boolean;
}

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: object[];
attributes: ThemeDTO[];
default_comment: string | null;
position: string;
position: string | null;
zoom: number;
zoom_min: number | null;
zoom_max: number | null;
extent: number[] | null;
all_members_can_valid: boolean;
open_without_affiliation: boolean;
open_with_email?: string[];
offline_allowed: boolean;
shared_extractions: boolean;
/** @format date-time */
creation: string;
grids: Grids[];
logo_url: string;
grids: GridDTO[];
logo_url: string | null;
keywords?: string[];
documents?: DocumentDTO[];
report_statuses?: ReportStatusesDTO;
shared_themes?: SharedThemesDTO[];
}

export interface Grids {
name: string;
export interface UserDTO {
id: number;
username: string;
firstname?: string;
surname?: string;
}

export interface DocumentDTO {
id: number;
short_fileName: string;
mime_type: string;
description?: string;
title: string;
type: string;
size?: number;
width?: number;
height?: number;
date: string;
geometry?: string;
uri: string;
}
export interface GridDTO {
name: string;
title: string;
type: GridType;
deleted: boolean;
extent: number[];
}

export interface GridType {
name: string;
title: string;
}
export interface CommunityPatchDTO extends Partial<Omit<CommunityResponseDTO, "logo_url">> {
logo: File | null;
}

export interface PermissionResponseDTO {
id: number;
database: number;
table: number | null;
column: number | null;
level: "NONE" | "VIEW" | "EXPORT" | "EDIT" | "ADMIN";
}

export interface ColumnDTO {
table_id: number;
crs: string | null;
enum: object | string[] | null;
default_value: string | null;
read_only: boolean;
id: number;
type: string;
target_table: string | null;
target_entity: string | null;
name: string;
short_name: string;
title: string;
description: string | null;
min_length: number | null;
max_length: number | null;
nullable: boolean;
unique: boolean;
srid: number | null;
position: number;
min_value: string | null;
max_value: string | null;
pattern: string | null;
is3d: boolean;
constraint: object | null;
condition_field: string | null;
computed: boolean;
automatic: boolean;
custom_id: boolean;
formula: string | null;
json_schema: object | null;
jeux_attributs: object | null;
queryable: boolean;
required: boolean;
mime_types: string | null;
}

export interface TableResponseDTO {
database_id: number;
database: string;
database_versioning: boolean;
full_name: string;
id_name: string;
geometry_name: string;
min_zoom_level: number | null;
max_zoom_level: number | null;
tile_zoom_level: number | null;
read_only: boolean;
id: number;
name: string;
title: string;
description: string | null;
thematic_ids: string[] | null;
position: number;
wfs: string;
wfs_transactions: string;
columns: ColumnDTO[];
}

export { SharedGeoremOptions };
5 changes: 2 additions & 3 deletions assets/components/Input/AutocompleteSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { fr } from "@codegouvfr/react-dsfr";
import MuiDsfrThemeProvider from "@codegouvfr/react-dsfr/mui";
import { Autocomplete, AutocompleteFreeSoloValueMapping, AutocompleteValue, CreateFilterOptionsConfig, TextField, createFilterOptions } from "@mui/material";
import { CSSProperties, useId } from "react";
import { CSSProperties, ReactNode, useId } from "react";
import { ControllerRenderProps } from "react-hook-form";
import { symToStr } from "tsafe/symToStr";

interface AutocompleteSelectProps<T> {
id?: string;
label: string;
hintText: string;
hintText?: ReactNode;
state?: "default" | "error" | "success";
stateRelatedMessage?: string;
defaultValue?: T[];
Expand Down Expand Up @@ -76,7 +76,6 @@ const AutocompleteSelect = <T,>(props: AutocompleteSelectProps<T>) => {
{label}
{hintText && <span className="fr-hint-text">{hintText}</span>}
</label>

<Autocomplete
{...controllerField}
id={inputId}
Expand Down
Loading
Loading