From 23272d18ef2eccd1a451bbd2aefb1f067b30962b Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Fri, 13 Nov 2020 10:05:48 -0500 Subject: basic sorting functional; swapped indexes for ids in edit list --- iridescence/src/store/index.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'iridescence/src/store') diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js index 19205c9..d0d04cb 100644 --- a/iridescence/src/store/index.js +++ b/iridescence/src/store/index.js @@ -11,31 +11,31 @@ export default new Vuex.Store({ searchTerm: "", products: [], busy: false, - progress: 100 + compare: () => 0 }, getters: { busy(state) { return state.busy; }, - progress(state) { - return state.progress; - }, products(state) { - return state.products.filter(item => { - return JSON.stringify(item) - .toLowerCase() - .includes(state.searchTerm.toLowerCase()); - }); + return state.products + .filter(item => { + return JSON.stringify(item) + .toLowerCase() + .includes(state.searchTerm.toLowerCase()); + }) + .sort(state.compare); } }, mutations: { toggleBusy(state) { state.busy = !state.busy; }, + compare(state, compare) { + state.compare = compare; + }, searchTerm(state, term) { - if (term) { - state.searchTerm = term; - } + state.searchTerm = term; }, setProducts(state, products) { if (products) { -- cgit v1.2.3