Skip to content

Commit

Permalink
Merge branch 'release/1.3.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
maoberlehner committed Sep 29, 2018
2 parents 9d2fcc4 + cf7c75b commit 65842ca
Show file tree
Hide file tree
Showing 4 changed files with 1,192 additions and 1,197 deletions.
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ export default {
</script>
```

[![Edit basic example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/94l98vx0p4)

### Nested properties

Oftentimes you want to have nested properties in the Vuex store. `vuex-map-fields` supports nested data structures by utilizing the object dot string notation.
Expand Down Expand Up @@ -142,6 +144,8 @@ export default {
</script>
```

[![Edit nested properties example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/38y88yvoo1)

### Rename properties

Sometimes you might want to give your computed properties different names than what you're using in the Vuex store. Renaming properties is made possible by passing an object of fields to the `mapFields` function instead of an array.
Expand All @@ -168,6 +172,8 @@ export default {
</script>
```

[![Edit rename properties example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/7yowrm6j4x)

### Custom getters and mutations

By default `vuex-map-fields` is searching for the given properties starting from the root of your state object. Depending on the size of your application, the state object might become quite big and therefore updating the state starting from the root might become a performance issue. To circumvent such problems, it is possible to create a custom `mapFields()` function which is configured to access custom mutation and getter functions which don't start from the root of the state object but are accessing a specific point of the state.
Expand Down Expand Up @@ -242,6 +248,8 @@ export default {
</script>
```

[![Edit custom getters and mutations example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/4rroy51z8x)

### Vuex modules

Vuex makes it possible to divide the store into modules.
Expand Down Expand Up @@ -311,6 +319,8 @@ export default {
</script>
```

[![Edit Vuex modules example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/mo7j05j6vy)

### Namespaced Vuex modules

By default, mutations and getters inside modules are registered under the global namespace – but you can mark modules as `namespaced` which prevents naming clashes of mutations and getters between modules.
Expand Down Expand Up @@ -370,6 +380,8 @@ export default {
</script>
```

[![Edit namespaced Vuex modules example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/mly87n06p)

Or you can pass the module namespace string as the first argument of the `mapFields()` function.

```html
Expand All @@ -391,6 +403,8 @@ export default {
</script>
```

[![Edit namespaced Vuex modules example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/m51j02794p)

### Multi-row fields

If you want to build a form which allows the user to enter multiple rows of a specific data type with multiple fields (e.g. multiple addresses) you can use the multi-row field mapping function.
Expand Down Expand Up @@ -451,6 +465,8 @@ export default {
</script>
```

[![Edit multi-row fields example](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/yj1xxx8kn1)

## Upgrade from 0.x.x to 1.x.x

Instead of accessing the state directly, since the 1.0.0 release, in order to enable the ability to implement custom getters and mutations, `vuex-map-fields` is using a getter function to access the state. This makes it necessary to add a getter function to your Vuex store.
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vuex-map-fields",
"version": "1.3.0",
"version": "1.3.1",
"description": "Enable two-way data binding for form fields saved in a Vuex store",
"keywords": [
"vue",
Expand Down Expand Up @@ -28,23 +28,23 @@
"prepublishOnly": "yarn run lint && yarn test && yarn run build"
},
"devDependencies": {
"@avalanche/eslint-config": "^2.0.0",
"@babel/core": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51",
"@vue/test-utils": "^1.0.0-beta.18",
"@avalanche/eslint-config": "^3.0.0",
"@babel/core": "^7.1.2",
"@babel/preset-env": "^7.1.0",
"@vue/test-utils": "1.0.0-beta.25",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.0.1",
"coveralls": "^3.0.1",
"eslint": "^4.19.1",
"eslint-plugin-compat": "^2.4.0",
"eslint-plugin-import": "^2.12.0",
"babel-jest": "^23.6.0",
"coveralls": "^3.0.2",
"eslint": "^5.6.1",
"eslint-plugin-compat": "^2.5.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-markdown": "^1.0.0-beta.6",
"jest": "^23.1.0",
"rollup": "^0.60.2",
"rollup-plugin-babel": "^4.0.0-beta.0",
"jest": "^23.6.0",
"rollup": "^0.66.2",
"rollup-plugin-babel": "^4.0.3",
"uglify-es": "^3.3.9",
"vue": "^2.5.16",
"vue-template-compiler": "^2.5.16",
"vue": "^2.5.17",
"vue-template-compiler": "^2.5.17",
"vuex": "^3.0.1"
},
"main": "dist/index.js",
Expand Down
5 changes: 5 additions & 0 deletions test/multi-row.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ describe(`Component initialized with multi row setup.`, () => {
wrapper.find(`input`).element.value = `New Name`;
wrapper.find(`input`).trigger(`input`);

// The following line was added because otherwise the tests are failing.
// This is a pretty dirty workaround for some problem with @vue/test-utils.
// eslint-disable-next-line no-unused-expressions
wrapper.find(`div:nth-child(2)`);

wrapper.find(`div:nth-child(2) input:nth-child(2)`).element.value = `[email protected]`;
wrapper.find(`div:nth-child(2) input:nth-child(2)`).trigger(`input`);

Expand Down
Loading

0 comments on commit 65842ca

Please sign in to comment.