fix(form): fix set operations behaviors

This commit is contained in:
Hugo Pointcheval 2022-11-15 18:10:30 -05:00
parent 9ebe8e21dc
commit 72661a343f
Signed by: hugo
GPG Key ID: A9E8E9615379254F
3 changed files with 12 additions and 7 deletions

View File

@ -30,12 +30,6 @@ class FormDifference extends FormOperation {
FormInput<dynamic, FormInputValidator<dynamic, ValidationError>,
dynamic>>[];
for (final i in b.inputs) {
if (!a.containsKey(i.key)) {
inputs.add(i);
}
}
for (final i in a.inputs) {
if (!b.containsKey(i.key)) {
inputs.add(i);

View File

@ -32,7 +32,11 @@ class FormIntersection extends FormOperation {
for (final i in a.inputs) {
if (b.containsKey(i.key)) {
inputs.add(i);
if (i.validator.pure) {
inputs.add(b.inputOf(i.key));
} else {
inputs.add(i);
}
}
}

View File

@ -37,6 +37,13 @@ class FormUnion extends FormOperation {
for (final i in b.inputs) {
if (!a.containsKey(i.key)) {
inputs.add(i);
} else {
// if a input is pure, but not b, replace a one with b
if (a.isPureInput(i.key)) {
inputs
..remove(a.inputOf(i.key))
..add(i);
}
}
}