diff options
Diffstat (limited to 'app/assets/javascripts/vuex_shared/bindings.js')
-rw-r--r-- | app/assets/javascripts/vuex_shared/bindings.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/app/assets/javascripts/vuex_shared/bindings.js b/app/assets/javascripts/vuex_shared/bindings.js index 741690886b7..bc3741a3880 100644 --- a/app/assets/javascripts/vuex_shared/bindings.js +++ b/app/assets/javascripts/vuex_shared/bindings.js @@ -6,7 +6,7 @@ * @param {string} list[].getter - the name of the getter, leave it empty to not use a getter * @param {string} list[].updateFn - the name of the action, leave it empty to use the default action * @param {string} defaultUpdateFn - the default function to dispatch - * @param {string} root - the key of the state where to search fo they keys described in list + * @param {string|function} root - the key of the state where to search for the keys described in list * @returns {Object} a dictionary with all the computed properties generated */ export const mapComputed = (list, defaultUpdateFn, root) => { @@ -21,6 +21,10 @@ export const mapComputed = (list, defaultUpdateFn, root) => { if (getter) { return this.$store.getters[getter]; } else if (root) { + if (typeof root === 'function') { + return root(this.$store.state)[key]; + } + return this.$store.state[root][key]; } return this.$store.state[key]; |