vue-form-generator icon indicating copy to clipboard operation
vue-form-generator copied to clipboard

v3 Enable lodash 'paths' feature

Open muschottkey opened this issue 5 years ago • 1 comments

According to the documentation, most features were turned off by default to reduce the package size. In order to use your desired feature, you needed to opt in to it.

'paths' feature was set to false. According to lodash documentation, paths feature offers Deep property path support for methods like _.get, _.has, & _.set. If the feature is not enabled, deep property fetching will fail since the methods are replaced with a _.noop method that always returns undefined.

Field attributes depend on this functionality in order to get attributes.label, attributes.input and attributes.wrapper. I also have fields with models like foo.bar which means that these fields will not work since we are able to set the value, but not get the value.

Therefore, I have enabled this option so that we can be sure that vfg.abstractField's value property will always be working whether the model provided is a deep or shallow path.

  • Please check if the PR fulfills these requirements
  • [ ] The commit message follows our guidelines
  • [ ] Tests for the changes have been added (for bug fixes / features)
  • [ ] Docs have been added / updated (for bug fixes / features)
  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...) Enables lodash's path feature.
  • What is the current behavior? (You can also link to an open issue here) Trying to access attributes from a hash using a path notation like foo.bar returns undefined.
  • What is the new behavior (if this is a feature change)?

if I have an object:

let foo = {
    bar: {
        baz: 'boo'
    } 
};

 _.get(foo, 'bar.baz'); // will return 'boo'

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)

NO.

muschottkey avatar Oct 08 '19 09:10 muschottkey

Coverage Status

Coverage remained the same at 73.92% when pulling 9678ff6bb2ef037f09d16765c0a69e72630d9f59 on muschottkey:v3-enable-lodash-paths into 218bababcdb4dced2fb439d6f6644c23afbf2d16 on vue-generators:v3.

coveralls avatar Oct 08 '19 09:10 coveralls