-
Notifications
You must be signed in to change notification settings - Fork 532
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better groups and new validation mechanic #484
Better groups and new validation mechanic #484
Conversation
Now instead of a global event bus for the whole component, a new one is created per instance and send down to children with props. |
Groups are working. There is a lot of changes. A group is a special type of field. {
type: "group",
legend: "My new group",
styleClasses: "nice-group",
tag: "section",
fields: [...]
} In a way, Now you can do that without problem (taken from the new grouping dev example) schema: {
fields: [
{
type: "group",
legend: "Contact Details",
tag: "div",
fields: [
{
type: "input",
model: "name",
label: "Name",
fieldOptions: {
inputType: "text"
},
required: true,
validator: ["required"]
},
{
type: "group",
legend: "Subgroup",
styleClasses: "subgroup",
tag: "fieldset",
fields: [
{
type: "input",
model: "subname",
label: "Name",
fieldOptions: {
inputType: "text"
},
required: true,
validator: ["required"]
}
]
},
{
type: "input",
model: "email",
label: "Email",
fieldOptions: {
inputType: "email"
}
}
]
},
{
type: "input",
model: "single",
label: "Single field (without group)",
fieldOptions: {
inputType: "text"
},
required: true,
validator: ["string"]
},
{
type: "group",
legend: "Other Details",
fields: [
{
type: "input",
model: "others.more",
label: "More",
fieldOptions: {
inputType: "text"
}
},
{
type: "input",
model: "others.things",
label: "Things",
fieldOptions: {
inputType: "text"
}
}
]
}
]
} Many things have been changed, I tried to stop using Lodash I also changed the way the fieldUID are created. Before, I was using the internal Now for the caveats and limitations I was able to detect. Manual validation return a promise and is asynchronous. Since everything communication through the event bus (and by event), there is no way to fall back toward synchronous validation for the whole form. <vue-form-generator ... ref="form"><vue-form-generator> /* Old way */
myManualValidation() {
let errors = this.$refs.form.validate();
if(errors.length > 0) {
// Validation error
console.warn("Error during validation", error);
} else {
// No validation errors
// ...
}
}
/* New way */
myManualValidation() {
this.$refs.form.validate().then(
() => {
// No validation errors
// ...
},
(error) => {
// Validation error
console.warn("Error during validation", error);
}
);
} |
I'm going to work on the validation states now. |
Use an event bus for most events Breaking: validate is a promise since now all validation is asynchronous
dc6e74a
to
2f83710
Compare
Update dep
I forgot to remove some big |
- Remove some skip - Fix some test
New group system and revamped validation system.
Group are not flexible enough #259
See Group are not flexible enough #259
Change schema for groups
This is still a WIP, I tried to modify the group first but faced many issue related to the current validation system.
So I went back and started to work on validation. Instead of using strongly bonded parent/child relationship, it now use an event bus. All event circulate on this event bus.
As of now, it is more of a POC than the final implementation.
I use the internal property "_uid" of vue objects
and I don't think you can use more than one vue-form-generator by page (they will use the same event bus and no id is created, so validation one vfg will trigger all the validation)EDIT: fixed.I'm going to tackle these issues first, then, implement groups. At this point, validation should be independent from structure and allow more flexible solutions.
@zoul0813 Please take a look if you have time and help me find unforeseen consequences.