allow searching while "all" event is selected
This commit is contained in:
parent
0fa52645c2
commit
f133ae9e60
1 changed files with 59 additions and 23 deletions
|
@ -77,10 +77,26 @@ const store = createStore({
|
|||
getEventTickets: (state, getters) => getters.getEventSlug === 'all' ? getters.getAllTickets : getters.getAllTickets.filter(t => t.event === getters.getEventSlug || (t.event == null && getters.getEventSlug === 'none')),
|
||||
isItemsLoaded: (state, getters) => (getters.getEventSlug === 'all' || getters.getEventSlug === 'none') ? !!state.loadedItems : Object.keys(state.loadedItems).includes(getters.getEventSlug),
|
||||
isTicketsLoaded: (state, getters) => (getters.getEventSlug === 'all' || getters.getEventSlug === 'none') ? !!state.loadedTickets : Object.keys(state.loadedTickets).includes(getters.getEventSlug),
|
||||
getItemsSearchResults: (state, getters) => state.loadedItemSearchResults[getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || [],
|
||||
getTicketsSearchResults: (state, getters) => state.loadedTicketSearchResults[getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || [],
|
||||
isItemsSearchLoaded: (state, getters) => Object.keys(state.loadedItemSearchResults).includes(getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))),
|
||||
isTicketsSearchLoaded: (state, getters) => Object.keys(state.loadedTicketSearchResults).includes(getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))),
|
||||
getItemsSearchResults: (state, getters) => {
|
||||
if (getters.getEventSlug === 'all') {
|
||||
return state.events.map(e => {
|
||||
return state.loadedItemSearchResults[e.slug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || []
|
||||
}).flat();
|
||||
} else {
|
||||
return state.loadedItemSearchResults[getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || []
|
||||
}
|
||||
},
|
||||
getTicketsSearchResults: (state, getters) => {
|
||||
if (getters.getEventSlug === 'all') {
|
||||
return state.events.map(e => {
|
||||
return state.loadedTicketSearchResults[e.slug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || []
|
||||
}).flat();
|
||||
} else {
|
||||
return state.loadedTicketSearchResults[getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))] || []
|
||||
}
|
||||
},
|
||||
isItemsSearchLoaded: (state, getters) => Object.keys(state.loadedItemSearchResults).includes(getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))) || getters.getEventSlug === 'all',
|
||||
isTicketsSearchLoaded: (state, getters) => Object.keys(state.loadedTicketSearchResults).includes(getters.getEventSlug + '/' + base64.encode(utf8.encode(getters.searchQuery))) || getters.getEventSlug === 'all',
|
||||
getActiveView: state => router.currentRoute.value.name || 'items',
|
||||
getFilters: state => router.currentRoute.value.query,
|
||||
getBoxes: state => state.loadedBoxes,
|
||||
|
@ -379,9 +395,8 @@ const store = createStore({
|
|||
},
|
||||
async loadEventItems({commit, getters, state}) {
|
||||
if (!state.user.token) return;
|
||||
if (state.fetchedData.items > Date.now() - 1000 * 60 * 60 * 24) return;
|
||||
const load = async (slug) => {
|
||||
try {
|
||||
const slug = getters.getEventSlug;
|
||||
const {data, success} = await getters.session.get(`/2/${slug}/items/`);
|
||||
if (data && success) {
|
||||
commit('setItems', {slug, items: data});
|
||||
|
@ -389,10 +404,17 @@ const store = createStore({
|
|||
} catch (e) {
|
||||
console.error("Error loading items");
|
||||
}
|
||||
}
|
||||
const slug = getters.getEventSlug;
|
||||
if (slug === 'all') {
|
||||
await Promise.all(state.events.map(e => load(e.slug)));
|
||||
} else {
|
||||
await load(slug);
|
||||
}
|
||||
},
|
||||
async searchEventItems({commit, getters, state}, query) {
|
||||
const encoded_query = base64.encode(utf8.encode(query));
|
||||
const slug = getters.getEventSlug;
|
||||
const load = async (slug) => {
|
||||
if (Object.keys(state.loadedItemSearchResults).includes(slug + '/' + encoded_query)) return;
|
||||
const {
|
||||
data, success
|
||||
|
@ -400,6 +422,13 @@ const store = createStore({
|
|||
if (data && success) {
|
||||
commit('setItemSearchResults', {slug, query: encoded_query, items: data});
|
||||
}
|
||||
}
|
||||
const slug = getters.getEventSlug;
|
||||
if (slug === 'all') {
|
||||
await Promise.all(state.events.map(e => load(e.slug)));
|
||||
} else {
|
||||
await load(slug);
|
||||
}
|
||||
},
|
||||
async loadBoxes({commit, state, getters}) {
|
||||
if (!state.user.token) return;
|
||||
|
@ -446,12 +475,19 @@ const store = createStore({
|
|||
},
|
||||
async searchEventTickets({commit, getters, state}, query) {
|
||||
const encoded_query = base64.encode(utf8.encode(query));
|
||||
const slug = getters.getEventSlug;
|
||||
const load = async (slug) => {
|
||||
if (Object.keys(state.loadedTicketSearchResults).includes(slug + '/' + encoded_query)) return;
|
||||
const {
|
||||
data, success
|
||||
} = await getters.session.get(`/2/${slug}/tickets/${encoded_query}/`);
|
||||
if (data && success) commit('setTicketSearchResults', {slug, query: encoded_query, items: data});
|
||||
}
|
||||
const slug = getters.getEventSlug;
|
||||
if (slug === 'all') {
|
||||
await Promise.all(state.events.map(e => load(e.slug)));
|
||||
} else {
|
||||
await load(slug);
|
||||
}
|
||||
},
|
||||
async sendMail({commit, dispatch, state, getters}, {id, message}) {
|
||||
const {data, success} = await getters.session.post(`/2/tickets/${id}/reply/`, {message},
|
||||
|
|
Loading…
Add table
Reference in a new issue