Skip to content

Commit a83ee68

Browse files
committed
More Form Wrapper docs
1 parent 73b27cc commit a83ee68

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

docs/.vuepress/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module.exports = {
1414
'/common-patterns.md',
1515
'/mixins.md',
1616
'/components.md',
17+
'/feathers-vuex-form-wrapper.md',
1718
'/nuxt.md'
1819
],
1920
serviceWorker: {

docs/feathers-vuex-form-wrapper.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
<!-- markdownlint-disable MD002 MD033 MD041 -->
2-
# FeathersVuexFormWrapper
1+
---
2+
title: Working with Forms
3+
sidebarDepth: 3
4+
---
35

4-
The `FeathersVuexFormWrapper` is a renderless component which assists in connecting your feathers-vuex data to a form. Let's review why it exists by looking at a couple of common patterns.
6+
# Working with Forms
7+
8+
The `FeathersVuexFormWrapper` is a renderless component which assists in connecting your feathers-vuex data to a form. The next two sections review why it exists by looking at a couple of common patterns. Proceed to the [FeathersVuexFormWrapper](#feathersvuexformwrapper) section to learn how to implement.
59

610
## The Mutation Multiplicity (anti) Pattern
711

@@ -23,7 +27,7 @@ The "Clone and Commit" pattern provides an alternative to using a lot of mutatio
2327

2428
Send most edits through a single mutation can really simplify the way you work with Vuex data. The Feathers-Vuex `BaseModel` class has `clone` and `commit` instance methods. Those methods are used inside the FeathersVuexFormWrapper component.
2529

26-
## Usage
30+
## FeathersVuexFormWrapper
2731

2832
The `FeathersVuexFormWrapper` component uses the "clone and commit" pattern to connect a single record to a child form within its default slot.
2933

@@ -32,10 +36,25 @@ The `FeathersVuexFormWrapper` component uses the "clone and commit" pattern to c
3236
<template v-slot="{ clone, save, reset, remove }">
3337
<SomeEditor
3438
:item="clone"
35-
@save="save()"
39+
@save="save"
3640
@reset="reset"
3741
@remove="remove"
3842
></SomeEditor>
3943
</template>
4044
</FeathersVuexFormWrapper>
4145
```
46+
47+
### Props
48+
49+
- `item`: {Object} a model instance from the Vuex store.
50+
- `watch`: {Boolean|Array} when enabled, if the original record is updated, the data will be re-cloned. The newly-cloned data will overwrite the `clone` data (in the slot scope). Default: `false`.
51+
- `eager`: {Boolean} While this is enabled, using the `save` method will first commit the result to the store then it will send a network request. The UI display will update immediately, without waiting for any response from the API server. Default: `true`.
52+
53+
### Slot Scope
54+
55+
The default slot contains only four attributes. The `clone` data can be passed to the child component. The `save`, `reset`, and `remove` are meant to be bound to events emitted from the child component.
56+
57+
- `clone`: {Object} The cloned record. Each record in the store can have a single clone. The clones are stored on the service's model class, by default.
58+
- `save`: {Function} When called, it commits the data and saves the record (with eager updating, by default. See the `eager` prop.).
59+
- `reset`: {Function} When called, the clone data will be reset back to the data that is currently found in the store for the same record.
60+
- `remove`: {Function} When called, it removes the record from the API server and the Vuex store.

0 commit comments

Comments
 (0)