feat(employees): Implemented loader inside employees-list when pagination/filtering. (TV-597)
Squashed commit of the following: commit 9e41609f515909fac8618f8cae9ce29409e62748 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Thu Sep 16 07:36:21 2021 +0200 Removed old classes commit 7be9f46dcd08be3cdec5e92bb237ad8fa6d1c373 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Wed Sep 15 14:23:53 2021 +0200 Added new loader component and implmented loader inside employees-list
This commit is contained in:
@@ -19,9 +19,4 @@
|
||||
<msfa-footer class="msfa__footer"></msfa-footer>
|
||||
</div>
|
||||
|
||||
<div
|
||||
*ngIf="(userLoading$ | async) || (rolesLoading$ | async)"
|
||||
class="msfa__loading-wrapper msfa__loading-wrapper--full-screen"
|
||||
>
|
||||
<digi-icon-spinner class="msfa__spinner"></digi-icon-spinner>
|
||||
</div>
|
||||
<msfa-loader *ngIf="(userLoading$ | async) || (rolesLoading$ | async)" [fullScreen]="true"></msfa-loader>
|
||||
|
||||
@@ -4,6 +4,7 @@ import { HttpClient } from '@angular/common/http';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { MarkdownModule } from 'ngx-markdown';
|
||||
import { LoaderModule } from '../loader/loader.module';
|
||||
import { FooterModule } from './components/footer/footer.module';
|
||||
import { NavigationModule } from './components/navigation/navigation.module';
|
||||
import { SidebarModule } from './components/sidebar/sidebar.module';
|
||||
@@ -22,6 +23,7 @@ import { LayoutComponent } from './layout.component';
|
||||
FooterModule,
|
||||
MarkdownModule.forRoot({ loader: HttpClient }),
|
||||
DigiNgNavigationBreadcrumbsModule,
|
||||
LoaderModule,
|
||||
],
|
||||
exports: [LayoutComponent],
|
||||
})
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<div [ngClass]="classes">
|
||||
<digi-icon-spinner class="loader__spinner"></digi-icon-spinner>
|
||||
</div>
|
||||
@@ -0,0 +1,22 @@
|
||||
@import 'mixins/backdrop';
|
||||
|
||||
@keyframes spinning {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.loader {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
&--full-screen {
|
||||
@include msfa__backdrop(1000);
|
||||
}
|
||||
|
||||
&__spinner {
|
||||
display: inline-flex;
|
||||
animation: spinning 1s linear infinite;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { LoaderComponent } from './loader.component';
|
||||
|
||||
describe('LoaderComponent', () => {
|
||||
let component: LoaderComponent;
|
||||
let fixture: ComponentFixture<LoaderComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
void TestBed.configureTestingModule({
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
declarations: [LoaderComponent],
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LoaderComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,19 @@
|
||||
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'msfa-loader',
|
||||
templateUrl: './loader.component.html',
|
||||
styleUrls: ['./loader.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class LoaderComponent {
|
||||
private readonly _defaultClass = 'loader';
|
||||
@Input() fullScreen = false;
|
||||
|
||||
get classes(): string {
|
||||
if (this.fullScreen) {
|
||||
return `${this._defaultClass} ${this._defaultClass}--full-screen`;
|
||||
}
|
||||
return this._defaultClass;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { DigiNgDialogModule } from '@af/digi-ng/_dialog/dialog';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
|
||||
import { LoaderComponent } from './loader.component';
|
||||
|
||||
@NgModule({
|
||||
schemas: [CUSTOM_ELEMENTS_SCHEMA],
|
||||
declarations: [LoaderComponent],
|
||||
imports: [CommonModule, DigiNgDialogModule],
|
||||
exports: [LoaderComponent],
|
||||
})
|
||||
export class LoaderModule {}
|
||||
@@ -44,6 +44,8 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
public lastDeletedEmployee$: Observable<Employee> = this._lastDeletedEmployee$.asObservable();
|
||||
private _employeeToDelete$ = new BehaviorSubject<Employee>(null);
|
||||
public employeeToDelete$: Observable<Employee> = this._employeeToDelete$.asObservable();
|
||||
private _employeesLoading$ = new BehaviorSubject<boolean>(false);
|
||||
public employeesLoading$: Observable<boolean> = this._employeesLoading$.asObservable();
|
||||
|
||||
constructor(private httpClient: HttpClient, private errorService: ErrorService) {
|
||||
super();
|
||||
@@ -110,11 +112,13 @@ export class EmployeeService extends UnsubscribeDirective {
|
||||
if (onlyEmployeesWithoutAuthorization) {
|
||||
params.onlyEmployeesWithoutAuthorization = onlyEmployeesWithoutAuthorization?.toString();
|
||||
}
|
||||
this._employeesLoading$.next(true);
|
||||
|
||||
return this.httpClient
|
||||
.get<EmployeesDataResponse>(this._apiBaseUrl, { params })
|
||||
.pipe(
|
||||
map(({ data, meta }) => {
|
||||
this._employeesLoading$.next(false);
|
||||
return { data: data.map(employee => mapResponseToEmployeeCompact(employee)), meta };
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user