Commits

Nicolai Olsen authored fa2b50dc510
Fixed a bug where DataCard got wrapped twice.
No tags

src/app/measurements/measurements-screenings/measurements-screenings.component.ts

Modified
13 13 @Component({
14 14 selector: 'app-measurements-screenings',
15 15 templateUrl: './measurements-screenings.component.html',
16 16 styleUrls: ['./measurements-screenings.component.scss'],
17 17 providers: [APP_MEASUREMENTS_SCREENINGS_CONTROL_VALUE_ACCESSOR],
18 18 viewProviders: [ { provide: ControlContainer, useExisting: NgForm } ]
19 19 })
20 20 export class MeasurementsScreeningsComponent implements ControlValueAccessor {
21 21 private innerModel: DataCardWrapper | undefined;
22 22 private dirtyAble = false;
23 - private onChangeCallback: (newValue: DataCardWrapper | undefined) => any = () => {};
23 + private onChangeCallback: (newValue: DataCard | undefined) => any = () => {};
24 24 private onTouchedCallback: () => any = () => {};
25 25 constructor() {
26 26 }
27 27
28 28 registerOnChange(fn: any): void {
29 29 this.onChangeCallback = fn;
30 30 }
31 31
32 32 registerOnTouched(fn: any): void {
33 33 this.onTouchedCallback = fn;
34 34 }
35 35
36 36 writeValue(newValue: DataCard): void {
37 37 this.value = new DataCardWrapper(newValue);
38 38 }
39 39 get value(): DataCardWrapper | undefined {
40 40 return this.innerModel;
41 41 }
42 42
43 43 set value(value: DataCardWrapper | undefined) {
44 - if (!deepEqual(value, this.innerModel)) {
44 + if (!deepEqual(value?.asDataCard, this.innerModel?.asDataCard)) {
45 45 this.innerModel = value;
46 46 if (this.dirtyAble) {
47 - this.onChangeCallback(value);
47 + this.onChangeCallback(value?.asDataCard);
48 48 }
49 49 if (!this.dirtyAble && this.innerModel) { // We don't want to mark the field as dirty while data gets initialized
50 50 this.dirtyAble = true;
51 51 }
52 52 }
53 53 }
54 54 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut