Skip to content

Commit c426304

Browse files
authored
Merge pull request #1006 from WildMeOrg/header_quick_search_patch
a few minor changes regarding search result display
2 parents 5b1695e + bbce2a5 commit c426304

File tree

7 files changed

+108
-115
lines changed

7 files changed

+108
-115
lines changed

frontend/src/components/header/HeaderQuickSearch.jsx

Lines changed: 54 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1-
import React, { useState, useContext } from "react";
1+
import React, { useState } from "react";
22
import { Dropdown, FormControl, Spinner } from "react-bootstrap";
3-
import MainButton from "../MainButton";
43
import { FormattedMessage } from "react-intl";
5-
import ThemeColorContext from "../../ThemeColorProvider";
64
import usePostHeaderQuickSearch from "../../models/usePostHeaderQuickSearch";
75

86
export default function HeaderQuickSearch() {
97
const [search, setSearch] = useState("");
108
const [showDropdown, setShowDropdown] = useState(false);
11-
const theme = useContext(ThemeColorContext);
129

1310
const { searchResults, loading } = usePostHeaderQuickSearch(search);
1411

@@ -17,7 +14,7 @@ export default function HeaderQuickSearch() {
1714
};
1815

1916
const handleClearSearch = () => {
20-
setSearch(""); //
17+
setSearch("");
2118
setShowDropdown(false);
2219
};
2320

@@ -55,7 +52,11 @@ export default function HeaderQuickSearch() {
5552
}}
5653
onClick={handleClearSearch}
5754
>
58-
<i className="bi bi-x"></i>
55+
{search ? (
56+
<i className="bi bi-x"></i>
57+
) : (
58+
<i className="bi bi-search"></i>
59+
)}
5960
</button>
6061
</div>
6162

@@ -87,62 +88,58 @@ export default function HeaderQuickSearch() {
8788
</Dropdown.Item>
8889
)}
8990
{!loading &&
90-
searchResults.map((result, index) => (
91-
<React.Fragment key={index}>
92-
<Dropdown.Item
93-
key={index}
94-
as="button"
95-
target="_blank"
96-
rel="noopener noreferrer"
97-
onMouseDown={(e) => {
98-
e.preventDefault();
99-
window.open(`/individuals.jsp?id=${result.id}`);
100-
}}
101-
>
102-
<div className="d-flex flex-row justify-content-between">
91+
searchResults.map((result, index) => {
92+
const context = result?.id
93+
?.toLowerCase()
94+
.includes(search.toLowerCase())
95+
? "SYSTEM_ID"
96+
: "FILTER_NAME";
97+
98+
let value = result.id;
99+
100+
if (context === "SYSTEM_ID") {
101+
value = result.id;
102+
} else {
103+
value =
104+
result.names.find((name) =>
105+
name.toLowerCase().includes(search.toLowerCase()),
106+
) || result.names.join(" | ");
107+
}
108+
109+
return (
110+
<React.Fragment key={index}>
111+
<Dropdown.Item
112+
key={index}
113+
as="button"
114+
target="_blank"
115+
rel="noopener noreferrer"
116+
onMouseDown={(e) => {
117+
e.preventDefault();
118+
window.open(`/individuals.jsp?id=${result.id}`);
119+
}}
120+
>
103121
<div
104-
className="individual-name"
122+
className="d-flex flex-row justify-content-between"
105123
style={{
106-
width: "180px",
107-
fontSize: "0.8rem",
108-
overflow: "hidden",
124+
height: "40px",
109125
}}
110126
>
111-
<div>{search}</div>
112-
<div>{result.taxonomy}</div>
127+
<div
128+
className="individual-name w-100"
129+
style={{
130+
fontSize: "0.8rem",
131+
overflow: "hidden",
132+
}}
133+
>
134+
<div>{value}</div>
135+
<div>{result.taxonomy}</div>
136+
</div>
113137
</div>
114-
<MainButton
115-
noArrow={true}
116-
style={{
117-
width: "80px",
118-
height: "30px",
119-
color: "white",
120-
fontSize: "0.8rem",
121-
marginRight: 0,
122-
}}
123-
backgroundColor={theme.primaryColors.primary500}
124-
>
125-
<FormattedMessage
126-
id={
127-
result?.id
128-
?.toLowerCase()
129-
.includes(search.toLowerCase())
130-
? "SYSTEM_ID"
131-
: result?.names?.some((name) =>
132-
name
133-
.toLowerCase()
134-
.includes(search.toLowerCase()),
135-
)
136-
? "FILTER_NAME"
137-
: "UNKNOWN"
138-
}
139-
/>
140-
</MainButton>
141-
</div>
142-
{index < searchResults.length - 1 && <Dropdown.Divider />}
143-
</Dropdown.Item>
144-
</React.Fragment>
145-
))}
138+
{index < searchResults.length - 1 && <Dropdown.Divider />}
139+
</Dropdown.Item>
140+
</React.Fragment>
141+
);
142+
})}
146143
</Dropdown.Menu>
147144
</Dropdown>
148145
</div>

