Merged PR 425: #1314 B2C Geschäftliche Angaben Rechnungsadresse

#1314 B2C Geschäftliche Angaben Rechnungsadresse
This commit is contained in:
Lorenz Hilpert
2021-01-14 16:42:24 +00:00
3 changed files with 245 additions and 202 deletions

View File

@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { FormGroup, Validators } from '@angular/forms';
import { Component, OnDestroy, OnInit } from '@angular/core';
import { AbstractControl, FormGroup, Validators } from '@angular/forms';
import { Subscription } from 'rxjs';
import { PayerCreateComponent } from './payer-create.component';
@Component({
@@ -7,7 +8,29 @@ import { PayerCreateComponent } from './payer-create.component';
templateUrl: 'payer-create-b2c.component.html',
styleUrls: ['payer-create.component.scss'],
})
export class PayerCreateB2CComponent extends PayerCreateComponent {
export class PayerCreateB2CComponent extends PayerCreateComponent implements OnInit, OnDestroy {
formsSubscription: Subscription;
get organisationGroup(): AbstractControl {
return this.control?.get('organisation');
}
ngOnInit(): void {
super.ngOnInit();
this.formsSubscription = this.organisationGroup?.get('name').valueChanges.subscribe((value: string) => {
if (!value) {
this.organisationGroup.get('department').reset();
this.organisationGroup.get('vatId').reset();
}
});
}
ngOnDestroy(): void {
if (this.formsSubscription) {
this.formsSubscription.unsubscribe();
}
}
initForm(): FormGroup {
const fb = this.fb;

View File

@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { FormGroup, Validators } from '@angular/forms';
import { Component, OnDestroy } from '@angular/core';
import { AbstractControl, FormGroup, Validators } from '@angular/forms';
import { Subscription } from 'rxjs';
import { PayerEditComponent } from './payer-edit.component';
@Component({
@@ -7,11 +8,23 @@ import { PayerEditComponent } from './payer-edit.component';
templateUrl: 'payer-edit-b2c.component.html',
styleUrls: ['payer-edit.component.scss'],
})
export class PayerEditB2CComponent extends PayerEditComponent {
export class PayerEditB2CComponent extends PayerEditComponent implements OnDestroy {
formsSubscription: Subscription;
get organisationGroup(): AbstractControl {
return this.control?.get('organisation');
}
ngOnDestroy(): void {
if (this.formsSubscription) {
this.formsSubscription.unsubscribe();
}
}
async initForm() {
const fb = this.fb;
let payerDTO = await this.payer$.toPromise();
let isDefault = await this.isDefault$.toPromise();
const payerDTO = await this.payer$.toPromise();
const isDefault = await this.isDefault$.toPromise();
this.control = fb.group({
gender: fb.control(payerDTO?.gender || undefined, [Validators.required]),
@@ -34,5 +47,12 @@ export class PayerEditB2CComponent extends PayerEditComponent {
isDefault: fb.control(isDefault),
});
this.cdr.markForCheck();
this.formsSubscription = this.organisationGroup?.get('name').valueChanges.subscribe((value: string) => {
if (!value) {
this.organisationGroup.get('department').reset();
this.organisationGroup.get('vatId').reset();
}
});
}
}

388
package-lock.json generated
View File

File diff suppressed because it is too large Load Diff