summaryrefslogtreecommitdiff
path: root/iridescence/src/store/index.js
diff options
context:
space:
mode:
authorAdam Carpenter <atc@53hor.net>2020-04-30 20:51:38 -0400
committerAdam Carpenter <atc@53hor.net>2020-04-30 20:51:38 -0400
commit9119c86ff94fd29086dfd342a616993f20fc5c75 (patch)
treebcf4a50e72465efd6eaa921d65a30eaf8363f973 /iridescence/src/store/index.js
parent580521ebe3c9d72d756c8e7ab2d53cb6a69443d1 (diff)
downloadtheglassyladies-9119c86ff94fd29086dfd342a616993f20fc5c75.tar.xz
theglassyladies-9119c86ff94fd29086dfd342a616993f20fc5c75.zip
added a search filter for names and descriptions
Diffstat (limited to 'iridescence/src/store/index.js')
-rw-r--r--iridescence/src/store/index.js21
1 files changed, 18 insertions, 3 deletions
diff --git a/iridescence/src/store/index.js b/iridescence/src/store/index.js
index 4a851ef..eaf9a9f 100644
--- a/iridescence/src/store/index.js
+++ b/iridescence/src/store/index.js
@@ -78,12 +78,27 @@ export default new Vuex.Store({
imgPath: "/wind-chime.jpg",
description: "Makes noise when the wind blows."
}
- ]
+ ],
+ term: ""
},
getters: {
- inventory: state => state.inventory
+ inventory(state) {
+ const term = state.term.toLowerCase();
+
+ return state.inventory.filter(item => {
+ // TODO: move into class for items
+ return (
+ item.name.toLowerCase().indexOf(term) != -1 ||
+ item.description.toLowerCase().indexOf(term) != -1
+ );
+ });
+ }
+ },
+ mutations: {
+ filterTerm(state, term) {
+ state.term = term;
+ }
},
- mutations: {},
actions: {},
modules: {}
});