src/main/resources/bundles/de/header.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@ sessionModalContent = Ihre Sitzung l\u00E4uft in K\u00FCrze ab.
103103
sessionLoginButton = Anmelden
104104
sessionLoginModalContent = Sie wurden vom System abgemeldet.
105105

106-
systemId = System-ID
106+
systemId = System ID
107107
Name = Name
108108
unknown = Unbekannt
109109
loading = Lade...
110110
noMatchResults = Keine \u00DCbereinstimmungsergebnisse
111111
errorOccurred = Fehler aufgetreten
112-
searchResultDisplay = Suchergebnisanzeige
112+
searchResultDisplay = Deine Suchergebnisse werden hier angezeigt.
113113
searchIndividuals = Individuen suchen

src/main/resources/bundles/en/header.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,12 @@ sessionLoginButton = Log in
104104
sessionLoginModalContent = You've been logged out of the system.
105105

106106

107-
systemId = System-ID
107+
systemId = System ID
108108
Name = Name
109109
unknown = Unknown
110110
loading = Loading...
111111
noMatchResults = No matching results
112112
errorOccurred = An error occurred
113-
searchResultDisplay = Search Result Display
113+
searchResultDisplay = Your search results will appear here
114114
searchIndividuals = Search Individuals
115115

src/main/resources/bundles/es/header.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@ unknown = Desconocido
109109
loading = Cargando...
110110
noMatchResults = No hay resultados coincidentes
111111
errorOccurred = Se ha producido un error
112-
searchResultDisplay = Mostrar resultados de b\u00fasqueda
112+
searchResultDisplay = Tus resultados de b\u00FAsqueda aparecer\u00E1n aqu\u00ED.
113113
searchIndividuals = Buscar individuos

src/main/resources/bundles/it/header.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,5 @@ unknown = Sconosciuto
109109
loading = Caricamento...
110110
noMatchResults = Nessun risultato corrispondente
111111
errorOccurred = Si \u00E8 verificato un errore
112-
searchResultDisplay = Visualizzazione dei risultati della ricerca
112+
searchResultDisplay = I tuoi risultati di ricerca appariranno qui
113113
searchIndividuals = Cerca individui

src/main/webapp/css/header.css

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
height: 40px;
155155
display: flex;
156156
align-items: center;
157-
margin-left: 35px;
157+
margin-left: 10px;
158158
}
159159

160160
.profile-wrapper:hover .dropdown-menu {
@@ -186,7 +186,7 @@
186186
/* width: 250px; */
187187
/* height: 100%; */
188188
max-height: 60px;
189-
margin-right: 60px;
189+
margin-right: 20px;
190190
font-size: 24px;
191191
display: flex;
192192
align-items: center;
@@ -196,6 +196,7 @@
196196
}
197197

198198
.nav-brand {
199+
flex-shrink: 0;
199200
width: 100px;
200201
height: 50px;
201202
display: block !important;
@@ -208,7 +209,7 @@
208209
}
209210

210211
.search-and-secondary-wrapper {
211-
margin-left: 50px;
212+
margin-left: 30px;
212213
margin-bottom: 0 !important;
213214
display: flex;
214215
flex-direction: row !important;
@@ -262,15 +263,12 @@
262263
.site-name {
263264
color: white;
264265
font-size: 1.5em;
265-
/* margin-left: 10px; */
266266
}
267267

268268
.navbar-header {
269269
display: flex;
270-
margin-left: auto;
271270
align-items: center;
272271
justify-content: space-between;
273-
/* width: 80%; */
274272
}
275273

276274
/* .nav-brand img {
@@ -300,11 +298,6 @@
300298

301299
/* Responsive adjustments */
302300
@media (max-width: 991px) {
303-
304-
.site-name {
305-
display: none !important;
306-
}
307-
308301
.navbar-toggle {
309302
display: block;
310303
margin-left: 20% !important;
@@ -390,7 +383,7 @@
390383
}
391384

392385
.site-name {
393-
margin-right: 10px;
386+
margin-right: 30px;
394387
}
395388

396389
}
@@ -447,7 +440,7 @@
447440
border-radius: 20px;
448441
color: white;
449442
height: 33px;
450-
width: 150px;
443+
width: 160px;
451444
position: relative;
452445
display: flex;
453446
}
@@ -456,9 +449,7 @@
456449
display: flex;
457450
justify-content: center;
458451
align-items: center;
459-
margin: 0 10px;
460452
position: relative;
461-
width: 200px;
462453
}
463454

464455
.quick-search-result{
@@ -485,12 +476,3 @@
485476
color: black;
486477
height: 25px;
487478
}
488-
489-
.quick-search-result-context{
490-
height: 25px; width: 100px;
491-
background-color: #00ACCE;
492-
border-radius: 4px;
493-
display: flex;
494-
align-items: center;
495-
justify-content: center
496-
}

0 commit comments

Comments
 (0)