Created
April 2, 2017 16:07
-
-
Save Ntropish/8efe3ec28b50517c24508a508d8874b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mutations = { | |
SET_SELECTED(state, newSelectedThing) { | |
state.item = newSelectedThing | |
Vue.set(state, 'item', newSelectedThing) | |
}, | |
UPDATE_SELECTED(state, {type, name, value}) { | |
if (!state.item) throw new Error(`No item selected while trying to update`) | |
if (!state.item[type]) throw new Error(`Missing property type: ${type}`) | |
// If no name given update the type, else update type.name | |
let key = name || type | |
let object = state.item | |
if (name) object = object[type] | |
Vue.set(object, key, value) | |
}, | |
SELECT_PROPERTY(state, property) { | |
Vue.set(state, 'property', property) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment