diff options
Diffstat (limited to 'iridescence/src/store')
-rw-r--r-- | iridescence/src/store/index.js | 21 |
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: {} }); |