You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/feathers-vuex-form-wrapper.md
+24-5Lines changed: 24 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,11 @@
1
-
<!-- markdownlint-disable MD002 MD033 MD041 -->
2
-
# FeathersVuexFormWrapper
1
+
---
2
+
title: Working with Forms
3
+
sidebarDepth: 3
4
+
---
3
5
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.
5
9
6
10
## The Mutation Multiplicity (anti) Pattern
7
11
@@ -23,7 +27,7 @@ The "Clone and Commit" pattern provides an alternative to using a lot of mutatio
23
27
24
28
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.
25
29
26
-
## Usage
30
+
## FeathersVuexFormWrapper
27
31
28
32
The `FeathersVuexFormWrapper` component uses the "clone and commit" pattern to connect a single record to a child form within its default slot.
29
33
@@ -32,10 +36,25 @@ The `FeathersVuexFormWrapper` component uses the "clone and commit" pattern to c
32
36
<templatev-slot="{ clone, save, reset, remove }">
33
37
<SomeEditor
34
38
:item="clone"
35
-
@save="save()"
39
+
@save="save"
36
40
@reset="reset"
37
41
@remove="remove"
38
42
></SomeEditor>
39
43
</template>
40
44
</FeathersVuexFormWrapper>
41
45
```
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