#1567 Popup Adressvorschläge

This commit is contained in:
Lorenz Hilpert
2021-03-25 15:55:49 +01:00
parent 2f0807396d
commit d71e506c07
6 changed files with 115 additions and 12 deletions

View File

@@ -127,7 +127,14 @@ export class CustomerCreateB2BComponent extends CustomerCreateComponentBase impl
try {
const address = await this.addressSelectionModal.validateAddress(this.control.value.address);
if (address) {
this.control.patchValue({ address });
if (typeof address === 'string') {
if (address === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ address });
}
}
} catch (error) {
this.setValidationError(error.error?.invalidProperties, this.control.get('address'));
@@ -138,7 +145,14 @@ export class CustomerCreateB2BComponent extends CustomerCreateComponentBase impl
if (this.control.value.differentShippingAddress) {
const shippingAddress = await this.addressSelectionModal.validateAddress(this.control.value.shippingAddress.address);
if (shippingAddress) {
this.control.patchValue({ shippingAddress });
if (typeof shippingAddress === 'string') {
if (shippingAddress === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ shippingAddress });
}
}
}
} catch (error) {
@@ -163,7 +177,7 @@ export class CustomerCreateB2BComponent extends CustomerCreateComponentBase impl
}
if (response.error) {
this.control.enable();
this.enableControl();
throw new Error(response.message);
} else {
this.removeBreadcrumb();
@@ -173,4 +187,15 @@ export class CustomerCreateB2BComponent extends CustomerCreateComponentBase impl
this.setValidationError(error.error?.invalidProperties, this.control);
}
}
enableControl() {
this.control.enable();
if (!this.control.get('differentShippingAddress').value) {
this.control.get('differentShippingAddress').disable();
}
this.control.markAllAsTouched();
this.control.updateValueAndValidity();
}
}

View File

@@ -131,7 +131,14 @@ export class CustomerCreateBranchComponent extends CustomerCreateComponentBase i
try {
let address = await this.addressSelectionModal.validateAddress(this.control.value.address);
if (address) {
this.control.patchValue({ address });
if (typeof address === 'string') {
if (address === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ address });
}
}
} catch (error) {
this.setValidationError(error.error?.invalidProperties, this.control.get('address'));
@@ -142,7 +149,14 @@ export class CustomerCreateBranchComponent extends CustomerCreateComponentBase i
if (this.control.value.differentShippingAddress) {
const shippingAddress = await this.addressSelectionModal.validateAddress(this.control.value.shippingAddress.address);
if (shippingAddress) {
this.control.patchValue({ shippingAddress });
if (typeof shippingAddress === 'string') {
if (shippingAddress === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ shippingAddress });
}
}
}
} catch (error) {
@@ -167,6 +181,7 @@ export class CustomerCreateBranchComponent extends CustomerCreateComponentBase i
}
if (response.error) {
this.enableControl();
throw new Error(response.message);
} else {
this.removeBreadcrumb();
@@ -176,4 +191,15 @@ export class CustomerCreateBranchComponent extends CustomerCreateComponentBase i
this.setValidationError(error.error?.invalidProperties, this.control);
}
}
enableControl() {
this.control.enable();
if (!this.control.get('differentShippingAddress').value) {
this.control.get('differentShippingAddress').disable();
}
this.control.markAllAsTouched();
this.control.updateValueAndValidity();
}
}

View File

@@ -133,7 +133,14 @@ export class CustomerCreateGuestComponent extends CustomerCreateComponentBase im
try {
const address = await this.addressSelectionModal.validateAddress(this.control.value.address);
if (address) {
this.control.patchValue({ address });
if (typeof address === 'string') {
if (address === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ address });
}
}
} catch (error) {
this.setValidationError(error.error?.invalidProperties, this.control.get('address'));
@@ -144,7 +151,14 @@ export class CustomerCreateGuestComponent extends CustomerCreateComponentBase im
if (this.control.value.differentShippingAddress) {
const shippingAddress = await this.addressSelectionModal.validateAddress(this.control.value.shippingAddress.address);
if (shippingAddress) {
this.control.patchValue({ shippingAddress });
if (typeof shippingAddress === 'string') {
if (shippingAddress === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ shippingAddress });
}
}
}
} catch (error) {
@@ -180,6 +194,7 @@ export class CustomerCreateGuestComponent extends CustomerCreateComponentBase im
}
if (response.error) {
this.enableControl();
throw new Error(response.message);
} else {
this.removeBreadcrumb();
@@ -189,4 +204,15 @@ export class CustomerCreateGuestComponent extends CustomerCreateComponentBase im
this.setValidationError(error.error?.invalidProperties, this.control);
}
}
enableControl() {
this.control.enable();
if (!this.control.get('differentShippingAddress').value) {
this.control.get('differentShippingAddress').disable();
}
this.control.markAllAsTouched();
this.control.updateValueAndValidity();
}
}

View File

@@ -172,7 +172,14 @@ export class CustomerCreateOnlineComponent extends CustomerCreateComponentBase i
try {
let address = await this.addressSelectionModal.validateAddress(this.control.value.address);
if (address) {
this.control.patchValue({ address });
if (typeof address === 'string') {
if (address === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ address });
}
}
} catch (error) {
this.setValidationError(error.error?.invalidProperties, this.control.get('address'));
@@ -183,7 +190,14 @@ export class CustomerCreateOnlineComponent extends CustomerCreateComponentBase i
if (this.control.value.differentShippingAddress) {
const shippingAddress = await this.addressSelectionModal.validateAddress(this.control.value.shippingAddress.address);
if (shippingAddress) {
this.control.get('shippingAddress').patchValue({ address: shippingAddress });
if (typeof shippingAddress === 'string') {
if (shippingAddress === 'close') {
this.enableControl();
return;
}
} else {
this.control.patchValue({ shippingAddress });
}
}
}
} catch (error) {
@@ -211,6 +225,7 @@ export class CustomerCreateOnlineComponent extends CustomerCreateComponentBase i
const response = await this.customerService.createOnlineCustomer(newCustomer).toPromise();
if (response.error) {
this.enableControl();
throw new Error(response.message);
} else {
this.removeBreadcrumb();
@@ -232,4 +247,15 @@ export class CustomerCreateOnlineComponent extends CustomerCreateComponentBase i
const indexOfAt = email.indexOf('@');
this.invalidDomainEmails.push(email.substring(indexOfAt));
}
enableControl() {
this.control.enable();
if (!this.control.get('differentShippingAddress').value) {
this.control.get('differentShippingAddress').disable();
}
this.control.markAllAsTouched();
this.control.updateValueAndValidity();
}
}

View File

@@ -1,6 +1,6 @@
<div class="wrapper">
<div class="actions">
<button class="close-btn" (click)="ref.close()">
<button class="close-btn" (click)="ref.close('close')">
<ui-icon icon="close" size="21px"></ui-icon>
</button>
</div>
@@ -16,6 +16,6 @@
</ul>
<div class="center">
<button class="select-btn" (click)="ref.close()">Eingegebene Adresse übernehmen</button>
<button class="select-btn" (click)="ref.close('continue')">Eingegebene Adresse übernehmen</button>
</div>
</div>

View File

@@ -9,5 +9,5 @@ import { UiModalRef } from '@ui/modal';
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AddressSelectionModalComponent {
constructor(public ref: UiModalRef<AddressDTO[]>) {}
constructor(public ref: UiModalRef<AddressDTO[] | string>) {}
}