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

Searchable facets #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 5 additions & 2 deletions plugin/assets/src/components/AlgoliaSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ import {
AisSortBy,
AisRangeInput,
AisToggleRefinement,
AisClearRefinements
AisClearRefinements,
} from 'vue-instantsearch';

import SearchInputWrapper from './SearchInputWrapper.vue'

import {history as historyRouter} from 'instantsearch.js/es/lib/routers';

function getRouting(component) {
Expand Down Expand Up @@ -150,7 +152,8 @@ export default {
VueSlider,
AisRangeInput,
AisToggleRefinement,
AisClearRefinements
AisClearRefinements,
SearchInputWrapper
},

data() {
Expand Down
43 changes: 43 additions & 0 deletions plugin/assets/src/components/SearchInputWrapper.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<search-input
v-model="searchForFacetValues"
:placeholder="placeholder"
:class-names="classNames"
/>
</template>

<script>
import SearchInput from 'vue-instantsearch/src/components/SearchInput.vue'
export default {
components: {
SearchInput
},
props: {
classNames: {
type: Object
},
placeholder: {
type: String
},
searchForItems: {
type: Function
}
},
data() {
return {
searchForFacetValuesQuery: '',
};
},
computed: {
searchForFacetValues: {
get() {
return this.searchForFacetValuesQuery;
},
set(value) {
this.searchForItems(value);
this.searchForFacetValuesQuery = value;
},
},
}
}
</script>
30 changes: 29 additions & 1 deletion plugin/builder/algolia_facet/element.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"all_button_text": "All",
"facet_type": "Checkbox",
"sort_by": "isRefined:desc",
"sort_by_fallback": "name:asc"
"sort_by_fallback": "name:asc",
"searchable": false,
"searchable_placeholder": "",
"searchable_no_result": "No Results"
},
"templates": {
"render": "./templates/template.php",
Expand Down Expand Up @@ -231,6 +234,21 @@
"Is Refined (Asc)": "isRefined:asc"
}
},
"searchable": {
"label": "Searchable",
"type": "checkbox",
"text": "Searchable"
},
"searchable_placeholder": {
"label": "Search Label",
"source": true,
"enable": "searchable"
},
"searchable_no_results": {
"label": "Search No Results Text",
"source": true,
"enable": "searchable"
},
"position": "${builder.position}",
"position_left": "${builder.position_left}",
"position_right": "${builder.position_right}",
Expand Down Expand Up @@ -304,6 +322,16 @@
"all_button_text"
]
},
{
"label": "Searchable",
"type": "group",
"divider": true,
"fields": [
"searchable",
"searchable_placeholder",
"searchable_no_result"
]
},
{
"label": "Sorting",
"type": "group",
Expand Down
Loading