diff --git a/front/public/locales/en/infraEditor.json b/front/public/locales/en/infraEditor.json index 594d6ec8404..fbb0e1626d2 100644 --- a/front/public/locales/en/infraEditor.json +++ b/front/public/locales/en/infraEditor.json @@ -582,6 +582,18 @@ } } }, + "TrackSectionSourceExtension": { + "properties": { + "name": { + "title": "Source", + "description": "Name of the source" + }, + "id": { + "title": "Source ID", + "description": "ID of the element within the source" + } + } + }, "TvmSystem": { "properties": { "next_signaling_systems": { diff --git a/front/public/locales/en/translation.json b/front/public/locales/en/translation.json index 474fc6fcce5..632fbe36c3e 100644 --- a/front/public/locales/en/translation.json +++ b/front/public/locales/en/translation.json @@ -394,6 +394,7 @@ "of-type": "of type", "selection": "{{count}} item selected", "selection_plural": "{{count}} items selected", + "sources": "Sources", "title": "Select", "unselect": "Deselect" }, diff --git a/front/public/locales/fr/infraEditor.json b/front/public/locales/fr/infraEditor.json index dd0e38479a1..8a12f627804 100644 --- a/front/public/locales/fr/infraEditor.json +++ b/front/public/locales/fr/infraEditor.json @@ -582,6 +582,18 @@ } } }, + "TrackSectionSourceExtension": { + "properties": { + "name": { + "title": "Source", + "description": "Nom de la source" + }, + "id": { + "title": "Source ID", + "description": "Identifiant de l'élément dans la source" + } + } + }, "TvmSystem": { "properties": { "next_signaling_systems": { diff --git a/front/public/locales/fr/translation.json b/front/public/locales/fr/translation.json index 212b88fa0ad..486c3488388 100644 --- a/front/public/locales/fr/translation.json +++ b/front/public/locales/fr/translation.json @@ -377,6 +377,7 @@ "of-type": "de type", "selection": "{{count}} élément sélectionné", "selection_plural": "{{count}} éléments sélectionnés", + "sources": "Sources", "title": "Sélection", "unselect": "Désélectionner" }, diff --git a/front/src/applications/editor/components/EntitySumUp.tsx b/front/src/applications/editor/components/EntitySumUp.tsx index a42a3a91cfd..b6e746ea48c 100644 --- a/front/src/applications/editor/components/EntitySumUp.tsx +++ b/front/src/applications/editor/components/EntitySumUp.tsx @@ -1,4 +1,4 @@ -import React, { type FC, useEffect, useState } from 'react'; +import React, { type FC, useEffect, useState, Fragment } from 'react'; import cx from 'classnames'; import type { TFunction } from 'i18next'; @@ -113,6 +113,7 @@ function getSumUpContent( let text = ''; const subtexts: (string | JSX.Element)[] = []; const classes = { ...DEFAULT_CLASSES, ...(classesOverride || {}) }; + const sources: string[] = []; switch (entity.objType) { case 'TrackSection': { @@ -125,6 +126,10 @@ function getSumUpContent( text = trackSection.properties.id; } if (attrs.line_name) subtexts.unshift(attrs.line_name); + const source = trackSection.properties.extensions?.source; + if (source) { + sources.push(`${source.name} ${source.id}`); + } break; } // @ts-expect-error: Here we only deal with the installation_type, the rest is handled with BufferStop and Detector. @@ -280,6 +285,14 @@ function getSumUpContent( {s} ))} + {sources.length > 0 && ( +
+ + {t(`Editor.tools.select-items.sources`)} + + {sources.join(', ')} +
+ )} ); } diff --git a/front/src/applications/editor/tools/trackEdition/components/TrackEditionLeftPanel.tsx b/front/src/applications/editor/tools/trackEdition/components/TrackEditionLeftPanel.tsx index fb5941624e7..20a6a555389 100644 --- a/front/src/applications/editor/tools/trackEdition/components/TrackEditionLeftPanel.tsx +++ b/front/src/applications/editor/tools/trackEdition/components/TrackEditionLeftPanel.tsx @@ -1,12 +1,17 @@ -import React, { useContext, useEffect, useRef } from 'react'; +import React, { useContext, useEffect, useRef, useMemo } from 'react'; import type { WidgetProps } from '@rjsf/utils'; +import { isNil, omit } from 'lodash'; import { useTranslation } from 'react-i18next'; import EditorForm from 'applications/editor/components/EditorForm'; import EntityError from 'applications/editor/components/EntityError'; import EditorContext from 'applications/editor/context'; -import { NEW_ENTITY_ID } from 'applications/editor/data/utils'; +import { + NEW_ENTITY_ID, + getJsonSchemaForLayer, + getLayerForObjectType, +} from 'applications/editor/data/utils'; import type { TrackEditionState, TrackSectionEntity, @@ -32,7 +37,7 @@ const TrackEditionLeftPanel: React.FC = () => { const dispatch = useAppDispatch(); const { t } = useTranslation(); const infraID = useInfraID(); - const { state, setState, isFormSubmited, setIsFormSubmited } = useContext( + const { state, setState, isFormSubmited, setIsFormSubmited, editorState } = useContext( EditorContext ) as ExtendedEditorContextType; const submitBtnRef = useRef(null); @@ -49,14 +54,40 @@ const TrackEditionLeftPanel: React.FC = () => { } }, [isFormSubmited]); + const schema = useMemo( + () => + getJsonSchemaForLayer( + editorState.editorSchema, + getLayerForObjectType(editorState.editorSchema, track.objType) || '' + ), + [editorState.editorSchema, track.objType] + ); + return ( <> { // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/front/src/applications/editor/tools/trackEdition/types.ts b/front/src/applications/editor/tools/trackEdition/types.ts index f7c42e68f20..90ca4bc7c40 100644 --- a/front/src/applications/editor/tools/trackEdition/types.ts +++ b/front/src/applications/editor/tools/trackEdition/types.ts @@ -21,6 +21,10 @@ export type TrackSectionEntity = EditorEntity< track_name?: string; track_number?: number; }; + source?: { + id: string; + name: string; + }; }; } > & {