Merge pull request #192 in TEA/mina-sidor-fa-web from feature/TV-728 to develop
Squashed commit of the following: commit 6d938f7763970f97721fd904c51a5a0f6f782db1 Author: fueno <nicolas.fuentes-maturana@arbetsformedlingen.se> Date: Tue Oct 12 09:24:47 2021 +0200 TV-728 show spinner during invitation posting
This commit is contained in:
@@ -81,3 +81,4 @@
|
|||||||
</section>
|
</section>
|
||||||
</digi-typography>
|
</digi-typography>
|
||||||
</msfa-layout>
|
</msfa-layout>
|
||||||
|
<msfa-loader *ngIf="submitIsLoading$ | async" type="absolute"></msfa-loader>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||||
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { EmployeeInviteResponse } from '@msfa-models/api/employee-invite.response.model';
|
import { EmployeeInviteResponse } from '@msfa-models/api/employee-invite.response.model';
|
||||||
|
import { CustomError } from '@msfa-models/error/custom-error';
|
||||||
import { EmployeeService } from '@msfa-services/api/employee.service';
|
import { EmployeeService } from '@msfa-services/api/employee.service';
|
||||||
import { CommaSeparatedEmailValidator } from '@msfa-utils/validators/email.validator';
|
import { CommaSeparatedEmailValidator } from '@msfa-utils/validators/email.validator';
|
||||||
import { RequiredValidator } from '@msfa-utils/validators/required.validator';
|
import { RequiredValidator } from '@msfa-utils/validators/required.validator';
|
||||||
@@ -18,6 +19,7 @@ export class EmployeeInviteComponent {
|
|||||||
});
|
});
|
||||||
private _lastInvites$ = new BehaviorSubject<EmployeeInviteResponse>(null);
|
private _lastInvites$ = new BehaviorSubject<EmployeeInviteResponse>(null);
|
||||||
lastInvites$: Observable<EmployeeInviteResponse> = this._lastInvites$.asObservable();
|
lastInvites$: Observable<EmployeeInviteResponse> = this._lastInvites$.asObservable();
|
||||||
|
submitIsLoading$ = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
constructor(private employeeService: EmployeeService) {}
|
constructor(private employeeService: EmployeeService) {}
|
||||||
|
|
||||||
@@ -82,8 +84,10 @@ export class EmployeeInviteComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitForm(): void {
|
submitForm(): void {
|
||||||
|
this.submitIsLoading$.next(true);
|
||||||
this._lastInvites$.next(null);
|
this._lastInvites$.next(null);
|
||||||
if (this.formGroup.invalid) {
|
if (this.formGroup.invalid) {
|
||||||
|
this.submitIsLoading$.next(false);
|
||||||
this.emailsControl.markAsDirty();
|
this.emailsControl.markAsDirty();
|
||||||
this.emailsControl.markAsTouched();
|
this.emailsControl.markAsTouched();
|
||||||
return;
|
return;
|
||||||
@@ -91,9 +95,14 @@ export class EmployeeInviteComponent {
|
|||||||
|
|
||||||
const post = this.employeeService.postEmployeeInvitation(this.emailsControlValueAsArray).subscribe({
|
const post = this.employeeService.postEmployeeInvitation(this.emailsControlValueAsArray).subscribe({
|
||||||
next: data => {
|
next: data => {
|
||||||
|
this.submitIsLoading$.next(false);
|
||||||
this._lastInvites$.next(data);
|
this._lastInvites$.next(data);
|
||||||
this.formGroup.reset();
|
this.formGroup.reset();
|
||||||
},
|
},
|
||||||
|
error: error => {
|
||||||
|
this.submitIsLoading$.next(false);
|
||||||
|
throw new CustomError(error);
|
||||||
|
},
|
||||||
complete: () => {
|
complete: () => {
|
||||||
post.unsubscribe();
|
post.unsubscribe();
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ReactiveFormsModule } from '@angular/forms';
|
|||||||
import { RouterModule } from '@angular/router';
|
import { RouterModule } from '@angular/router';
|
||||||
import { BackLinkModule } from '@msfa-shared/components/back-link/back-link.module';
|
import { BackLinkModule } from '@msfa-shared/components/back-link/back-link.module';
|
||||||
import { LayoutModule } from '@msfa-shared/components/layout/layout.module';
|
import { LayoutModule } from '@msfa-shared/components/layout/layout.module';
|
||||||
|
import { LoaderModule } from '@msfa-shared/components/loader/loader.module';
|
||||||
import { EmployeeInviteComponent } from './employee-invite.component';
|
import { EmployeeInviteComponent } from './employee-invite.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
@@ -17,6 +18,7 @@ import { EmployeeInviteComponent } from './employee-invite.component';
|
|||||||
BackLinkModule,
|
BackLinkModule,
|
||||||
ReactiveFormsModule,
|
ReactiveFormsModule,
|
||||||
DigiNgFormTextareaModule,
|
DigiNgFormTextareaModule,
|
||||||
|
LoaderModule
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class EmployeeInviteModule {}
|
export class EmployeeInviteModule {}
|
||||||
|
|||||||
Reference in New Issue
Block a user