Skip to content

Commit 554c8d2

Browse files
committed
[2.7.7] vue-form now passes itself initial value to every component
1 parent a979d40 commit 554c8d2

File tree

6 files changed

+38
-38
lines changed

6 files changed

+38
-38
lines changed

CHANGELOG.md

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,54 @@
1-
## 2.7.6
1+
## 2.7.7
22

33
### Fixed
44

5-
— Pass `fileList` prop as `file-list` prop to `<Upload />`
6-
— Can't use value for now as `file-list` prop
5+
- `vue-form` now passes itself initial value to every component
6+
- User no need to define `fileList` if he passed `initalValues` to `Form`
77

8-
```js
9-
// Correct example
10-
<Upload
11-
formItem
12-
showFileList
13-
name="specificationFiles"
14-
label="Upload Specification*"
15-
labelWidth="150px"
16-
endpoint="uploadSpecification"
17-
// These initial values you have passed to form
18-
// Default value is an empty array
19-
fileList={this.initialValues.specificationFiles}
20-
httpRequest={this.createUploadFile}
21-
formatResponse={this.formatResponse}>
22-
<Button>Browse</Button>
23-
</Upload>
24-
```
8+
## 2.7.6
9+
10+
### Fixed
11+
12+
- Pass `fileList` prop as `file-list` prop to `<Upload />`
13+
- Can't use value for now as `file-list` prop
2514

2615
## 2.7.5
2716

2817
### Fixed
2918

30-
Pass `<Upload />` value as `file-list` prop to UI component
31-
Add default noop value for `handleModelChange`
32-
Call `handleModelChange` on `reinitialize`
19+
- Pass `<Upload />` value as `file-list` prop to UI component
20+
- Add default noop value for `handleModelChange`
21+
- Call `handleModelChange` on `reinitialize`
3322

3423
## 2.7.4
3524

3625
### Added
3726

38-
`<Button />` component from `element-ui`, just for convenience
27+
- `<Button />` component from `element-ui`, just for convenience
3928

4029
## 2.7.3
4130

4231
### Updated
4332

44-
When form field has removed from form — it value won't be passed to submit
33+
- When form field has removed from form — it value won't be passed to submit
4534

4635
## 2.7.2
4736

4837
### Fixed
4938

50-
Added `append`, `prepend` props to `<Input />`
39+
- Added `append`, `prepend` props to `<Input />`
5140

5241
## 2.7.1
5342

5443
### Fixed
5544

56-
Merge values for submit instead of destructuring
45+
- Merge values for submit instead of destructuring
5746

5847
## 2.7.0
5948

6049
### Added
6150

62-
`<Upload />` control
51+
- `<Upload />` control
6352

6453
## 2.6.1
6554

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ See demo at [https://detools.github.io/vue-form](https://detools.github.io/vue-f
8080

8181
## Changelog
8282

83+
- [2.7.7](/CHANGELOG.md#277)
8384
- [2.7.6](/CHANGELOG.md#276)
8485
- [2.7.5](/CHANGELOG.md#275)
8586
- [2.7.4](/CHANGELOG.md#274)

VueForm/components/ConnectedUpload.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,19 +155,19 @@ const ConnectedInput = {
155155
setValue([])
156156
},
157157

158-
handleFieldSuccess(response, file, filelist) {
159-
this.handleSuccess(response, file, filelist)
158+
handleFieldSuccess(response, file, fileList) {
159+
this.handleSuccess(response, file, fileList)
160160

161161
const [, setValue] = this.state
162-
const transformedResponse = this.formatResponse(response, file, filelist)
163-
const nextValue = castArray(filelist)
162+
const transformedResponse = this.formatResponse(response, file, fileList)
163+
const nextValue = castArray(fileList)
164164
.slice(0, -1)
165165
.concat(transformedResponse)
166166

167167
setValue(nextValue)
168168
},
169169

170-
renderComponent() {
170+
renderComponent(value, setValue, createElement, initialValue) {
171171
return (
172172
<Upload
173173
{...this.callbacks}
@@ -183,7 +183,7 @@ const ConnectedInput = {
183183
accept={this.accept}
184184
before-upload={this.beforeUpload}
185185
before-remove={this.beforeRemove}
186-
file-list={this.fileList}
186+
file-list={initialValue || this.fileList}
187187
list-type={this.listType}
188188
auto-upload={this.autoUpload}
189189
http-request={this.httpRequest}

VueForm/components/Form/Form.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,20 @@ export default {
167167
const isFieldTouched = vm.touchedFields[name]
168168

169169
return [
170+
// Current value
170171
vm.state[name],
172+
173+
// Value handler
171174
setValue,
175+
176+
// Current error
172177
isFieldTouched && (vm.syncErrors[name] || vm.asyncErrors[name]),
178+
179+
// Touched indicator
173180
isFieldTouched,
181+
182+
// Initial value
183+
this.initialValues[name],
174184
]
175185
},
176186
}

VueForm/mixins/ConnectedControl.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const ConnectedControlMixin = {
3737
},
3838

3939
render(createElement) {
40-
const [value, setValue, error] = this.state
40+
const [value, setValue, error, , initialValue] = this.state
4141
let { label } = this
4242

4343
if (isBoolean(this.label)) {
@@ -51,12 +51,12 @@ const ConnectedControlMixin = {
5151
if (this.formItem) {
5252
return (
5353
<FormItem label={label} label-width={this.labelWidth} error={error}>
54-
{this.renderComponent(value, setValue, createElement)}
54+
{this.renderComponent(value, setValue, createElement, initialValue)}
5555
</FormItem>
5656
)
5757
}
5858

59-
return this.renderComponent(value, setValue, createElement)
59+
return this.renderComponent(value, setValue, createElement, initialValue)
6060
},
6161
}
6262

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@detools/vue-form",
3-
"version": "2.7.6",
3+
"version": "2.7.7",
44
"description": "Form State Management for VueJS",
55
"main": "VueForm/index.js",
66
"scripts": {

0 commit comments

Comments
 (0)