make the main searchbar do stuff too

This commit is contained in:
j3d1 2019-12-25 17:50:18 +01:00
parent 5c56329ee3
commit 2a69e231be
2 changed files with 7 additions and 3 deletions

View file

@ -31,7 +31,7 @@
</button> </button>
<form class="form-inline mt-1 my-lg-auto my-xl-auto w-100 d-inline"> <form class="form-inline mt-1 my-lg-auto my-xl-auto w-100 d-inline">
<input class="form-control w-100" type="search" placeholder="Search" aria-label="Search"> <input class="form-control w-100" type="search" placeholder="Search" aria-label="Search" @input="searchEventItems($event.target.value)">
</form> </form>
<div class="collapse navbar-collapse" id="navbarSupportedContent"> <div class="collapse navbar-collapse" id="navbarSupportedContent">
@ -77,7 +77,7 @@ export default {
...mapGetters(['getEventSlug', 'getActiveView']), ...mapGetters(['getEventSlug', 'getActiveView']),
}, },
methods: { methods: {
...mapActions(['changeEvent', 'changeView']), ...mapActions(['changeEvent', 'changeView','searchEventItems']),
...mapMutations(['setLayout']) ...mapMutations(['setLayout'])
} }
}; };

View file

@ -63,7 +63,7 @@ const store = new Vuex.Store({
}, },
changeEvent({ dispatch, getters}, eventName) { changeEvent({ dispatch, getters}, eventName) {
router.push({path: `/${eventName.slug}/${getters.getActiveView}`}); router.push({path: `/${eventName.slug}/${getters.getActiveView}`});
dispatch('loadEventItems', eventName); dispatch('loadEventItems');
}, },
changeView({ getters }, link) { changeView({ getters }, link) {
router.push({path: `/${getters.getEventSlug}/${link.path}`}); router.push({path: `/${getters.getEventSlug}/${link.path}`});
@ -75,6 +75,10 @@ const store = new Vuex.Store({
const { data } = await axios.get(`/1/${getters.getEventSlug}/items`); const { data } = await axios.get(`/1/${getters.getEventSlug}/items`);
commit('replaceLoadedItems', data); commit('replaceLoadedItems', data);
}, },
async searchEventItems({ commit, getters }, query) {
const {data} = await axios.get(`/1/${getters.getEventSlug}/items/${btoa(query)}`);
commit('replaceLoadedItems', data);
},
async loadBoxes({ commit }) { async loadBoxes({ commit }) {
const { data } = await axios.get('/1/boxes'); const { data } = await axios.get('/1/boxes');
commit('replaceBoxes', data); commit('replaceBoxes', data);