stash
This commit is contained in:
parent
af00daca51
commit
1c9afb6bad
5 changed files with 54 additions and 24 deletions
|
@ -1,19 +1,17 @@
|
|||
<template>
|
||||
<form class="form-inline">
|
||||
<input
|
||||
class="form-control w-100"
|
||||
type="search"
|
||||
placeholder="Search"
|
||||
aria-label="Search"
|
||||
v-model="search_query"
|
||||
@input="searchEventItems(search_query)"
|
||||
>
|
||||
</form>
|
||||
<input
|
||||
class="form-control w-100"
|
||||
type="search"
|
||||
placeholder="Search"
|
||||
aria-label="Search"
|
||||
v-model="search_query"
|
||||
@keyup.enter="dispatchSearch"
|
||||
>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapActions} from "vuex";
|
||||
import {mapActions, mapGetters} from "vuex";
|
||||
|
||||
export default {
|
||||
name: 'SearchBox',
|
||||
|
@ -22,8 +20,24 @@ export default {
|
|||
search_query: ''
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(['getActiveView'])
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['searchEventItems']),
|
||||
...mapActions(['searchEventItems', 'searchEventTickets']),
|
||||
isItemView() {
|
||||
return this.getActiveView === 'items' || this.getActiveView === 'item';
|
||||
},
|
||||
isTicketView() {
|
||||
return this.getActiveView === 'tickets' || this.getActiveView === 'ticket';
|
||||
},
|
||||
dispatchSearch() {
|
||||
if (this.isItemView()) {
|
||||
this.searchEventItems(this.search_query);
|
||||
} else if (this.isTicketView()) {
|
||||
this.searchEventTickets(this.search_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
|
@ -26,6 +26,7 @@ const store = createStore({
|
|||
|
||||
lastEvent: '37C3',
|
||||
lastUsed: {},
|
||||
searchQuery: '',
|
||||
remember: false,
|
||||
user: {
|
||||
username: null,
|
||||
|
@ -375,10 +376,9 @@ const store = createStore({
|
|||
}
|
||||
},
|
||||
async searchEventItems({commit, getters, state}, query) {
|
||||
const foo = utf8.encode(query);
|
||||
const bar = base64.encode(foo);
|
||||
const encoded_query = base64.encode(utf8.encode(query));
|
||||
|
||||
const {data, success} = await http.get(`/2/${getters.getEventSlug}/items/${bar}/`, state.user.token);
|
||||
const {data, success} = await http.get(`/2/${getters.getEventSlug}/items/${encoded_query}/`, state.user.token);
|
||||
if (data && success)
|
||||
commit('replaceLoadedItems', data);
|
||||
},
|
||||
|
@ -427,6 +427,13 @@ const store = createStore({
|
|||
if (data && success)
|
||||
commit('replaceTickets', data);
|
||||
},
|
||||
async searchEventTickets({commit, getters, state}, query) {
|
||||
const encoded_query = base64.encode(utf8.encode(query));
|
||||
|
||||
const {data, success} = await http.get(`/2/${getters.getEventSlug}/tickets/${encoded_query}/`, state.user.token);
|
||||
if (data && success)
|
||||
commit('replaceTickets', data);
|
||||
},
|
||||
async sendMail({commit, dispatch, state}, {id, message}) {
|
||||
const {data, success} = await http.post(`/2/tickets/${id}/reply/`, {message}, state.user.token);
|
||||
if (data && success) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue