From 2ac3a2bd8976b78ff2fd92efb9ab474ca6d5b36d Mon Sep 17 00:00:00 2001 From: SarahBellaha Date: Thu, 21 Dec 2023 17:33:23 +0100 Subject: [PATCH] front: search op with ci - ch code --- front/public/locales/en/map-search.json | 38 +++--- front/public/locales/fr/map-search.json | 38 +++--- front/src/common/BootstrapSNCF/InputSNCF.tsx | 114 +++++++++--------- .../common/Map/Search/MapSearchStation.tsx | 64 +++++----- 4 files changed, 131 insertions(+), 123 deletions(-) diff --git a/front/public/locales/en/map-search.json b/front/public/locales/en/map-search.json index 749a09080f3..8ed9a5c3e3c 100644 --- a/front/public/locales/en/map-search.json +++ b/front/public/locales/en/map-search.json @@ -1,34 +1,34 @@ { + "all": "All", + "aspects": "States", + "errorMessages": { + "unableToSearchSignal": "Signal search impossible" + }, + "labelbvonly": "BV only", + "line": "Line", "linecode": "Line code", "name": "Name", + "noAspectSelected": "No state selected", "noresult": "No results", + "pk": "PK", + "placeholderchcode": "CH code", "placeholderline": "Line name or number", + "placeholdername": "Name, label, CI code", "placeholdersignal": "Signal name", - "placeholdername": "Name, label", - "placeholderchcode": "CH code", - "labelbvonly": "BV only", - "pk": "PK", - "resultsCount_zero": "No results", + "reset": "Reset", "resultsCount_one": "1 result", "resultsCount_other": "{{ count }} results", + "resultsCount_zero": "No results", "search": "Search", "signal": "Signal", "signalbox": "Switchbox", "station": "Station", - "trackname": "Track", - "type": "Type", - "line": "Line", - "reset": "Reset", - "aspects": "States", - "noAspectSelected": "No state selected", - "signalSystem": "Signalling system", - "errorMessages": { - "unableToSearchSignal": "Signal search impossible" - }, - "all": "All", "signalSettings": { - "Nf": "Not crossable", "distant": "Far", - "is_430": "430" - } + "is_430": "430", + "Nf": "Not crossable" + }, + "signalSystem": "Signalling system", + "trackname": "Track", + "type": "Type" } diff --git a/front/public/locales/fr/map-search.json b/front/public/locales/fr/map-search.json index d0be610c2e9..5725c733be5 100644 --- a/front/public/locales/fr/map-search.json +++ b/front/public/locales/fr/map-search.json @@ -1,34 +1,34 @@ { + "all": "Tous", + "aspects": "Aspects", + "errorMessages": { + "unableToSearchSignal": "Recherche du signal impossible" + }, + "labelbvonly": "BV uniquement", + "line": "Ligne", "linecode": "Code ligne", "name": "Nom", + "noAspectSelected": "Aucun aspect sélectionné", "noresult": "Aucun résultat", + "pk": "PK", + "placeholderchcode": "Code CH", "placeholderline": "Nom ou numéro de ligne", + "placeholdername": "Nom, appelation, libellé, code CI", "placeholdersignal": "Nom du signal", - "placeholdername": "Nom, appelation, libellé", - "placeholderchcode": "Code CH", - "labelbvonly": "BV uniquement", - "pk": "PK", - "resultsCount_zero": "Aucun résultat", + "reset": "Réinitialiser", "resultsCount_one": "1 résultat", "resultsCount_other": "{{ count }} résultats", + "resultsCount_zero": "Aucun résultat", "search": "Rechercher", "signal": "Signal", "signalbox": "Poste", "station": "Gare", - "trackname": "Voie", - "type": "Type", - "line": "Ligne", - "reset": "Réinitialiser", - "aspects": "Aspects", - "noAspectSelected": "Aucun aspect sélectionné", - "signalSystem": "Système de signalisation", - "errorMessages": { - "unableToSearchSignal": "Recherche du signal impossible" - }, - "all": "Tous", "signalSettings": { - "Nf": "Non franchissable", "distant": "Distant", - "is_430": "430" - } + "is_430": "430", + "Nf": "Non franchissable" + }, + "signalSystem": "Système de signalisation", + "trackname": "Voie", + "type": "Type" } diff --git a/front/src/common/BootstrapSNCF/InputSNCF.tsx b/front/src/common/BootstrapSNCF/InputSNCF.tsx index 43caea358d7..b98c8b17213 100644 --- a/front/src/common/BootstrapSNCF/InputSNCF.tsx +++ b/front/src/common/BootstrapSNCF/InputSNCF.tsx @@ -1,4 +1,6 @@ +/* eslint-disable jsx-a11y/no-autofocus */ import React, { InputHTMLAttributes, ReactNode } from 'react'; +import cx from 'classnames'; export type InputSNCFProps = { id: string; @@ -6,6 +8,7 @@ export type InputSNCFProps = { name?: string; label?: JSX.Element | string; placeholder?: string; + title?: string; onChange?: InputHTMLAttributes['onChange']; value?: string | number; readonly?: boolean; @@ -39,32 +42,34 @@ export type InputSNCFProps = { condensed?: boolean; textRight?: boolean; disabled?: boolean; + ref?: React.MutableRefObject; }; const InputSNCF = ({ // Basic input props id, type, - name = undefined, - label = undefined, - placeholder = undefined, - onChange = undefined, - value = undefined, + name, + label, + placeholder, + title, + onChange, + value, readonly = false, inputProps = {}, - list = undefined, + list, // Error handling isInvalid = false, - errorMsg = undefined, + errorMsg, // Clear button clearButton = false, - onClear = undefined, + onClear, // Options for the appened icon - appendOptions = undefined, + appendOptions, // Styling props - unit = undefined, - min = undefined, - max = undefined, + unit, + min, + max, sm = false, whiteBG = false, noMargin = false, @@ -75,33 +80,19 @@ const InputSNCF = ({ condensed = false, textRight = false, disabled = false, + ref = undefined, }: InputSNCFProps): JSX.Element => { // Build custom classes - const formSize = sm ? 'form-control-sm' : ''; - const readOnlyFlag = readonly ? 'readonly' : ''; - const backgroundColor = whiteBG ? 'bg-white' : ''; - const clearOption = clearButton ? 'clear-option' : ''; - const flex = isFlex ? 'd-flex align-items-center' : ''; - const condensedIcon = condensed ? 'condensed-icon' : ''; - const condensedInput = condensed ? 'px-2' : ''; const textAlignmentClass = textRight ? 'right-alignment' : 'left-alignment'; - // Test and adapt display if entry is invalid - let invalidClass = ''; - let invalidMsg: JSX.Element | null = null; - if (isInvalid) { - invalidClass = 'is-invalid'; - invalidMsg =
{errorMsg}
; - } - // Appends a icon button right next to the input field + // Appends an icon button right next to the input field const appendButton = (small: boolean) => { - const newFormSize = small ? 'btn-sm' : ''; if (appendOptions) { return (