Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit c429f3d

Browse files
committed
Release v0.1.0
1 parent 7c860c1 commit c429f3d

File tree

4 files changed

+43
-39
lines changed

4 files changed

+43
-39
lines changed

CHANGELOG.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
![repository-banner.png](https://res.cloudinary.com/alvarosaburido/image/upload/v1564929632/as-readme-banner_tqdgrx.png)
1+
# Changelog
22

3-
## Software version
3+
All notable changes to this project will be documented in this file.
44

5-
- `node -v` : v12.4.0
6-
- `npm -v` : v6.4.1
7-
- `yarn -v`: 1.9.4
8-
- `vue --version`:3.0.3
9-
- `webpack -v` : v4.1.1
5+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
107

11-
---
8+
## 0.1.0 - 2020-22-03
129

13-
# Vue Dynamic Forms
10+
### Added
11+
12+
- Dynamic Forms component
13+
- Dynamic Input component
14+
- Input text, select, checkbox, textarea, radio
15+
- Validators

src/components/dynamic-form/DynamicForm.js

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,6 @@ const methods = {
3838
field =>
3939
new FormControl({
4040
...field,
41-
valid: true,
42-
touched: false,
43-
dirty: false,
44-
errors: {},
4541
}),
4642
);
4743
},
@@ -87,34 +83,32 @@ const computed = {
8783
return control ? control.valid : true;
8884
},
8985
allErrors() {
90-
return (
91-
this.controls &&
92-
this.controls.reduce((prev, curr) => {
93-
const errors = Object.keys(curr.errors) || [];
94-
if (errors.length > 0) {
95-
const error = {};
96-
error[curr.name] = curr.errors;
86+
return this.controls
87+
? this.controls.reduce((prev, curr) => {
88+
const errors = Object.keys(curr.errors) || [];
89+
if (errors.length > 0) {
90+
const error = {};
91+
error[curr.name] = curr.errors;
92+
return {
93+
...prev,
94+
...error,
95+
};
96+
}
97+
return prev;
98+
}, {})
99+
: {};
100+
},
101+
values() {
102+
return this.controls
103+
? this.controls.reduce((prev, curr) => {
104+
const obj = {};
105+
obj[curr.name] = curr.value;
97106
return {
98107
...prev,
99-
...error,
108+
...obj,
100109
};
101-
}
102-
return prev;
103-
}, {})
104-
);
105-
},
106-
values() {
107-
return (
108-
this.controls &&
109-
this.controls.reduce((prev, curr) => {
110-
const obj = {};
111-
obj[curr.name] = curr.value;
112-
return {
113-
...prev,
114-
...obj,
115-
};
116-
}, {})
117-
);
110+
}, {})
111+
: {};
118112
},
119113
};
120114

src/components/dynamic-form/DynamicForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
>
1212
<input type="hidden" name="form-name" :value="id" />
1313
<dynamic-input
14-
v-for="field in fields"
14+
v-for="field in controls"
1515
:key="field.name"
1616
:form-control="field"
1717
/>

src/core/utils/form-control.model.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export function FormControl({
66
name = null,
77
options = [],
88
placeholder = null,
9+
errors = {},
10+
valid = true,
11+
touched = false,
12+
dirty = false,
913
}) {
1014
this.type = type;
1115
this.value = value;
@@ -14,6 +18,10 @@ export function FormControl({
1418
this.name = name;
1519
this.options = options;
1620
this.placeholder = placeholder;
21+
this.errors = errors;
22+
this.valid = valid;
23+
this.touched = touched;
24+
this.dirty = dirty;
1725
}
1826

1927
export function FormField({

0 commit comments

Comments
 (0)