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>
|
||||
</digi-typography>
|
||||
</msfa-layout>
|
||||
<msfa-loader *ngIf="submitIsLoading$ | async" type="absolute"></msfa-loader>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ChangeDetectionStrategy, Component } from '@angular/core';
|
||||
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
||||
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 { CommaSeparatedEmailValidator } from '@msfa-utils/validators/email.validator';
|
||||
import { RequiredValidator } from '@msfa-utils/validators/required.validator';
|
||||
@@ -18,6 +19,7 @@ export class EmployeeInviteComponent {
|
||||
});
|
||||
private _lastInvites$ = new BehaviorSubject<EmployeeInviteResponse>(null);
|
||||
lastInvites$: Observable<EmployeeInviteResponse> = this._lastInvites$.asObservable();
|
||||
submitIsLoading$ = new BehaviorSubject<boolean>(false);
|
||||
|
||||
constructor(private employeeService: EmployeeService) {}
|
||||
|
||||
@@ -82,8 +84,10 @@ export class EmployeeInviteComponent {
|
||||
}
|
||||
|
||||
submitForm(): void {
|
||||
this.submitIsLoading$.next(true);
|
||||
this._lastInvites$.next(null);
|
||||
if (this.formGroup.invalid) {
|
||||
this.submitIsLoading$.next(false);
|
||||
this.emailsControl.markAsDirty();
|
||||
this.emailsControl.markAsTouched();
|
||||
return;
|
||||
@@ -91,9 +95,14 @@ export class EmployeeInviteComponent {
|
||||
|
||||
const post = this.employeeService.postEmployeeInvitation(this.emailsControlValueAsArray).subscribe({
|
||||
next: data => {
|
||||
this.submitIsLoading$.next(false);
|
||||
this._lastInvites$.next(data);
|
||||
this.formGroup.reset();
|
||||
},
|
||||
error: error => {
|
||||
this.submitIsLoading$.next(false);
|
||||
throw new CustomError(error);
|
||||
},
|
||||
complete: () => {
|
||||
post.unsubscribe();
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { BackLinkModule } from '@msfa-shared/components/back-link/back-link.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';
|
||||
|
||||
@NgModule({
|
||||
@@ -17,6 +18,7 @@ import { EmployeeInviteComponent } from './employee-invite.component';
|
||||
BackLinkModule,
|
||||
ReactiveFormsModule,
|
||||
DigiNgFormTextareaModule,
|
||||
LoaderModule
|
||||
],
|
||||
})
|
||||
export class EmployeeInviteModule {}
|
||||
|
||||
Reference in New Issue
Block a user