Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R20-1183] search listing hide form option #983

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,12 @@ Feature: Search listing - Filter
| Apples |
| Oranges |

@mockserver
Example: Should hide the search form when hideSearchForm is set
Given the page endpoint for path "/no-search-form" returns fixture "/search-listing/filters/page-no-search-form" with status 200
And the search network request is stubbed with fixture "/search-listing/filters/response" and status 200

When I visit the page "/no-search-form"
Then the search listing page should have 2 results
And the search form should be hidden

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"title": "Listing without search form",
"changed": "2022-11-02T12:47:29+11:00",
"created": "2022-11-02T12:47:29+11:00",
"type": "tide_search_listing",
"nid": "11dede11-10c0-111e1-1100-000000000332",
"showTopicTags": true,
"summary": "",
"config": {
"searchListingConfig": {
"hideSearchForm": true,
"resultsPerPage": 10
},
"queryConfig": {},
"results": {
"layout": {
"component": "TideSearchResultsGrid"
},
"item": {
"*": {
"component": "TideSearchResultCard"
}
}
},
"globalFilters": [
{ "terms": { "type": ["grant"] } },
{ "terms": { "field_node_site": [8888] } }
],
"userFilters": []
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,7 @@ Then(
cy.get(`#search-listing-sort-options`).should('contain', option)
}
)

Then('the search form should be hidden', () => {
cy.get(`.tide-search-header`).should('not.exist')
})
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const props = withDefaults(defineProps<Props>(), {
}
}),
searchListingConfig: () => ({
hideSearchForm: false,
resultsPerPage: 9,
labels: {
submit: 'Submit',
Expand Down Expand Up @@ -336,7 +337,10 @@ watch(
:corner-bottom="false"
>
<p v-if="introText" class="rpl-type-p-large">{{ introText }}</p>
<div class="tide-search-header">
<div
v-if="!searchListingConfig.hideSearchForm"
class="tide-search-header"
>
<RplSearchBar
id="tide-search-bar"
variant="default"
Expand Down
1 change: 1 addition & 0 deletions packages/ripple-tide-search/mapping/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ const parseResultsConfigFromDrupal = (src) => {
const buildConfigFromDrupalFields = (src) => {
return {
searchListingConfig: {
hideSearchForm: src?.field_listing_hide_search_form ?? false,
resultsPerPage: src.field_listing_results_per_page || 10,
labels: {
submit: src.field_search_submit_label,
Expand Down
9 changes: 8 additions & 1 deletion packages/ripple-tide-search/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,12 @@ export type TideSearchListingConfig = {
*/
index: string
/**
* @description Toggle grid and list view of results, cards need to be a grid view
* @description Set the number of results to show per page
*/
resultsPerPage?: number
/**
* @description Override the default labels
*/
labels: {
submit: string
reset: string
Expand All @@ -133,6 +136,10 @@ export type TideSearchListingConfig = {
* @description whether to display map tab and include map search results
*/
displayMapTab?: boolean
/**
* @description optionally hide the search form
*/
hideSearchForm?: boolean
}
/**
* @description Elastic Query DSL for query clause
Expand Down
Loading