Skip to content
Snippets Groups Projects
Commit 4947e9b2 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-6477 PR Anmerkungen

parent d67fbc5f
Branches
No related tags found
No related merge requests found
Showing
with 89 additions and 82 deletions
...@@ -5,7 +5,12 @@ export interface Collaboration { ...@@ -5,7 +5,12 @@ export interface Collaboration {
titel: string; titel: string;
beschreibung: string; beschreibung: string;
zustaendigeStelle: ResourceUri; zustaendigeStelle: ResourceUri;
collaborationLevel?: number; collaborationLevel?: typeof CollaborationLevels[keyof typeof CollaborationLevels];
}
export class CollaborationLevels {
public static readonly ORGANISATIONS_EINHEIT = "1";
public static readonly EXTERNE_FACHSTELLE = "4";
} }
export interface CollaborationResource extends Collaboration, Resource, ListItemResource {} export interface CollaborationResource extends Collaboration, Resource, ListItemResource {}
......
<ozgcloud-spinner [stateResource]="collaborationStateListResource"> <ozgcloud-spinner [stateResource]="collaborationStateListResource">
@for(collaboration of collaborations; track collaboration.zustaendigeStelle){ @for(collaboration of collaborations; track collaboration.zustaendigeStelle){
@if(isOrganisationsEinheit(collaboration)){ @if(collaboration.collaborationLevel === CollaborationLevels.ORGANISATIONS_EINHEIT){
<alfa-organisations-einheit-list-item-container <alfa-organisations-einheit-list-item-container
[organisationsEinheitResourceUri]="collaboration.zustaendigeStelle" [organisationsEinheitResourceUri]="collaboration.zustaendigeStelle"
data-test-id="organisations-einheit-list-item" data-test-id="organisations-einheit-list-item"
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<alfa-collaboration-request [collaboration]="collaboration"/> <alfa-collaboration-request [collaboration]="collaboration"/>
</alfa-organisations-einheit-list-item-container> </alfa-organisations-einheit-list-item-container>
} }
@if(isExterneFachstelle(collaboration)){ @if(collaboration.collaborationLevel === CollaborationLevels.EXTERNE_FACHSTELLE){
<alfa-externe-fachstelle-list-item-container <alfa-externe-fachstelle-list-item-container
[externeFachstelleResourceUri] = "collaboration.zustaendigeStelle" [externeFachstelleResourceUri] = "collaboration.zustaendigeStelle"
data-test-id="externe-fachstelle-list-item" data-test-id="externe-fachstelle-list-item"
......
import { CollaborationListLinkRel, CollaborationListResource, CollaborationResource } from '@alfa-client/collaboration-shared'; import {
CollaborationLevels,
CollaborationListLinkRel,
CollaborationListResource,
CollaborationResource,
} from '@alfa-client/collaboration-shared';
import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared';
import { SpinnerComponent } from '@alfa-client/ui'; import { SpinnerComponent } from '@alfa-client/ui';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { createCollaborationListResource } from 'libs/collaboration-shared/test/collaboration'; import { createCollaboration, createCollaborationListResource } from 'libs/collaboration-shared/test/collaboration';
import { ExterneFachstelleListItemContainerComponent } from 'libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component'; import {
import { OrganisationsEinheitListItemContainerComponent } from 'libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component'; ExterneFachstelleListItemContainerComponent,
} from 'libs/externe-fachstelle/src/lib/externe-fachstelle-list-item-container/externe-fachstelle-list-item-container.component';
import {
OrganisationsEinheitListItemContainerComponent,
} from 'libs/organisations-einheit/src/lib/organisations-einheit-list-item-container/organisations-einheit-list-item-container.component';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { CollaborationListContainerComponent } from './collaboration-list-container.component'; import { CollaborationListContainerComponent } from './collaboration-list-container.component';
import { toResource } from 'libs/tech-shared/test/resource';
import { getDataTestIdOf } from 'libs/tech-shared/test/data-test';
import { existsAsHtmlElement } from '@alfa-client/test-utils';
import { CollaborationRequestComponent } from './collaboration-request/collaboration-request.component';
describe('CollaborationListContainerComponent', () => { describe('CollaborationListContainerComponent', () => {
let component: CollaborationListContainerComponent; let component: CollaborationListContainerComponent;
let fixture: ComponentFixture<CollaborationListContainerComponent>; let fixture: ComponentFixture<CollaborationListContainerComponent>;
const organisationsEinheitListItem: string = getDataTestIdOf('organisations-einheit-list-item');
const externeFachstelleListItem: string = getDataTestIdOf('externe-fachstelle-list-item');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
imports: [ imports: [
CollaborationListContainerComponent, CollaborationListContainerComponent,
MockComponent(OrganisationsEinheitListItemContainerComponent), MockComponent(OrganisationsEinheitListItemContainerComponent),
MockComponent(ExterneFachstelleListItemContainerComponent), MockComponent(ExterneFachstelleListItemContainerComponent),
MockComponent(CollaborationRequestComponent),
MockComponent(SpinnerComponent), MockComponent(SpinnerComponent),
], ],
}).compileComponents(); }).compileComponents();
...@@ -31,6 +48,33 @@ describe('CollaborationListContainerComponent', () => { ...@@ -31,6 +48,33 @@ describe('CollaborationListContainerComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('template', () => {
const collaboration: CollaborationResource = toResource(createCollaboration());
beforeEach(() => {
component.collaborations = [collaboration];
})
describe('alfa-organisations-einheit-list-item-container', () => {
it('should be rendered if collaborationLevel is ORGANISATIONS_EINHEIT', () => {
collaboration.collaborationLevel = CollaborationLevels.ORGANISATIONS_EINHEIT;
fixture.detectChanges();
existsAsHtmlElement(fixture, organisationsEinheitListItem);
});
})
describe('alfa-externe-fachstelle-list-item-container', () => {
it('should be rendered if collaborationLevel is EXTERNE_FACHSTELLE', () => {
collaboration.collaborationLevel = CollaborationLevels.EXTERNE_FACHSTELLE;
fixture.detectChanges();
existsAsHtmlElement(fixture, externeFachstelleListItem);
});
})
})
describe('component', () => {
describe('getCollaborations', () => { describe('getCollaborations', () => {
it('should return empty array if state resource is null', () => { it('should return empty array if state resource is null', () => {
component.collaborationStateListResource = null; component.collaborationStateListResource = null;
...@@ -53,24 +97,5 @@ describe('CollaborationListContainerComponent', () => { ...@@ -53,24 +97,5 @@ describe('CollaborationListContainerComponent', () => {
); );
}); });
}); });
describe('isOrganisationsEinheit', () => {
it('should return true if collaborationLevel is 1', () => {
const collaboration = { collaborationLevel: 1 } as CollaborationResource;
const result = component.isOrganisationsEinheit(collaboration);
expect(result).toBe(true);
});
});
describe('isExterneFachstelle', () => {
it('should return true if collaborationLevel is 4', () => {
const collaboration = { collaborationLevel: 4 } as CollaborationResource;
const result = component.isExterneFachstelle(collaboration);
expect(result).toBe(true);
});
}); });
}); });
import { CollaborationListLinkRel, CollaborationListResource, CollaborationResource } from '@alfa-client/collaboration-shared'; import {
CollaborationLevels,
CollaborationListLinkRel,
CollaborationListResource,
CollaborationResource,
} from '@alfa-client/collaboration-shared';
import { getEmbeddedResources, StateResource } from '@alfa-client/tech-shared'; import { getEmbeddedResources, StateResource } from '@alfa-client/tech-shared';
import { Component, Input, OnChanges } from '@angular/core'; import { Component, Input, OnChanges } from '@angular/core';
@Component({ @Component({
selector: 'alfa-collaboration-list-container', selector: 'alfa-collaboration-list-container',
templateUrl: './collaboration-list-container.component.html', templateUrl: './collaboration-list-container.component.html',
styleUrl: './collaboration-list-container.component.scss',
}) })
export class CollaborationListContainerComponent implements OnChanges { export class CollaborationListContainerComponent implements OnChanges {
@Input() public collaborationStateListResource: StateResource<CollaborationListResource>; @Input() public collaborationStateListResource: StateResource<CollaborationListResource>;
...@@ -20,11 +24,5 @@ export class CollaborationListContainerComponent implements OnChanges { ...@@ -20,11 +24,5 @@ export class CollaborationListContainerComponent implements OnChanges {
return getEmbeddedResources(this.collaborationStateListResource, CollaborationListLinkRel.COLLABORATION_LIST); return getEmbeddedResources(this.collaborationStateListResource, CollaborationListLinkRel.COLLABORATION_LIST);
} }
public isOrganisationsEinheit(collaboration: CollaborationResource): boolean { protected readonly CollaborationLevels = CollaborationLevels;
return collaboration.collaborationLevel === 1;
}
public isExterneFachstelle(collaboration: CollaborationResource): boolean {
return collaboration.collaborationLevel === 4;
}
} }
...@@ -4,7 +4,6 @@ import { Component, Input } from '@angular/core'; ...@@ -4,7 +4,6 @@ import { Component, Input } from '@angular/core';
@Component({ @Component({
selector: 'alfa-collaboration-request', selector: 'alfa-collaboration-request',
templateUrl: './collaboration-request.component.html', templateUrl: './collaboration-request.component.html',
styleUrl: './collaboration-request.component.scss',
}) })
export class CollaborationRequestComponent { export class CollaborationRequestComponent {
@Input() public collaboration: CollaborationResource; @Input() public collaboration: CollaborationResource;
......
...@@ -39,6 +39,7 @@ describe('ExterneFachstelleListItemContainerComponent', () => { ...@@ -39,6 +39,7 @@ describe('ExterneFachstelleListItemContainerComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('component', () => {
describe('ngOnInit', () => { describe('ngOnInit', () => {
it('should call externeFachstelleResourceService getExterneFachstelle Resource', () => { it('should call externeFachstelleResourceService getExterneFachstelle Resource', () => {
component.ngOnInit(); component.ngOnInit();
...@@ -47,3 +48,4 @@ describe('ExterneFachstelleListItemContainerComponent', () => { ...@@ -47,3 +48,4 @@ describe('ExterneFachstelleListItemContainerComponent', () => {
}); });
}); });
}); });
});
...@@ -13,7 +13,6 @@ import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-it ...@@ -13,7 +13,6 @@ import { ExterneFachstelleListItemComponent } from './externe-fachstelle-list-it
imports: [CommonModule, ExterneFachstelleListItemComponent], imports: [CommonModule, ExterneFachstelleListItemComponent],
providers: [ExterneFachstelleResourceService], providers: [ExterneFachstelleResourceService],
templateUrl: './externe-fachstelle-list-item-container.component.html', templateUrl: './externe-fachstelle-list-item-container.component.html',
styleUrl: './externe-fachstelle-list-item-container.component.scss',
}) })
export class ExterneFachstelleListItemContainerComponent implements OnInit { export class ExterneFachstelleListItemContainerComponent implements OnInit {
private externeFachstelleResourceService: ExterneFachstelleResourceService = inject(ExterneFachstelleResourceService); private externeFachstelleResourceService: ExterneFachstelleResourceService = inject(ExterneFachstelleResourceService);
......
...@@ -9,7 +9,6 @@ import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@o ...@@ -9,7 +9,6 @@ import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@o
standalone: true, standalone: true,
imports: [PublicAdministrationIconComponent, ExternalUnitIconComponent, UiModule], imports: [PublicAdministrationIconComponent, ExternalUnitIconComponent, UiModule],
templateUrl: './externe-fachstelle-list-item.component.html', templateUrl: './externe-fachstelle-list-item.component.html',
styleUrl: './externe-fachstelle-list-item.component.scss',
}) })
export class ExterneFachstelleListItemComponent { export class ExterneFachstelleListItemComponent {
@Input() externeFachstelleStateResource: StateResource<ExterneFachstelleResource>; @Input() externeFachstelleStateResource: StateResource<ExterneFachstelleResource>;
......
...@@ -41,6 +41,7 @@ describe('OrganisationsEinheitListItemContainerComponent', () => { ...@@ -41,6 +41,7 @@ describe('OrganisationsEinheitListItemContainerComponent', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('component', () => {
describe('ngOnInit', () => { describe('ngOnInit', () => {
it('should call organisationsEinheitResourceService getOrganisationsEinheit Resource', () => { it('should call organisationsEinheitResourceService getOrganisationsEinheit Resource', () => {
component.ngOnInit(); component.ngOnInit();
...@@ -49,3 +50,4 @@ describe('OrganisationsEinheitListItemContainerComponent', () => { ...@@ -49,3 +50,4 @@ describe('OrganisationsEinheitListItemContainerComponent', () => {
}); });
}); });
}); });
});
...@@ -13,7 +13,6 @@ import { OrganisationsEinheitListItemComponent } from './organisations-einheit-l ...@@ -13,7 +13,6 @@ import { OrganisationsEinheitListItemComponent } from './organisations-einheit-l
imports: [CommonModule, OrganisationsEinheitListItemComponent], imports: [CommonModule, OrganisationsEinheitListItemComponent],
providers: [OrganisationsEinheitResourceService], providers: [OrganisationsEinheitResourceService],
templateUrl: './organisations-einheit-list-item-container.component.html', templateUrl: './organisations-einheit-list-item-container.component.html',
styleUrl: './organisations-einheit-list-item-container.component.scss',
}) })
export class OrganisationsEinheitListItemContainerComponent implements OnInit { export class OrganisationsEinheitListItemContainerComponent implements OnInit {
private organisationsEinheitResourceService: OrganisationsEinheitResourceService = inject(OrganisationsEinheitResourceService); private organisationsEinheitResourceService: OrganisationsEinheitResourceService = inject(OrganisationsEinheitResourceService);
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
</div> </div>
</div> </div>
<div class="flex-1"> <div class="flex-1">
<div class="block">{{ formatAnschrift(resource.anschrift) }}</div> <div class="block">
{{ resource.anschrift.strasse }} {{ resource.anschrift.hausnummer }}
, {{ resource.anschrift.plz }} {{ resource.anschrift.ort }}
</div>
</div> </div>
</div> </div>
<ng-content /> <ng-content />
......
...@@ -3,16 +3,13 @@ import { UiModule } from '@alfa-client/ui'; ...@@ -3,16 +3,13 @@ import { UiModule } from '@alfa-client/ui';
import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared'; import { OrganisationsEinheitResource } from '@alfa-client/zustaendige-stelle-shared';
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system'; import { ExternalUnitIconComponent, PublicAdministrationIconComponent } from '@ods/system';
import { formatAnschrift } from '../../organisations-einheit.util';
@Component({ @Component({
selector: 'alfa-organisations-einheit-list-item', selector: 'alfa-organisations-einheit-list-item',
standalone: true, standalone: true,
imports: [ExternalUnitIconComponent, PublicAdministrationIconComponent, UiModule], imports: [ExternalUnitIconComponent, PublicAdministrationIconComponent, UiModule],
templateUrl: './organisations-einheit-list-item.component.html', templateUrl: './organisations-einheit-list-item.component.html',
styleUrl: './organisations-einheit-list-item.component.scss',
}) })
export class OrganisationsEinheitListItemComponent { export class OrganisationsEinheitListItemComponent {
@Input() organisationsEinheitStateResource: StateResource<OrganisationsEinheitResource>; @Input() organisationsEinheitStateResource: StateResource<OrganisationsEinheitResource>;
protected readonly formatAnschrift = formatAnschrift;
} }
import { formatAnschrift } from './organisations-einheit.util';
describe('formatAnschrit', () => {
it('should format Anschrift correctly', () => {
const anschrift = {
strasse: 'Musterstraße',
hausnummer: '123',
plz: '12345',
ort: 'Musterort',
};
const formattedAnschrift: string = formatAnschrift(anschrift);
expect(formattedAnschrift).toEqual('Musterstraße 123, 12345 Musterort');
});
});
import { OrganisationsEinheit } from '@alfa-client/zustaendige-stelle-shared';
export function formatAnschrift(anschrift: OrganisationsEinheit['anschrift']): string {
return `${anschrift.strasse} ${anschrift.hausnummer}, ${anschrift.plz} ${anschrift.ort}`;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment