Skip to content

Commit 36fc7ba

Browse files
committed
2927: Moved options to helper
1 parent 65a6eed commit 36fc7ba

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

src/components/slide/content/poster/poster-helper.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,41 @@ const getHeaders = () => {
8080
return headers;
8181
};
8282

83+
const getSingleSearchOptions = (t) => {
84+
return [
85+
{
86+
key: "singleSearchTypeOptions1",
87+
value: "title",
88+
title: t("single-search-type-title"),
89+
},
90+
{
91+
key: "singleSearchTypeOptions2",
92+
value: "url",
93+
title: t("single-search-type-url"),
94+
},
95+
{
96+
key: "singleSearchTypeOptions3",
97+
value: "organizations",
98+
title: t("single-search-type-organization"),
99+
},
100+
{
101+
key: "singleSearchTypeOptions4",
102+
value: "locations",
103+
title: t("single-search-type-location"),
104+
},
105+
{
106+
key: "singleSearchTypeOptions5",
107+
value: "tags",
108+
title: t("single-search-type-tag"),
109+
},
110+
];
111+
};
112+
83113
export {
84114
formatDate,
85115
capitalize,
86116
loadDropdownOptions,
87117
getHeaders,
88118
loadDropdownOptionsPromise,
119+
getSingleSearchOptions,
89120
};

src/components/slide/content/poster/poster-single.jsx

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import FormCheckbox from "../../../util/forms/form-checkbox";
1010
import {
1111
formatDate,
1212
getHeaders,
13+
getSingleSearchOptions,
1314
loadDropdownOptionsPromise,
1415
} from "./poster-helper";
1516

@@ -51,6 +52,8 @@ function PosterSingle({ configurationChange, feedSource, configuration }) {
5152
const optionsEndpoint = firstAdminEntry.endpointOption ?? null;
5253
const entityEndpoint = firstAdminEntry.endpointEntity ?? null;
5354

55+
const singleSearchTypeOptions = getSingleSearchOptions(t);
56+
5457
const removeSingleSelected = () => {
5558
configurationChange({
5659
targets: [
@@ -66,34 +69,6 @@ function PosterSingle({ configurationChange, feedSource, configuration }) {
6669
});
6770
};
6871

69-
const singleSearchTypeOptions = [
70-
{
71-
key: "singleSearchTypeOptions1",
72-
value: "title",
73-
title: t("single-search-type-title"),
74-
},
75-
{
76-
key: "singleSearchTypeOptions2",
77-
value: "url",
78-
title: t("single-search-type-url"),
79-
},
80-
{
81-
key: "singleSearchTypeOptions3",
82-
value: "organizations",
83-
title: t("single-search-type-organization"),
84-
},
85-
{
86-
key: "singleSearchTypeOptions4",
87-
value: "locations",
88-
title: t("single-search-type-location"),
89-
},
90-
{
91-
key: "singleSearchTypeOptions5",
92-
value: "tags",
93-
title: t("single-search-type-tag"),
94-
},
95-
];
96-
9772
const handleSelectEvent = (eventId, occurrenceIds = []) => {
9873
if (!eventId) {
9974
return;
@@ -214,7 +189,7 @@ function PosterSingle({ configurationChange, feedSource, configuration }) {
214189
const timeoutRef = useRef(null);
215190

216191
const debounceOptions = (inputValue) => {
217-
// Debounce promise.
192+
// Debounce result to avoid searching while typing.
218193
return new Promise((resolve, reject) => {
219194
if (timeoutRef.current) {
220195
clearTimeout(timeoutRef.current);

0 commit comments

Comments
 (0)