Skip to content
Snippets Groups Projects
Verified Commit c324a9bd authored by Sebastian Bergandy's avatar Sebastian Bergandy :keyboard:
Browse files

OZG-6988 implement navigation

Sub task: OZG-7446
parent 5b7a5d82
No related branches found
No related tags found
1 merge request!27OZG-6988 implement button
Showing
with 124 additions and 103 deletions
......@@ -28,6 +28,7 @@ import { Route } from '@angular/router';
import { OrganisationsEinheitFormPageComponent } from '../pages/organisationseinheit/organisationseinheit-form-page/organisationseinheit-form-page.component';
import { OrganisationsEinheitPageComponent } from '../pages/organisationseinheit/organisationseinheit-page/organisationseinheit-page.component';
import { PostfachPageComponent } from '../pages/postfach/postfach-page/postfach-page.component';
import { AppStatistikFieldsFormPageComponent } from '../pages/statistik/statistik-fields-form-page/app-statistik-fields-form-page.component';
import { StatistikPageComponent } from '../pages/statistik/statistik-page/statistik-page.component';
import { UnavailablePageComponent } from '../pages/unavailable/unavailable-page/unavailable-page.component';
import { UserAddPageComponent } from '../pages/users-roles/user-add-page/user-add-page.component';
......@@ -37,6 +38,7 @@ import { apiRootGuard, configurationGuard } from './app.guard';
export interface GuardData {
linkRelName: string;
}
export const appRoutes: Route[] = [
{
path: '',
......@@ -86,4 +88,11 @@ export const appRoutes: Route[] = [
canActivate: [configurationGuard],
data: <GuardData>{ linkRelName: ConfigurationLinkRel.AGGREGATION_MAPPINGS },
},
{
path: ROUTES.STATISTIK_NEU,
component: AppStatistikFieldsFormPageComponent,
title: 'Admin | Statistik weitere Felder auswerten',
canActivate: [configurationGuard],
data: <GuardData>{ linkRelName: ConfigurationLinkRel.AGGREGATION_MAPPINGS },
},
];
<admin-statistik-fields-form data-test-id="evaluate-fields-form"></admin-statistik-fields-form>
\ No newline at end of file
import { existsAsHtmlElement } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MockComponent } from 'ng-mocks';
import { AdminStatistikFieldsFormComponent } from '../../../../../../libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component';
import { getDataTestIdOf } from '../../../../../../libs/tech-shared/test/data-test';
import { AppStatistikFieldsFormPageComponent } from './app-statistik-fields-form-page.component';
describe('AppStatistikFieldsFormPageComponent', () => {
let component: AppStatistikFieldsFormPageComponent;
let fixture: ComponentFixture<AppStatistikFieldsFormPageComponent>;
const evaluateFieldsForm: string = getDataTestIdOf('evaluate-fields-form');
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [AppStatistikFieldsFormPageComponent, MockComponent(AdminStatistikFieldsFormComponent)],
}).compileComponents();
fixture = TestBed.createComponent(AppStatistikFieldsFormPageComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('template', () => {
describe('weiter felder auswerten form', () => {
it('should exists', () => {
fixture.detectChanges();
existsAsHtmlElement(fixture, evaluateFieldsForm);
});
});
});
});
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { AdminStatistikFieldsFormComponent } from '../../../../../../libs/admin/statistik/src/lib/statistik-fields-form/admin-statistik-fields-form.component';
@Component({
selector: 'app-app-statistik-fields-form-page',
standalone: true,
imports: [CommonModule, AdminStatistikFieldsFormComponent],
templateUrl: './app-statistik-fields-form-page.component.html',
})
export class AppStatistikFieldsFormPageComponent {}
......@@ -28,4 +28,5 @@ export const ROUTES = {
ORGANISATIONSEINHEITEN: 'organisationseinheiten',
UNAVAILABLE: 'unavailable',
STATISTIK: 'statistik',
STATISTIK_NEU: 'statistik/neu',
};
......@@ -24,17 +24,10 @@
-->
<h1 class="heading-1" data-test-id="statistik-header-text">Statistik</h1>
@if (evaluateAdditionalFields) {
<admin-statistik-fields-form
(cancel)="hideEvaluateFieldsForm()"
data-test-id="statistik-fields-form"
></admin-statistik-fields-form>
} @else {
<div class="mt-4">
<ods-button
text="Weitere Felder auswerten"
(clickEmitter)="showEvaluateFieldsForm()"
(clickEmitter)="navigateToStatistikFieldsForm()"
data-test-id="weitere-felder-auswerten-button"
></ods-button>
</div>
}
......@@ -21,7 +21,9 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { existsAsHtmlElement, notExistsAsHtmlElement, triggerEvent } from '@alfa-client/test-utils';
import { ROUTES } from '@admin-client/shared';
import { NavigationService } from '@alfa-client/navigation-shared';
import { existsAsHtmlElement, mock, Mock, triggerEvent } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { getDataTestIdOf } from '../../../../../tech-shared/test/data-test';
import { StatistikContainerComponent } from './statistik-container.component';
......@@ -31,11 +33,22 @@ describe('StatistikContainerComponent', () => {
let fixture: ComponentFixture<StatistikContainerComponent>;
const evaluateAdditionalFieldsTestId: string = getDataTestIdOf('weitere-felder-auswerten-button');
const statistikFieldsFormTestId: string = getDataTestIdOf('statistik-fields-form');
let navigationService: Mock<NavigationService>;
beforeEach(() => {
navigationService = mock(NavigationService);
});
beforeEach(async () => {
await TestBed.configureTestingModule({
imports: [StatistikContainerComponent],
providers: [
{
provide: NavigationService,
useValue: navigationService,
},
],
});
});
......@@ -51,28 +64,11 @@ describe('StatistikContainerComponent', () => {
expect(component).toBeTruthy();
});
it('should set default values', () => {
expect(component.evaluateAdditionalFields).toBeDefined();
expect(component.evaluateAdditionalFields).toBeFalsy();
});
describe('showEvaluateFieldsForm', () => {
it('should update component state', () => {
component.evaluateAdditionalFields = false;
component.showEvaluateFieldsForm();
expect(component.evaluateAdditionalFields).toBeTruthy();
});
});
describe('hideEvaluateFieldsForm', () => {
it('should update component state', () => {
component.evaluateAdditionalFields = true;
component.hideEvaluateFieldsForm();
describe('navigateToStatistikFieldsForm', () => {
it('should call navigation service', () => {
component.navigateToStatistikFieldsForm();
expect(component.evaluateAdditionalFields).toBeFalsy();
expect(navigationService.navigate).toHaveBeenCalledWith(ROUTES.STATISTIK_NEU);
});
});
});
......@@ -85,19 +81,10 @@ describe('StatistikContainerComponent', () => {
existsAsHtmlElement(fixture, evaluateAdditionalFieldsTestId);
});
it('should NOT exists', () => {
component.evaluateAdditionalFields = true;
fixture.detectChanges();
notExistsAsHtmlElement(fixture, evaluateAdditionalFieldsTestId);
});
describe('output', () => {
describe('clickEmitter', () => {
it('should call handler', () => {
component.showEvaluateFieldsForm = jest.fn();
component.evaluateAdditionalFields = false;
component.navigateToStatistikFieldsForm = jest.fn();
fixture.detectChanges();
triggerEvent({
......@@ -106,43 +93,7 @@ describe('StatistikContainerComponent', () => {
name: 'clickEmitter',
});
expect(component.showEvaluateFieldsForm).toHaveBeenCalled();
});
});
});
});
describe('statistik fields form', () => {
it('should exists', () => {
component.evaluateAdditionalFields = true;
fixture.detectChanges();
existsAsHtmlElement(fixture, statistikFieldsFormTestId);
});
it('should NOT exists', () => {
component.evaluateAdditionalFields = false;
fixture.detectChanges();
notExistsAsHtmlElement(fixture, statistikFieldsFormTestId);
});
describe('output', () => {
describe('cancel', () => {
it('should hide form', () => {
component.evaluateAdditionalFields = true;
component.hideEvaluateFieldsForm = jest.fn();
fixture.detectChanges();
triggerEvent({
fixture,
elementSelector: statistikFieldsFormTestId,
name: 'cancel',
});
expect(component.hideEvaluateFieldsForm).toHaveBeenCalled();
expect(component.navigateToStatistikFieldsForm).toHaveBeenCalled();
});
});
});
......
......@@ -21,25 +21,22 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen.
*/
import { ROUTES } from '@admin-client/shared';
import { NavigationService } from '@alfa-client/navigation-shared';
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { ButtonComponent } from '@ods/system';
import { AdminStatistikFieldsFormComponent } from './statistik-fields-form/admin-statistik-fields-form.component';
@Component({
selector: 'admin-statistik-container',
templateUrl: './statistik-container.component.html',
standalone: true,
imports: [CommonModule, ButtonComponent, AdminStatistikFieldsFormComponent],
imports: [CommonModule, ButtonComponent],
})
export class StatistikContainerComponent {
public evaluateAdditionalFields: boolean = false;
private readonly navigationService = inject(NavigationService);
public showEvaluateFieldsForm(): void {
this.evaluateAdditionalFields = true;
}
public hideEvaluateFieldsForm(): void {
this.evaluateAdditionalFields = false;
public navigateToStatistikFieldsForm(): void {
this.navigationService.navigate(ROUTES.STATISTIK_NEU);
}
}
......@@ -30,7 +30,7 @@
<div class="mt-4 flex gap-4">
<ods-button text="Speichern" data-test-id="save-statistik-fields-button"></ods-button>
<ods-button text="Abbrechen" variant="outline" (clickEmitter)="cancel.emit()" data-test-id="cancel-statistik-fields-button">
<ods-button text="Abbrechen" variant="outline" (clickEmitter)="onCancel()" data-test-id="cancel-statistik-fields-button">
<ods-close-icon icon class="fill-primary" />
</ods-button>
</div>
......
import { existsAsHtmlElement, getElementComponentFromFixtureByCss, triggerEvent } from '@alfa-client/test-utils';
import { ROUTES } from '@admin-client/shared';
import { NavigationService } from '@alfa-client/navigation-shared';
import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock, triggerEvent } from '@alfa-client/test-utils';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FormBuilder } from '@angular/forms';
import { TextInputComponent } from '@ods/system';
import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test';
import { getDataTestIdOf } from '../../../../../tech-shared/test/data-test';
import { AdminStatistikFieldsFormComponent } from './admin-statistik-fields-form.component';
import { StatistikFieldsFormService } from './statistik-fields.formservice';
......@@ -18,9 +20,11 @@ describe('AdminStatistikFieldsFormComponent', () => {
const dataField1TestId: string = getDataTestIdOf('data-statistik-field-0');
let formService: StatistikFieldsFormService;
let navigationService: Mock<NavigationService>;
beforeEach(() => {
formService = new StatistikFieldsFormService(new FormBuilder());
navigationService = mock(NavigationService);
});
beforeEach(async () => {
......@@ -31,6 +35,10 @@ describe('AdminStatistikFieldsFormComponent', () => {
provide: StatistikFieldsFormService,
useValue: formService,
},
{
provide: NavigationService,
useValue: navigationService,
},
],
},
});
......@@ -65,6 +73,14 @@ describe('AdminStatistikFieldsFormComponent', () => {
expect(formService.addDataField).toHaveBeenCalled();
});
});
describe('onCancel', () => {
it('should call navigation service', () => {
component.onCancel();
expect(navigationService.navigate).toHaveBeenCalledWith(ROUTES.STATISTIK);
});
});
});
describe('template', () => {
......@@ -167,8 +183,8 @@ describe('AdminStatistikFieldsFormComponent', () => {
describe('output', () => {
describe('clickEmitter', () => {
it('should emit', () => {
component.cancel.emit = jest.fn();
it('should call handler', () => {
component.onCancel = jest.fn();
fixture.detectChanges();
triggerEvent({
......@@ -177,7 +193,7 @@ describe('AdminStatistikFieldsFormComponent', () => {
name: 'clickEmitter',
});
expect(component.cancel.emit).toHaveBeenCalled();
expect(component.onCancel).toHaveBeenCalled();
});
});
});
......
import { ROUTES } from '@admin-client/shared';
import { NavigationService } from '@alfa-client/navigation-shared';
import { CommonModule } from '@angular/common';
import { Component, EventEmitter, inject, Output } from '@angular/core';
import { Component, inject } from '@angular/core';
import { FormArray, FormControl, ReactiveFormsModule } from '@angular/forms';
import { ButtonComponent, CloseIconComponent, PlusIconComponent, TextInputComponent } from '@ods/system';
import { StatistikFieldsFormService } from './statistik-fields.formservice';
......@@ -12,9 +14,8 @@ import { StatistikFieldsFormService } from './statistik-fields.formservice';
templateUrl: './admin-statistik-fields-form.component.html',
})
export class AdminStatistikFieldsFormComponent {
@Output() public readonly cancel: EventEmitter<void> = new EventEmitter<void>();
private readonly formService = inject(StatistikFieldsFormService);
private readonly navigationService = inject(NavigationService);
public readonly formEngineFormControl: FormControl = this.formService.form.controls[
StatistikFieldsFormService.FIELD_FORM_ENGINE
......@@ -29,4 +30,8 @@ export class AdminStatistikFieldsFormComponent {
public addDataField(): void {
this.formService.addDataField();
}
public onCancel(): void {
this.navigationService.navigate(ROUTES.STATISTIK);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment