diff --git a/lib/decorate.js b/lib/decorate.js index 9672a1a..cf99849 100644 --- a/lib/decorate.js +++ b/lib/decorate.js @@ -15,19 +15,20 @@ exports.decorate = function (params, keyPath, componentName) { return params } - keyPath = _.toPath(keyPath) - const { data, errors } = this.ctx - if (!data) { - return '' - } + + keyPath = _.toPath(keyPath) // Strip data from key path as auto store data middleware adds it if (keyPath[0] === 'data') { keyPath.shift(1) } - const storedValue = _.get(data, keyPath) + // Get stored value from session data, else local data + const storedValue = _.get(data, keyPath) || _.get(this.ctx, keyPath) + if (!storedValue) { + return '' + } params.id = (params.id) ? params.id : keyPath.join('-') params.name = (params.name) ? params.name : keyPath.map(s => `[${s}]`).join('')