diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
index 795c3a51a6d..c3cdf276495 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.html
@@ -310,7 +310,9 @@
-
+
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
index 8eaa104a260..fcb448d1ab0 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
+++ b/ui/ui-frontend/projects/identity/src/app/customer/customer-create/customer-create.component.ts
@@ -37,14 +37,14 @@
import { ComponentType } from '@angular/cdk/portal';
import { Component, Inject, OnDestroy, OnInit, TemplateRef } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
-import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
-import { merge, Observable, Subject } from 'rxjs';
-import { filter, takeUntil } from 'rxjs/operators';
+import { MAT_DIALOG_DATA, MatDialog, MatDialogRef } from '@angular/material/dialog';
+import { merge, Observable, Subscription } from 'rxjs';
+import { filter, finalize } from 'rxjs/operators';
import { ConfirmDialogService, CountryOption, CountryService, Customer, Logo, OtpState, StartupService } from 'ui-frontend-common';
import { CustomerService } from '../../core/customer.service';
import { TenantFormValidators } from '../tenant-create/tenant-form.validators';
import { CustomerAlertingComponent } from './customer-alerting/customer-alerting.component';
-import { ALPHA_NUMERIC_REGEX, CustomerCreateValidators, CUSTOMER_CODE_MAX_LENGTH } from './customer-create.validators';
+import { ALPHA_NUMERIC_REGEX, CUSTOMER_CODE_MAX_LENGTH, CustomerCreateValidators } from './customer-create.validators';
interface CustomerInfo {
code: string;
@@ -65,30 +65,36 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
public form: FormGroup;
public hasError = true;
public message: string;
- public creating = false;
+ public isLoading = false;
public customerInfo: CustomerInfo = {
code: null,
name: null,
companyName: null,
};
+
public get customerForm(): FormGroup {
return this._customerForm;
}
+
public set customerForm(form: FormGroup) {
this._customerForm = form;
}
+
public logos: Logo[];
public countries: CountryOption[];
public portalTitles: { [language: string]: string };
public portalMessages: { [language: string]: string };
+
public get homepageMessageForm(): FormGroup {
return this._homepageMessageForm;
}
+
public set homepageMessageForm(form: FormGroup) {
this._homepageMessageForm = form;
}
+
gdprReadOnlyStatus: boolean;
- private destroy = new Subject();
+ private subscription: Subscription;
// tslint:disable-next-line: variable-name
private _homepageMessageForm: FormGroup;
// tslint:disable-next-line: variable-name
@@ -157,10 +163,7 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
this.customer = customerDetails;
});
- this.confirmDialogService
- .listenToEscapeKeyPress(this.dialogRef)
- .pipe(takeUntil(this.destroy))
- .subscribe(() => this.onCancel());
+ this.subscription = this.confirmDialogService.listenToEscapeKeyPress(this.dialogRef).subscribe(() => this.onCancel());
this.countryService.getAvailableCountries().subscribe((values: CountryOption[]) => {
this.countries = values;
@@ -168,7 +171,7 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
}
ngOnDestroy() {
- this.destroy.next();
+ this.subscription.unsubscribe();
}
onChanges() {
@@ -206,18 +209,17 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
if (this.lastStepIsInvalid() || this.stepIndex !== this.stepCount - 1) {
return;
}
- this.creating = true;
+ this.isLoading = true;
const customer: Customer = this.getCustomerFromForm();
this.customerService
.create(customer, this.logos)
- .pipe(takeUntil(this.destroy))
+ .pipe(finalize(() => (this.isLoading = false)))
.subscribe(
() => {
this.dialogRef.close(true);
},
(error) => {
- this.creating = false;
console.error(error);
},
);
@@ -312,6 +314,6 @@ export class CustomerCreateComponent implements OnInit, OnDestroy {
lastStepIsInvalid(): boolean {
const invalid = this.firstStepInvalid() || this.secondStepInvalid() || !this.thirdStepValid() || !this.fourthStepValid();
- return this.form.pending || this.form.invalid || invalid || this.creating;
+ return this.form.pending || this.form.invalid || invalid || this.isLoading;
}
}
diff --git a/ui/ui-frontend/projects/identity/src/app/customer/owner-create/owner-create.component.html b/ui/ui-frontend/projects/identity/src/app/customer/owner-create/owner-create.component.html
index 03c30d814d1..e9e49283638 100644
--- a/ui/ui-frontend/projects/identity/src/app/customer/owner-create/owner-create.component.html
+++ b/ui/ui-frontend/projects/identity/src/app/customer/owner-create/owner-create.component.html
@@ -11,10 +11,10 @@
-