Implements string textual on collection. Closes #32.

This commit is contained in:
Mateus Machado Luna 2018-05-04 11:08:51 -03:00
parent 7a3e4cce62
commit 4e49bea66f
8 changed files with 35 additions and 4 deletions

View File

@ -103,7 +103,8 @@ export default {
id: Number
},
watch: {
'$route' (to) {
'$route.path' (to) {
this.activeRoute = to.name;
this.pageTitle = this.$route.meta.title;

View File

@ -16,10 +16,12 @@
<b-field class="margin-1">
<b-input
placeholder="Search..."
:placeholder=" $i18n.get('instruction_search_collection') "
type="search"
size="is-small"
icon="magnify" />
icon="magnify"
@input="updateSearch($event)"
:value="searchQuery"/>
</b-field>
<a class="is-size-7 is-secondary is-pulled-right">Busca avançada</a>
@ -172,6 +174,9 @@
...mapGetters('filter', [
'getFilters'
]),
...mapGetters('search', [
'getSearchQuery'
]),
toggleCollapseAll() {
this.collapseAll = !this.collapseAll;
@ -179,6 +184,9 @@
this.fieldCollapses[i] = this.collapseAll;
},
updateSearch(searchQuery) {
this.$eventBusSearch.setSearchQuery(searchQuery)
}
},
computed: {
items() {
@ -189,6 +197,9 @@
},
fields() {
return this.getFields();
},
searchQuery() {
return this.getSearchQuery();
}
},
created() {

View File

@ -189,6 +189,7 @@ return [
'instruction_insert_url' => __( 'Insert URL', 'tainacan' ),
'instruction_write_text' => __( 'Write Text', 'tainacan' ),
'instruction_search_repository' => __( 'Search on repository', 'tainacan' ),
'instruction_search_collection' => __( 'Search on collection', 'tainacan' ),
// Info. Other feedback to user.
'info_name_is_required' => __( 'Name is required.', 'tainacan' ),

View File

@ -86,6 +86,10 @@ export default {
this.$store.dispatch('search/setOrder', newOrder);
this.updateURLQueries();
},
setSearchQuery(searchQuery) {
this.$store.dispatch('search/setSearchQuery', searchQuery);
this.updateURLQueries();
},
updateURLQueries() {
this.$router.push({ query: {} });
this.$router.push({ query: this.$store.getters['search/getPostQuery'] });

View File

@ -66,3 +66,8 @@ export const setOrderBy = ({ commit }, orderBy ) => {
export const setOrder = ({ commit }, order ) => {
commit('setPostQueryAttribute', { attr: 'order', value: order } );
};
// Set search query
export const setSearchQuery = ({ commit }, searchQuery ) => {
commit('setSearchQuery', searchQuery );
};

View File

@ -28,4 +28,8 @@ export const getOrder = state => {
export const getOrderBy = state => {
return state.postquery.orderby;
};
};
export const getSearchQuery = state => {
return state.postquery.search;
}

View File

@ -8,6 +8,7 @@ const state = {
order: 'DESC',
paged: 1,
perpage: 12,
search: '',
post_type: [],
metaquery: [],
taxquery: []

View File

@ -64,3 +64,7 @@ export const removeTaxQuery = ( state, filter ) => {
export const setTotalItems = ( state, total ) => {
state.totalItems = total;
};
export const setSearchQuery = ( state, searchQuery ) => {
state.postquery.search = searchQuery;
};