diff --git a/Jenkinsfile b/Jenkinsfile index 6305e9bab9dcbdf6a30e10c0511a262728f8e7b3..deb6ce4266ec36519843962e4f378ed44768e381 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -250,12 +250,17 @@ pipeline { stage ('Deploy SBOM to DependencyTrack') { steps { - configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { - withCredentials([string(credentialsId: 'dependency-track-api-key', variable: 'API_KEY')]) { + script { + IMAGE_TAG = generateImageTag() - dir('alfa-server') { - - sh 'mvn --no-transfer-progress -s $MAVEN_SETTINGS io.github.pmckeown:dependency-track-maven-plugin:upload-bom -Ddependency-track.apiKey=$API_KEY -Ddependency-track.projectVersion=' + generateImageTag() + ' -Ddependency-track.dependencyTrackBaseUrl=https://dependency-track.ozg-sh.de' + configFileProvider([configFile(fileId: 'maven-settings', variable: 'MAVEN_SETTINGS')]) { + withCredentials([string(credentialsId: 'dependency-track-api-key', variable: 'API_KEY')]) { + + dir('alfa-server') { + catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { + sh "mvn --no-transfer-progress -s $MAVEN_SETTINGS io.github.pmckeown:dependency-track-maven-plugin:upload-bom -Ddependency-track.apiKey=$API_KEY -Ddependency-track.projectVersion=${IMAGE_TAG} -Ddependency-track.dependencyTrackBaseUrl=https://dependency-track.ozg-sh.de" + } + } } } } diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts index 6bba58e7fc8b68c547729f19c4630e63a4b4b482..d5cdf3d7a38229b500188f238c7ed137ac9a475b 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.spec.ts @@ -103,7 +103,7 @@ describe('CollaborationService', () => { order: CommandOrder.CREATE_COLLABORATION_REQUEST, body: collaboration, }, - snackBarMessage: 'Die Zuarbeit wurde angefragt', + snackBarMessage: 'Die Zuarbeit wurde angefragt.', }); }); diff --git a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts index 736d0cb47f6cd6ed943688a389a6f8f5e9acb388..f210a1133df3293f5bfa9da2bdd97fe033af1f6c 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/collaboration.service.ts @@ -42,7 +42,7 @@ export class CollaborationService { order: CommandOrder.CREATE_COLLABORATION_REQUEST, body: collaborationRequest, }, - snackBarMessage: 'Die Zuarbeit wurde angefragt', + snackBarMessage: 'Die Zuarbeit wurde angefragt.', }); } } diff --git a/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.spec.ts b/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.spec.ts index 2099588d498d90965f498e9c9c8a1bce56d9bce5..f264006658fe044ac57ad9a2926427046ba6f029 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.spec.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.spec.ts @@ -99,4 +99,12 @@ describe('OrganisationsEinheitService', () => { expect(searchService.selectResult).toHaveBeenCalledWith(organisationsEinheitResource); }); }); + + describe('clear selected result', () => { + it('should call service', () => { + service.clearSelectedResult(); + + expect(searchService.clearSelectedResult).toHaveBeenCalled(); + }); + }); }); diff --git a/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.ts b/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.ts index f4fadaf317dfd2bc7bf9103e8bd4d953613c21aa..495c115446391b8d126feef91bc6b02ad9c24134 100644 --- a/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.ts +++ b/alfa-client/libs/collaboration-shared/src/lib/organisations-einheit.service.ts @@ -30,4 +30,8 @@ export class OrganisationsEinheitService { public selectSearchResult(organisationsEinheitResource: OrganisationsEinheitResource): void { this.searchService.selectResult(organisationsEinheitResource); } + + public clearSelectedResult(): void { + this.searchService.clearSelectedResult(); + } } diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts index 85649462f34ddd362382333feed07cf10693ed88..a5e6e9e22dc4c22f174f59115b1bb954d1addaf3 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.spec.ts @@ -155,4 +155,12 @@ describe('CollaborationInVorgangContainerComponent', () => { expect(service.hideRequestForm).toHaveBeenCalled(); }); }); + + describe('ngOnDestroy', () => { + it('should call service to clear selected result', () => { + component.ngOnDestroy(); + + expect(organisationsEinheitSearchService.clearSelectedResult).toHaveBeenCalled(); + }); + }); }); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts index 63127377e2c066b9a8eedaa7e2ca7b58c74ba8fa..50c5d04bcffdbd5cd7171a14c5f696839b7447ea 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang-container.component.ts @@ -1,6 +1,6 @@ import { OrganisationsEinheitResource } from '@alfa-client/collaboration-shared'; import { StateResource } from '@alfa-client/tech-shared'; -import { Component, OnInit } from '@angular/core'; +import { Component, OnDestroy, OnInit } from '@angular/core'; import { CollaborationListResource } from 'libs/collaboration-shared/src/lib/collaboration.model'; import { CollaborationService } from 'libs/collaboration-shared/src/lib/collaboration.service'; import { OrganisationsEinheitResourceSearchService } from 'libs/collaboration-shared/src/lib/organisations-einheit-resource-search.service'; @@ -10,7 +10,7 @@ import { Observable } from 'rxjs'; selector: 'alfa-collaboration-in-vorgang-container', templateUrl: './collaboration-in-vorgang-container.component.html', }) -export class CollaborationInVorgangContainerComponent implements OnInit { +export class CollaborationInVorgangContainerComponent implements OnInit, OnDestroy { public collaborationStateListResource$: Observable<StateResource<CollaborationListResource>>; public isRequestFormVisible$: Observable<boolean>; public selectedOrganisationsEinheit$: Observable<OrganisationsEinheitResource>; @@ -33,4 +33,8 @@ export class CollaborationInVorgangContainerComponent implements OnInit { public hideRequestForm(): void { this.service.hideRequestForm(); } + + ngOnDestroy(): void { + this.searchService.clearSelectedResult(); + } } diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.html index 298c59138de6107079d0e2c83e2991958d6912ef..733601490e198e7d93d37626f597974081b8367a 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.html +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.html @@ -26,6 +26,13 @@ </ng-container> <ng-container *ngIf="collaboration"> <div data-test-id="collaboration-request-result"> - Result: {{ collaboration | json }} OrganisationsEinheit: {{ organisationsEinheit | json }} + <div class="flex items-center gap-3"> + <ods-office-icon size="large" class="fill-text" /> + <alfa-organisations-einheit + [organisationsEinheitResource]="organisationsEinheit" + ></alfa-organisations-einheit> + </div> + <h4 class="my-6 text-xl font-medium">{{ collaboration.titel }}</h4> + <p class="text-base">{{ collaboration.anfrage }}</p> </div> </ng-container> diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.spec.ts b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.spec.ts index 71ed93f04ed34882a1a0b8bf62ea74fc11382b13..5b17cd273cc3b503a6accb79219bb149c351041a 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-in-vorgang/collaboration-in-vorgang.component.spec.ts @@ -13,7 +13,7 @@ import { triggerEvent, } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { ButtonComponent, CollaborationIconComponent } from '@ods/system'; +import { ButtonComponent, CollaborationIconComponent, OfficeIconComponent } from '@ods/system'; import { createCollaboration, createCollaborationListResource, @@ -21,6 +21,7 @@ import { import { getDataTestIdAttributeOf, getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { MockComponent } from 'ng-mocks'; import { CollaborationRequestFormComponent } from '../collaboration-request-form/collaboration-request-form.component'; +import { OrganisationsEinheitComponent } from '../collaboration-request-form/organisations-einheit-container/organisations-einheit/organisations-einheit.component'; import { CollaborationInVorgangComponent } from './collaboration-in-vorgang.component'; describe('CollaborationInVorgangComponent', () => { @@ -41,6 +42,8 @@ describe('CollaborationInVorgangComponent', () => { MockComponent(ButtonComponent), MockComponent(CollaborationRequestFormComponent), MockComponent(CollaborationIconComponent), + MockComponent(OfficeIconComponent), + MockComponent(OrganisationsEinheitComponent), ], }).compileComponents(); diff --git a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/organisations-einheit-container/organisations-einheit-container.component.html b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/organisations-einheit-container/organisations-einheit-container.component.html index 76fb67a05d142c765f76eaf2413abc1af5454901..26bf7894a39f4bc7fb5d5d1e07d51dc2cd2976cd 100644 --- a/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/organisations-einheit-container/organisations-einheit-container.component.html +++ b/alfa-client/libs/collaboration/src/lib/collaboration-in-vorgang-container/collaboration-request-form/organisations-einheit-container/organisations-einheit-container.component.html @@ -2,7 +2,7 @@ *ngIf="organisationsEinheitResource$ | async as organisationsEinheitResource; else searchButton" > <div class="flex items-center gap-3"> - <ods-office-icon size="large" class="flex-none" /> + <ods-office-icon size="large" class="fill-text" /> <alfa-organisations-einheit data-test-id="organisations-einheit-in-collaboration" [organisationsEinheitResource]="organisationsEinheitResource" diff --git a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.spec.ts b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.spec.ts index 2f94294e437896891c8c55521ca86c71a7b255d8..69c11f3b7ff394d26ec6472161c281fe59ff2cae 100644 --- a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.spec.ts @@ -87,6 +87,20 @@ describe('SearchOrganisationsEinheitContainerComponent', () => { }); }); + describe('onKeyDownHandler', () => { + it('should prevent default behavior for enter key', () => { + const keyboardEvent: KeyboardEvent = { + ...new KeyboardEvent('enter'), + key: 'Enter', + preventDefault: jest.fn(), + }; + + component.onKeyDownHandler(keyboardEvent); + + expect(keyboardEvent.preventDefault).toHaveBeenCalled(); + }); + }); + describe('search organisationsEinheit component', () => { beforeEach(() => { component.organisationsEinheitStateListResource$ = of(organisationsEinheitStateListResource); @@ -175,7 +189,7 @@ describe('SearchOrganisationsEinheitContainerComponent', () => { it('should close dialog', () => { component.selectSearchResult(organisationsEinheitResource); - expect(dialogRefMock.close).toHaveBeenCalledWith(); + expect(dialogRefMock.close).toHaveBeenCalled(); }); }); diff --git a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.ts b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.ts index 963ef863886ec30268528d90e3d9c5ea09d877d6..14a54da18681ed93697757c2cbcd13e81346414c 100644 --- a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.ts +++ b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-container.component.ts @@ -4,7 +4,7 @@ import { } from '@alfa-client/collaboration-shared'; import { StateResource } from '@alfa-client/tech-shared'; import { DialogRef } from '@angular/cdk/dialog'; -import { Component, OnInit } from '@angular/core'; +import { Component, HostListener, OnInit } from '@angular/core'; import { OrganisationsEinheitListResource, OrganisationsEinheitResource, @@ -31,6 +31,10 @@ export class SearchOrganisationsEinheitContainerComponent implements OnInit { this.organisationsEinheitStateListResource$ = this.service.getSearchResultList(); } + @HostListener('document:keydown', ['$event']) onKeyDownHandler(e: KeyboardEvent) { + if (e.key === 'Enter') e.preventDefault(); + } + public search(searchBy: string): void { this.service.search(searchBy); } diff --git a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.spec.ts b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.spec.ts index e93e7403bfa65080636bf44355f942ab224f063f..11fa9f5ebd5cfdcca46bf05fd71833602391e270 100644 --- a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.spec.ts +++ b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.spec.ts @@ -94,7 +94,7 @@ describe('SearchOrganisationsEinheitFormComponent', () => { const instantSearchResult: InstantSearchResult<OrganisationsEinheitResource> = component.mapToInstantantSearchResult(organisationsEinheitResource); - const expectedDescription: string = `${organisationsEinheitResource.anschrift.strasse} ${organisationsEinheitResource.anschrift.plz} ${organisationsEinheitResource.anschrift.ort}`; + const expectedDescription: string = `${organisationsEinheitResource.anschrift.strasse} ${organisationsEinheitResource.anschrift.hausnummer}, ${organisationsEinheitResource.anschrift.plz} ${organisationsEinheitResource.anschrift.ort}`; expect(instantSearchResult.description).toBe(expectedDescription); }); diff --git a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.ts b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.ts index 2e49ca660d004820de961dd252ef7ed156040a1a..e144eb1257283beea80b37d9b1d79b1a1fee50ab 100644 --- a/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.ts +++ b/alfa-client/libs/collaboration/src/lib/search-organisations-einheit-container/search-organisations-einheit-form/search-organisations-einheit-form.component.ts @@ -34,7 +34,7 @@ export class SearchOrganisationsEinheitFormComponent { ): InstantSearchResult<OrganisationsEinheitResource> { return <any>{ title: organisationsEinheit.name, - description: `${organisationsEinheit.anschrift.strasse} ${organisationsEinheit.anschrift.plz} ${organisationsEinheit.anschrift.ort}`, + description: `${organisationsEinheit.anschrift.strasse} ${organisationsEinheit.anschrift.hausnummer}, ${organisationsEinheit.anschrift.plz} ${organisationsEinheit.anschrift.ort}`, data: organisationsEinheit, }; } diff --git a/alfa-client/libs/command-shared/src/lib/+state/command.effects.spec.ts b/alfa-client/libs/command-shared/src/lib/+state/command.effects.spec.ts index c461fcffe58c1bff6b679c9175b70af066484b98..2ee1199a7ec572ca5c33e21ed788c098f2b95015 100644 --- a/alfa-client/libs/command-shared/src/lib/+state/command.effects.spec.ts +++ b/alfa-client/libs/command-shared/src/lib/+state/command.effects.spec.ts @@ -1,4 +1,3 @@ -import { TestBed } from '@angular/core/testing'; import { ApiError, ApiErrorAction, @@ -7,6 +6,7 @@ import { } from '@alfa-client/tech-shared'; import { Mock, mock } from '@alfa-client/test-utils'; import { SnackBarService } from '@alfa-client/ui'; +import { TestBed } from '@angular/core/testing'; import { provideMockActions } from '@ngrx/effects/testing'; import { Action, Store, createAction, props } from '@ngrx/store'; import { TypedAction } from '@ngrx/store/src/models'; @@ -26,7 +26,12 @@ import { CommandLinkRel } from '../command.linkrel'; import { CREATE_COMMAND_MESSAGE_BY_ORDER, CommandErrorMessage } from '../command.message'; import { CommandListResource, CommandResource, CreateCommandProps } from '../command.model'; import { CommandRepository } from '../command.repository'; -import { CommandProps, LoadCommandListSuccessProps, createCommandFailure } from './command.actions'; +import { + CommandProps, + LoadCommandListSuccessProps, + SnackBarProps, + createCommandFailure, +} from './command.actions'; import { CommandEffects } from './command.effects'; import * as CommandActions from './command.actions'; @@ -35,13 +40,17 @@ describe('CommandEffects', () => { let actions: Observable<Action>; let effects: CommandEffects; - const repository: Mock<CommandRepository> = mock(CommandRepository); - const snackBarService: Mock<SnackBarService> = mock(SnackBarService); - const store: Mock<SnackBarService> = mock(SnackBarService); + let repository: Mock<CommandRepository>; + let snackBarService: Mock<SnackBarService>; + let store: Mock<Store>; let testScheduler: TestScheduler; beforeEach(() => { + repository = mock(CommandRepository); + snackBarService = mock(SnackBarService); + store = mock(Store); + testScheduler = new TestScheduler((actual, expected) => expect(actual).toEqual(expected)); TestBed.configureTestingModule({ @@ -374,7 +383,8 @@ describe('CommandEffects', () => { const createCommandProps: CreateCommandProps = createCreateCommandProps(); const command: CommandResource = createCommandResource(); - it('should show snackBar on existing snackBarMessage', () => { + it('should call handle snackbar by command', () => { + effects.handleSnackbarByCommand = jest.fn(); const showSnackbarAction: TypedAction<string> = CommandActions.showSnackbar({ createCommandProps, command, @@ -383,6 +393,19 @@ describe('CommandEffects', () => { actions = of(showSnackbarAction); effects.showSnackbar$.subscribe(); + expect(effects.handleSnackbarByCommand).toHaveBeenCalled(); + }); + }); + + describe('handle snackbar by command', () => { + const createCommandProps: CreateCommandProps = createCreateCommandProps(); + const command: CommandResource = createCommandResource(); + + it('should show snackBar on existing snackBarMessage', () => { + const snackBarProps: SnackBarProps = { createCommandProps, command }; + + effects.handleSnackbarByCommand(snackBarProps); + expect(snackBarService.show).toHaveBeenCalledWith( command, createCommandProps.snackBarMessage, @@ -390,13 +413,12 @@ describe('CommandEffects', () => { }); it('should show snackBar on undefined snackBarMessage', () => { - const showSnackbarAction: TypedAction<string> = CommandActions.showSnackbar({ + const snackBarProps: SnackBarProps = { createCommandProps: { ...createCommandProps, snackBarMessage: undefined }, command, - }); + }; - actions = of(showSnackbarAction); - effects.showSnackbar$.subscribe(); + effects.handleSnackbarByCommand(snackBarProps); expect(snackBarService.show).toHaveBeenCalledWith( command, @@ -404,16 +426,24 @@ describe('CommandEffects', () => { ); }); - //Faellt um, wenn man ihn mit den anderen Tests zusammen laufen laesst - it.skip('FIXME should NOT show snackBar on empty snackBarMessage', () => { - const showSnackbarAction: TypedAction<string> = CommandActions.showSnackbar({ + it('should NOT show snackBar on empty snackBarMessage', () => { + const snackBarProps: SnackBarProps = { createCommandProps: { ...createCommandProps, snackBarMessage: EMPTY_STRING }, command, - }); - snackBarService.show.mockClear(); + }; - effects.showSnackbar$.subscribe(); - actions = of(showSnackbarAction); + effects.handleSnackbarByCommand(snackBarProps); + + expect(snackBarService.show).not.toHaveBeenCalled(); + }); + + it('should NOT show snackBar on existing error message', () => { + const snackBarProps: SnackBarProps = { + createCommandProps, + command: { ...command, errorMessage: 'dummyErrorMessage' }, + }; + + effects.handleSnackbarByCommand(snackBarProps); expect(snackBarService.show).not.toHaveBeenCalled(); }); diff --git a/alfa-client/libs/command-shared/src/lib/+state/command.effects.ts b/alfa-client/libs/command-shared/src/lib/+state/command.effects.ts index 3d7151381f57a1c9843bf17179f320bd3c28022c..76c42d3899bc776736f109e5af66d73cccd23aa1 100644 --- a/alfa-client/libs/command-shared/src/lib/+state/command.effects.ts +++ b/alfa-client/libs/command-shared/src/lib/+state/command.effects.ts @@ -1,14 +1,21 @@ -import { Injectable } from '@angular/core'; +import { EMPTY_STRING } from '@alfa-client/tech-shared'; import { SnackBarService } from '@alfa-client/ui'; +import { Injectable } from '@angular/core'; import { Actions, createEffect, ofType } from '@ngrx/effects'; import { Store } from '@ngrx/store'; import { TypedAction } from '@ngrx/store/src/models'; +import { isEmpty, isEqual, isUndefined } from 'lodash-es'; import { of } from 'rxjs'; import { catchError, delay, map, mergeMap, switchMap, tap } from 'rxjs/operators'; import { COMMAND_ERROR_MESSAGES, CREATE_COMMAND_MESSAGE_BY_ORDER } from '../command.message'; import { CommandListResource, CommandResource, CreateCommandProps } from '../command.model'; import { CommandRepository } from '../command.repository'; -import { hasCommandError, isConcurrentModification, isPending, isRevokeable } from '../command.util'; +import { + hasCommandError, + isConcurrentModification, + isPending, + isRevokeable, +} from '../command.util'; import { CommandProps, LoadCommandListProps, @@ -27,8 +34,6 @@ import { showRevokeSnackbar, showSnackbar, } from './command.actions'; -import { isEqual, isUndefined } from 'lodash-es'; -import { EMPTY_STRING } from '@alfa-client/tech-shared'; @Injectable() export class CommandEffects { @@ -99,6 +104,8 @@ export class CommandEffects { } if (hasCommandError(command) && isConcurrentModification(command.errorMessage)) { this.showError(command); + //FIXME Anstelle der createCommandSucess Action sollte eine createCommandFailure Action geworfen werden. + //Hierzu muss ein HttpErrorResponse für die errorMessage definieren werden return [createCommandSuccess({ command }), publishConcurrentModificationAction()]; } return [createCommandSuccess({ command }), showSnackbar({ createCommandProps, command })]; @@ -131,15 +138,20 @@ export class CommandEffects { () => this.actions$.pipe( ofType(showSnackbar), - tap((props: SnackBarProps) => { - if (!isEqual(props.createCommandProps.snackBarMessage, EMPTY_STRING)) { - this.snackbarService.show(props.command, this.getSnackBarMessage(props)); - } - }), + tap((props: SnackBarProps) => this.handleSnackbarByCommand(props)), ), { dispatch: false }, ); + handleSnackbarByCommand(props: SnackBarProps): void { + if ( + !isEqual(props.createCommandProps.snackBarMessage, EMPTY_STRING) && + isEmpty(props.command.errorMessage) + ) { + this.snackbarService.show(props.command, this.getSnackBarMessage(props)); + } + } + private getSnackBarMessage(props: SnackBarProps): string { return isUndefined(props.createCommandProps.snackBarMessage) ? CREATE_COMMAND_MESSAGE_BY_ORDER[props.command.order] diff --git a/alfa-client/libs/design-system/src/lib/instant-search/instant-search/instant-search.component.ts b/alfa-client/libs/design-system/src/lib/instant-search/instant-search/instant-search.component.ts index ab653fe9d22fae4f7f7faf447d5b7a5685e85342..80a889a7bfa1211c008d3891cfb80d98d811448e 100644 --- a/alfa-client/libs/design-system/src/lib/instant-search/instant-search/instant-search.component.ts +++ b/alfa-client/libs/design-system/src/lib/instant-search/instant-search/instant-search.component.ts @@ -47,7 +47,7 @@ import { InstantSearchQuery, InstantSearchResult } from './instant-search.model' <ods-aria-live-region [text]="ariaLiveText" /> <ods-search-result-layer *ngIf="results.length && areResultsVisible" - class="absolute z-50 mt-3 w-full" + containerClass="absolute z-50 mt-3 max-h-[calc(50vh)] w-full overflow-y-auto" id="results" > <ods-search-result-header diff --git a/alfa-client/libs/design-system/src/lib/instant-search/search-result-layer/search-result-layer.component.ts b/alfa-client/libs/design-system/src/lib/instant-search/search-result-layer/search-result-layer.component.ts index 971e06b585e2292b36be429b6972ba91090ccaa0..f06c873fc8e184fa6eb56a399e67a39633bf95da 100644 --- a/alfa-client/libs/design-system/src/lib/instant-search/search-result-layer/search-result-layer.component.ts +++ b/alfa-client/libs/design-system/src/lib/instant-search/search-result-layer/search-result-layer.component.ts @@ -1,15 +1,22 @@ import { CommonModule } from '@angular/common'; -import { Component } from '@angular/core'; +import { Component, Input } from '@angular/core'; @Component({ selector: 'ods-search-result-layer', standalone: true, imports: [CommonModule], - template: `<div class="rounded-lg border border-primary-600/50 bg-background-50 shadow-lg"> + template: `<div + [ngClass]="[ + 'rounded-lg border border-primary-600/50 bg-background-50 shadow-lg', + containerClass, + ]" + > <ng-content select="[header]" /> <ul role="list"> <ng-content /> </ul> </div>`, }) -export class SearchResultLayerComponent {} +export class SearchResultLayerComponent { + @Input() containerClass: string = ''; +} diff --git a/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.spec.ts b/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.spec.ts index a4873730938d80aa0efe333f7177aca4e2e4ff28..eef4a6cad0cd8c46e932d45a93b11eab29005b62 100644 --- a/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.spec.ts +++ b/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.spec.ts @@ -23,7 +23,7 @@ */ import { getEmbeddedResource } from '@ngxp/rest'; import { DummyListLinkRel } from 'libs/tech-shared/test/dummy'; -import { createDummyListResource } from 'libs/tech-shared/test/resource'; +import { createDummyListResource, toResource } from 'libs/tech-shared/test/resource'; import { ListResource } from '../resource/resource.util'; import { EMPTY_ARRAY } from '../tech.util'; import { ToEmbeddedResourcesPipe } from './to-embedded-resource.pipe'; @@ -55,5 +55,11 @@ describe('ToEmbeddedResourcesPipe', () => { expect(result).toBe(EMPTY_ARRAY); }); + + it('should return empty array non existing resources', () => { + const result: unknown[] = pipe.transform(toResource({}), DummyListLinkRel.LIST); + + expect(result).toBe(EMPTY_ARRAY); + }); }); }); diff --git a/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.ts b/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.ts index 77e51945183b3b392c2b3d49647af0bf4a0e02ea..f310e40a994c86031869c1137adf3a3387864b38 100644 --- a/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.ts +++ b/alfa-client/libs/tech-shared/src/lib/pipe/to-embedded-resource.pipe.ts @@ -23,7 +23,7 @@ */ import { Pipe, PipeTransform } from '@angular/core'; import { Resource, getEmbeddedResource } from '@ngxp/rest'; -import { isNil } from 'lodash-es'; +import { isNil, isNull } from 'lodash-es'; import { LinkRelationName } from '../resource/resource.model'; import { ListResource } from '../resource/resource.util'; import { EMPTY_ARRAY } from '../tech.util'; @@ -32,6 +32,7 @@ import { EMPTY_ARRAY } from '../tech.util'; export class ToEmbeddedResourcesPipe implements PipeTransform { transform(listResource: ListResource, linkRel: LinkRelationName): Resource[] { if (isNil(listResource) || isNil(linkRel)) return EMPTY_ARRAY; - return getEmbeddedResource(listResource, linkRel); + const embeddedReources: Resource[] = getEmbeddedResource(listResource, linkRel); + return isNull(embeddedReources) ? EMPTY_ARRAY : embeddedReources; } } diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.spec.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.spec.ts index acbd45df651fd4343be7601e8a9886850f133f0e..1c1d30cbcd83ef02da378247d4e2792ff750d3a0 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.spec.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.spec.ts @@ -191,4 +191,16 @@ describe('ResourceSearchService', () => { expect(service.selectedResource.value).toEqual(dummyResource); }); }); + + describe('clear select result', () => { + const dummyResource: Resource = createDummyResource(); + + it('should update selected resource to null', () => { + service.selectedResource.next(dummyResource); + + service.clearSelectedResult(); + + expect(service.selectedResource.value).toBeNull(); + }); + }); }); diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.ts index d23b4be986f9a8fb880e582c5925f525459bf3dc..f8e52663e186ba7c2ebe4b8d6bec0dd593163e3a 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource-search.service.ts @@ -98,4 +98,8 @@ export class ResourceSearchService< public selectResult(selected: I): void { this.selectedResource.next(selected); } + + public clearSelectedResult(): void { + this.selectedResource.next(null); + } } diff --git a/alfa-client/package-lock.json b/alfa-client/package-lock.json index 6f74aee054bb6dd8cf0188cb27a4e8c4ce1b78b5..b551b3e5a341ab04c060b67cf3b84a262f0e74d4 100644 --- a/alfa-client/package-lock.json +++ b/alfa-client/package-lock.json @@ -1,12 +1,12 @@ { "name": "alfa", - "version": "0.8.0-SNAPSHOT", + "version": "1.0.0-SNAPSHOT", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "alfa", - "version": "0.8.0-SNAPSHOT", + "version": "1.0.0-SNAPSHOT", "license": "MIT", "dependencies": { "@angular/animations": "17.3.10", diff --git a/alfa-client/package.json b/alfa-client/package.json index a02724a20ba7b3e3d31967f73f9e0ec13ad8fce5..e1523dd25e7b7786a77adf6d0fe52760d69516fe 100644 --- a/alfa-client/package.json +++ b/alfa-client/package.json @@ -1,6 +1,6 @@ { "name": "alfa", - "version": "0.8.0-SNAPSHOT", + "version": "1.0.0-SNAPSHOT", "license": "MIT", "scripts": { "start": "nx run alfa:serve --port 4300 --disable-host-check", @@ -162,4 +162,4 @@ "ts-node": "10.9.1", "typescript": "5.4.5" } -} +} \ No newline at end of file diff --git a/alfa-client/pom.xml b/alfa-client/pom.xml index b36055f368b4404644459bb3f3816469ba738293..576dd79ddd4c0ab6fb8adbf86fcb0e631b3aab55 100644 --- a/alfa-client/pom.xml +++ b/alfa-client/pom.xml @@ -29,7 +29,7 @@ <parent> <groupId>de.ozgcloud.alfa</groupId> <artifactId>alfa</artifactId> - <version>2.12.0-SNAPSHOT</version> + <version>2.13.0-SNAPSHOT</version> </parent> <modelVersion>4.0.0</modelVersion> diff --git a/alfa-server/pom.xml b/alfa-server/pom.xml index e157390eee8d5e6722072745abd75cb760f831ec..352336b4ac3074f81a411207f393d1b590933cbf 100644 --- a/alfa-server/pom.xml +++ b/alfa-server/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>de.ozgcloud.alfa</groupId> <artifactId>alfa</artifactId> - <version>2.12.0-SNAPSHOT</version> + <version>2.13.0-SNAPSHOT</version> </parent> <artifactId>alfa-server</artifactId> diff --git a/alfa-service/pom.xml b/alfa-service/pom.xml index 9f540119c2fdada17280122da064557d1fc1078a..24d69e9a5b0678baaea9c632062d636ba513d436 100644 --- a/alfa-service/pom.xml +++ b/alfa-service/pom.xml @@ -33,7 +33,7 @@ <parent> <groupId>de.ozgcloud.alfa</groupId> <artifactId>alfa</artifactId> - <version>2.12.0-SNAPSHOT</version> + <version>2.13.0-SNAPSHOT</version> </parent> <artifactId>alfa-service</artifactId> diff --git a/alfa-xdomea/pom.xml b/alfa-xdomea/pom.xml index c141f0be18aa411909614eadcb8a85bc679f4837..4bd9cb9cc3356d4ff4484bfd957150d964526142 100644 --- a/alfa-xdomea/pom.xml +++ b/alfa-xdomea/pom.xml @@ -31,7 +31,7 @@ <parent> <groupId>de.ozgcloud.alfa</groupId> <artifactId>alfa</artifactId> - <version>2.12.0-SNAPSHOT</version> + <version>2.13.0-SNAPSHOT</version> </parent> <artifactId>alfa-xdomea</artifactId> diff --git a/pom.xml b/pom.xml index bac9e0e473b07a7e6bbc10f857de168643db407e..1989d2bfc0f915073d913b26e94eadfed20299bc 100644 --- a/pom.xml +++ b/pom.xml @@ -32,12 +32,12 @@ <parent> <groupId>de.ozgcloud.common</groupId> <artifactId>ozgcloud-common-parent</artifactId> - <version>4.4.0-SNAPSHOT</version> + <version>4.3.2</version> </parent> <groupId>de.ozgcloud.alfa</groupId> <artifactId>alfa</artifactId> - <version>2.12.0-SNAPSHOT</version> + <version>2.13.0-SNAPSHOT</version> <name>Alfa Parent</name> <packaging>pom</packaging> @@ -56,7 +56,7 @@ <nachrichten-manager.version>2.7.0</nachrichten-manager.version> <ozgcloud-common-pdf.version>3.0.1</ozgcloud-common-pdf.version> <user-manager.version>2.2.0</user-manager.version> - <zufi-manager.version>1.2.0-SNAPSHOT</zufi-manager.version> + <zufi-manager.version>1.2.0</zufi-manager.version> <!-- TODO: die Version über ozgcloud-common ziehen --> <jjwt.version>0.11.5</jjwt.version>