Skip to content

Commit

Permalink
[2.7.7] vue-form now passes itself initial value to every component
Browse files Browse the repository at this point in the history
  • Loading branch information
isnifer committed Dec 11, 2018
1 parent a979d40 commit 554c8d2
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 38 deletions.
45 changes: 17 additions & 28 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,54 @@
## 2.7.6
## 2.7.7

### Fixed

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

```js
// Correct example
<Upload
formItem
showFileList
name="specificationFiles"
label="Upload Specification*"
labelWidth="150px"
endpoint="uploadSpecification"
// These initial values you have passed to form
// Default value is an empty array
fileList={this.initialValues.specificationFiles}
httpRequest={this.createUploadFile}
formatResponse={this.formatResponse}>
<Button>Browse</Button>
</Upload>
```
## 2.7.6

### Fixed

- Pass `fileList` prop as `file-list` prop to `<Upload />`
- Can't use value for now as `file-list` prop

## 2.7.5

### Fixed

Pass `<Upload />` value as `file-list` prop to UI component
Add default noop value for `handleModelChange`
Call `handleModelChange` on `reinitialize`
- Pass `<Upload />` value as `file-list` prop to UI component
- Add default noop value for `handleModelChange`
- Call `handleModelChange` on `reinitialize`

## 2.7.4

### Added

`<Button />` component from `element-ui`, just for convenience
- `<Button />` component from `element-ui`, just for convenience

## 2.7.3

### Updated

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

## 2.7.2

### Fixed

Added `append`, `prepend` props to `<Input />`
- Added `append`, `prepend` props to `<Input />`

## 2.7.1

### Fixed

Merge values for submit instead of destructuring
- Merge values for submit instead of destructuring

## 2.7.0

### Added

`<Upload />` control
- `<Upload />` control

## 2.6.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ See demo at [https://detools.github.io/vue-form](https://detools.github.io/vue-f

## Changelog

- [2.7.7](/CHANGELOG.md#277)
- [2.7.6](/CHANGELOG.md#276)
- [2.7.5](/CHANGELOG.md#275)
- [2.7.4](/CHANGELOG.md#274)
Expand Down
12 changes: 6 additions & 6 deletions VueForm/components/ConnectedUpload.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,19 +155,19 @@ const ConnectedInput = {
setValue([])
},

handleFieldSuccess(response, file, filelist) {
this.handleSuccess(response, file, filelist)
handleFieldSuccess(response, file, fileList) {
this.handleSuccess(response, file, fileList)

const [, setValue] = this.state
const transformedResponse = this.formatResponse(response, file, filelist)
const nextValue = castArray(filelist)
const transformedResponse = this.formatResponse(response, file, fileList)
const nextValue = castArray(fileList)
.slice(0, -1)
.concat(transformedResponse)

setValue(nextValue)
},

renderComponent() {
renderComponent(value, setValue, createElement, initialValue) {
return (
<Upload
{...this.callbacks}
Expand All @@ -183,7 +183,7 @@ const ConnectedInput = {
accept={this.accept}
before-upload={this.beforeUpload}
before-remove={this.beforeRemove}
file-list={this.fileList}
file-list={initialValue || this.fileList}
list-type={this.listType}
auto-upload={this.autoUpload}
http-request={this.httpRequest}
Expand Down
10 changes: 10 additions & 0 deletions VueForm/components/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,20 @@ export default {
const isFieldTouched = vm.touchedFields[name]

return [
// Current value
vm.state[name],

// Value handler
setValue,

// Current error
isFieldTouched && (vm.syncErrors[name] || vm.asyncErrors[name]),

// Touched indicator
isFieldTouched,

// Initial value
this.initialValues[name],
]
},
}
Expand Down
6 changes: 3 additions & 3 deletions VueForm/mixins/ConnectedControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const ConnectedControlMixin = {
},

render(createElement) {
const [value, setValue, error] = this.state
const [value, setValue, error, , initialValue] = this.state
let { label } = this

if (isBoolean(this.label)) {
Expand All @@ -51,12 +51,12 @@ const ConnectedControlMixin = {
if (this.formItem) {
return (
<FormItem label={label} label-width={this.labelWidth} error={error}>
{this.renderComponent(value, setValue, createElement)}
{this.renderComponent(value, setValue, createElement, initialValue)}
</FormItem>
)
}

return this.renderComponent(value, setValue, createElement)
return this.renderComponent(value, setValue, createElement, initialValue)
},
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@detools/vue-form",
"version": "2.7.6",
"version": "2.7.7",
"description": "Form State Management for VueJS",
"main": "VueForm/index.js",
"scripts": {
Expand Down

0 comments on commit 554c8d2

Please sign in to comment.