Skip to content

Commit c78c570

Browse files
authored
Fix grouped modifications search (#3436)
Update the contents of the placeholder and the label for the modifications search and nodes search's search bar
1 parent 9062105 commit c78c570

File tree

4 files changed

+24
-33
lines changed

4 files changed

+24
-33
lines changed

src/components/graph/menus/root-network/root-network-panel-search.tsx

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ interface RootNetworkSearchPanelProps {
3030
}
3131

3232
function getModificationResultsCount(results: ModificationsSearchResult[]): number {
33-
return results.reduce((sum, node) => {
34-
const countForNode = node.modifications.reduce((innerSum, modif) => {
35-
return innerSum + modif.impactedEquipmentIds.length;
36-
}, 0);
37-
return sum + countForNode;
38-
}, 0);
33+
return results.reduce((sum, r) => sum + r.modifications.length, 0);
3934
}
4035

4136
function getNodeResultsCount(results: string[]): number {
@@ -132,11 +127,14 @@ const RootNetworkSearchPanel: React.FC<RootNetworkSearchPanelProps> = ({ setIsSe
132127
<Box sx={styles.searchField}>
133128
<SearchBar
134129
placeholder={intl.formatMessage({
135-
id: isNodeTab(tabValue)
136-
? 'rootNetwork.searchPlaceholder.nodes'
137-
: 'rootNetwork.searchPlaceholder.modifications',
130+
id: 'searchPlaceholder',
138131
})}
139132
value={searchTerm}
133+
label={intl.formatMessage({
134+
id: isNodeTab(tabValue)
135+
? 'rootNetwork.searchLabel.nodes'
136+
: 'rootNetwork.searchLabel.modifications',
137+
})}
140138
onChange={handleOnChange}
141139
onClear={leaveSearch}
142140
/>
@@ -149,21 +147,14 @@ const RootNetworkSearchPanel: React.FC<RootNetworkSearchPanelProps> = ({ setIsSe
149147
)}
150148
{showResultsCount && (
151149
<Typography variant="body2" sx={{ mt: 1, color: 'gray' }}>
152-
{isNodeTab(tabValue) ? (
153-
<FormattedMessage
154-
id="rootNetwork.nodeResults"
155-
values={{
156-
count: getNodeResultsCount(nodesSearch.results),
157-
}}
158-
/>
159-
) : (
160-
<FormattedMessage
161-
id="rootNetwork.modificationResults"
162-
values={{
163-
count: getModificationResultsCount(modificationsSearch.results),
164-
}}
165-
/>
166-
)}
150+
<FormattedMessage
151+
id="rootNetwork.results"
152+
values={{
153+
count: isNodeTab(tabValue)
154+
? getNodeResultsCount(nodesSearch.results)
155+
: getModificationResultsCount(modificationsSearch.results),
156+
}}
157+
/>
167158
</Typography>
168159
)}
169160

src/components/graph/menus/root-network/root-network-search-bar.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,20 @@ import React from 'react';
1313
interface SearchBarProps {
1414
readonly placeholder: string;
1515
readonly value: string;
16+
readonly label?: string;
1617
readonly onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
1718
readonly onClear: () => void;
1819
}
1920

20-
export default function SearchBar({ placeholder, value, onChange, onClear }: SearchBarProps) {
21+
export default function SearchBar({ placeholder, value, label, onChange, onClear }: SearchBarProps) {
2122
return (
2223
<>
2324
<TextField
2425
fullWidth
2526
variant="outlined"
2627
placeholder={placeholder}
2728
value={value}
29+
label={label}
2830
onChange={onChange}
2931
size="small"
3032
InputProps={{

src/translations/en.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1446,12 +1446,11 @@
14461446
"updateRootNetworksError": "An error occurred while updating the root network",
14471447
"visibleRootNetwork": "Visible network : ",
14481448
"rootNetwork.modificationsInfos": "Only modifications in built nodes and their parent nodes will appear in the results.",
1449-
"rootNetwork.searchPlaceholder.modifications": "Search for a modified equipment",
1450-
"rootNetwork.searchPlaceholder.nodes": "Search for a node",
1449+
"rootNetwork.searchLabel.modifications": "Search equipment",
1450+
"rootNetwork.searchLabel.nodes": "Search node",
14511451
"rootNetwork.modificationTab": "Modifications",
14521452
"rootNetwork.nodeTab": "Nodes",
1453-
"rootNetwork.nodeResults": "{count, plural, =0 {No result} =1 {# result} other {# results}}",
1454-
"rootNetwork.modificationResults": "{count, plural, =0 {No equipment found} =1 {# equipment found} other {# equipments found}}",
1453+
"rootNetwork.results": "{count, plural, =0 {No result} =1 {# result} other {# results}}",
14551454
"rootNetwork.loading": "Loading...",
14561455
"rootNetwork.originalNotFound": "The original case was not found",
14571456
"rootNetwork.unknownPath": "<Unknown>",

src/translations/fr.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1448,12 +1448,11 @@
14481448
"importCaseFailure": "Impossible d'importer la situation",
14491449
"modificationActivationByRootNetworkError": "Une erreur est survenue lors de l'activation / désactivation de la modification par réseau racine",
14501450
"rootNetwork.modificationsInfos": "Seules les modifications dans les nœuds réalisés et leurs nœuds parents apparaitront dans les résultats.",
1451-
"rootNetwork.searchPlaceholder.modifications": "Rechercher un ouvrage modifié…",
1452-
"rootNetwork.searchPlaceholder.nodes": "Rechercher un nœud...",
1451+
"rootNetwork.searchLabel.modifications": "Rechercher un ouvrage",
1452+
"rootNetwork.searchLabel.nodes": "Rechercher un nœud",
14531453
"rootNetwork.modificationTab": "Modifications",
14541454
"rootNetwork.nodeTab": "Nœuds",
1455-
"rootNetwork.nodeResults": "{count, plural, =0 {Aucun résultat} =1 {# résultat} other {# résultats}}",
1456-
"rootNetwork.modificationResults": "{count, plural, =0 {Aucun ouvrage trouvé} =1 {# ouvrage trouvé} other {# ouvrages trouvés}}",
1455+
"rootNetwork.results": "{count, plural, =0 {Aucun résultat} =1 {# résultat} other {# résultats}}",
14571456
"rootNetwork.loading": "Chargement...",
14581457
"rootNetwork.originalNotFound": "La situation d'origine est introuvable",
14591458
"rootNetwork.unknownPath": "<Inconnu>",

0 commit comments

Comments
 (0)