Skip to content

Commit ea24437

Browse files
authored
Merge pull request #11028 from neinteractiveliterature/nbudin/issue10759
Change event catalog search box to be full text, not just title
2 parents 4c49404 + 60b06fa commit ea24437

7 files changed

Lines changed: 34 additions & 8 deletions

File tree

app/graphql/types/event_filters_input_type.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ class Types::EventFiltersInputType < Types::BaseInputObject
33
argument :category, [Integer, { null: true }], required: false
44
argument :form_items, GraphQL::Types::JSON, required: false, camelize: false
55
argument :my_rating, [Integer], required: false, camelize: false
6+
argument :text_search, String, required: false, camelize: false
67
argument :title, String, required: false
78
argument :title_prefix, String, required: false, camelize: false
89
end

app/javascript/EventsApp/EventCatalog/EventList/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const PAGE_SIZE = 20;
3636
const filterCodecs = buildFieldFilterCodecs({
3737
category: FilterCodecs.integerArray,
3838
my_rating: FilterCodecs.integerArray,
39-
title_prefix: FilterCodecs.nonEmptyString,
39+
text_search: FilterCodecs.nonEmptyString,
4040
form_items: FilterCodecs.json,
4141
});
4242

@@ -150,8 +150,8 @@ function EventList(): React.JSX.Element {
150150
[changeFilterValue],
151151
);
152152

153-
const titlePrefixChanged = useCallback(
154-
(value: unknown) => changeFilterValue('title_prefix', value),
153+
const textSearchChanged = useCallback(
154+
(value: unknown) => changeFilterValue('text_search', value),
155155
[changeFilterValue],
156156
);
157157

@@ -183,7 +183,7 @@ function EventList(): React.JSX.Element {
183183

184184
return (
185185
<>
186-
<h1>Event Catalog</h1>
186+
<h1>{t('navigation.events.eventCatalog')}</h1>
187187

188188
<EventCatalogNavTabs />
189189

@@ -232,9 +232,9 @@ function EventList(): React.JSX.Element {
232232

233233
<div className="ms-2 flex-grow-1">
234234
<SearchInput
235-
label="Search"
236-
value={effectiveFilters.find(({ id }) => id === 'title_prefix')?.value as string | undefined}
237-
onChange={titlePrefixChanged}
235+
label={t('events.catalog.textSearchLabel')}
236+
value={effectiveFilters.find(({ id }) => id === 'text_search')?.value as string | undefined}
237+
onChange={textSearchChanged}
238238
iconSet="bootstrap-icons"
239239
/>
240240
</div>

app/javascript/graphqlTypes.generated.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,6 +2960,7 @@ export type EventFiltersInput = {
29602960
category?: InputMaybe<Array<InputMaybe<Scalars['Int']['input']>>>;
29612961
form_items?: InputMaybe<Scalars['JSON']['input']>;
29622962
my_rating?: InputMaybe<Array<Scalars['Int']['input']>>;
2963+
text_search?: InputMaybe<Scalars['String']['input']>;
29632964
title?: InputMaybe<Scalars['String']['input']>;
29642965
title_prefix?: InputMaybe<Scalars['String']['input']>;
29652966
};

app/presenters/tables/events_table_results_presenter.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def apply_filter(scope, value)
3737
end
3838
end
3939

40+
field :text_search, "Text search" do
41+
def apply_filter(scope, value)
42+
scope.where(id: PgSearch.multisearch(value).where(searchable_type: "Event").select(:searchable_id))
43+
end
44+
45+
def sql_order(_direction)
46+
nil
47+
end
48+
end
49+
4050
field :my_rating, "My rating" do
4151
delegate :user_con_profile, :pundit_user, to: :presenter
4252

locales/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@
749749
"catalog": {
750750
"author_one": "Author",
751751
"author_other": "Authors",
752-
"organization": "Organization"
752+
"organization": "Organization",
753+
"textSearchLabel": "Search"
753754
},
754755
"categoryDropdown": {
755756
"allCategoriesLabel": "All event types",

schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3713,6 +3713,7 @@ input EventFiltersInput {
37133713
category: [Int]
37143714
form_items: JSON
37153715
my_rating: [Int!]
3716+
text_search: String
37163717
title: String
37173718
title_prefix: String
37183719
}

schema.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15770,6 +15770,18 @@
1577015770
"isDeprecated": false,
1577115771
"deprecationReason": null
1577215772
},
15773+
{
15774+
"name": "text_search",
15775+
"description": null,
15776+
"type": {
15777+
"kind": "SCALAR",
15778+
"name": "String",
15779+
"ofType": null
15780+
},
15781+
"defaultValue": null,
15782+
"isDeprecated": false,
15783+
"deprecationReason": null
15784+
},
1577315785
{
1577415786
"name": "title",
1577515787
"description": null,

0 commit comments

Comments
 (0)