diff --git a/alfa-client/apps/alfa/src/app/app.module.ts b/alfa-client/apps/alfa/src/app/app.module.ts index 566ebc0b3fd03aa04506016be0d3c16aa1bf1fd9..d0b1eefacd958300514b409e1ae7a72b39a5a8a4 100644 --- a/alfa-client/apps/alfa/src/app/app.module.ts +++ b/alfa-client/apps/alfa/src/app/app.module.ts @@ -23,6 +23,7 @@ */ import { ApiRootModule } from '@alfa-client/api-root-shared'; import { AppSharedModule } from '@alfa-client/app-shared'; +import { BescheidSharedModule } from '@alfa-client/bescheid-shared'; import { BuildInfoComponent } from '@alfa-client/common'; import { EnvironmentModule } from '@alfa-client/environment-shared'; import { HintSharedModule } from '@alfa-client/hint-shared'; @@ -82,6 +83,8 @@ const routes: Routes = [ @NgModule({ declarations: [AppComponent], imports: [ + // todo: warum wird der BescheidResourceService sonst nicht gefunden? + BescheidSharedModule, MatIconModule, BrowserModule, BrowserAnimationsModule, diff --git a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.ts b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.ts index ff80f84dc3220803d3b811a72cc8f1e306e0d067..e5d31671fbb6b1ed316c249493928b2ade00fac2 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/+state/bescheid.reducer.ts @@ -21,12 +21,7 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { - CommandProps, - CommandResource, - CreateCommandFailureProps, - CreateCommandProps, -} from '@alfa-client/command-shared'; +import { CommandProps, CommandResource, CreateCommandFailureProps, CreateCommandProps } from '@alfa-client/command-shared'; import { ApiError, SingleResourceReducer, @@ -47,6 +42,7 @@ export const BESCHEID_FEATURE_KEY = 'BescheidState'; export const BESCHEID_PATH = 'bescheid'; export const BESCHEID_DRAFT_PATH = 'bescheidDraft'; +export const BESCHEID_LIST_PATH = 'bescheidList'; export interface BescheidParentState { bescheid: BescheidState; @@ -86,10 +82,7 @@ export const bescheidReducer: ActionReducerMap<BescheidParentState> = { [BESCHEID_DRAFT_PATH]: bescheidDraftResourceReducer, }; -function bescheidDraftResourceReducer( - state: SingleResourceState, - action: Action, -): SingleResourceState { +function bescheidDraftResourceReducer(state: SingleResourceState, action: Action): SingleResourceState { const resourceReducer: SingleResourceReducer = new SingleResourceReducer( createSingleResourceActions({ name: BESCHEID_FEATURE_KEY, path: BESCHEID_DRAFT_PATH }), ); diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid-list-resource-service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid-list-resource-service.ts index 43b427dd4e8975e8ac0d3d6211a2957c14b99671..9363ebe28969108d22ae82d779247d657c05ee22 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid-list-resource-service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid-list-resource-service.ts @@ -1,25 +1,31 @@ -import { ListResourceServiceConfig, ResourceListService, ResourceRepository } from '@alfa-client/tech-shared'; +import { CommandListResourceService, CommandListResourceServiceConfig, CommandService } from '@alfa-client/command-shared'; +import { ResourceListService, ResourceRepository } from '@alfa-client/tech-shared'; import { VorgangService, VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { BESCHEID_FEATURE_KEY, BESCHEID_LIST_PATH } from './+state/bescheid.reducer'; import { BescheidListLinkRel } from './bescheid.linkrel'; import { BescheidListResource, BescheidResource } from './bescheid.model'; -export class BescheidListResourceService extends ResourceListService< +export class BescheidListResourceService extends CommandListResourceService< VorgangWithEingangResource, BescheidListResource, BescheidResource > {} export function createBescheidListResourceService( - repository: ResourceRepository<BescheidResource>, vorgangService: VorgangService, + repository: ResourceRepository<BescheidResource>, + commandService: CommandService, ): ResourceListService<VorgangWithEingangResource, BescheidListResource, BescheidResource> { - return new BescheidListResourceService(buildBescheidListServiceConfig(vorgangService), repository); + return new BescheidListResourceService(buildBescheidListServiceConfig(vorgangService), repository, commandService); } -function buildBescheidListServiceConfig(vorgangService: VorgangService): ListResourceServiceConfig<VorgangWithEingangResource> { +function buildBescheidListServiceConfig( + vorgangService: VorgangService, +): CommandListResourceServiceConfig<VorgangWithEingangResource> { return { + stateInfo: { name: BESCHEID_FEATURE_KEY, path: BESCHEID_LIST_PATH }, baseResource: vorgangService.getVorgangWithEingang(), - listLinkRel: VorgangWithEingangLinkRel.BESCHEIDE, + getLinkRel: VorgangWithEingangLinkRel.BESCHEIDE, listResourceListLinkRel: BescheidListLinkRel.BESCHEID_LIST, }; } diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid-resource-service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid-resource-service.ts index b256816a9f4e91b99b09deb9ff0995683eb14c69..f75d57d6c31c43d6a8d74a882c63c3a3088445e3 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid-resource-service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid-resource-service.ts @@ -1,6 +1,7 @@ import { CommandOrder, CommandResourceService, CommandService } from '@alfa-client/command-shared'; import { ResourceServiceConfig, StateService } from '@alfa-client/tech-shared'; import { VorgangService, VorgangWithEingangLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { BESCHEID_DRAFT_PATH, BESCHEID_FEATURE_KEY } from './+state/bescheid.reducer'; import { BescheidLinkRel } from './bescheid.linkrel'; import { BescheidResource } from './bescheid.model'; @@ -17,6 +18,7 @@ export function createBescheidResourceService( function buildConfig(vorgangService: VorgangService): ResourceServiceConfig<VorgangWithEingangResource> { return { + stateInfo: { name: BESCHEID_FEATURE_KEY, path: BESCHEID_DRAFT_PATH }, baseResource: vorgangService.getVorgangWithEingang(), getLinkRel: VorgangWithEingangLinkRel.BESCHEID_DRAFT, delete: { linkRel: BescheidLinkRel.DELETE, order: CommandOrder.DELETE_BESCHEID }, diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid-shared.module.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid-shared.module.ts index b920c4c0d44132ca4c7e67a7d3991beaf266c50f..0fbda49ab01f9805955cf5e575199cb88447e2b7 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid-shared.module.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid-shared.module.ts @@ -21,12 +21,31 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { CommandService } from '@alfa-client/command-shared'; +import { ResourceRepository, StateService } from '@alfa-client/tech-shared'; +import { VorgangService, VorgangSharedModule } from '@alfa-client/vorgang-shared'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; import { StoreModule } from '@ngrx/store'; import { BESCHEID_FEATURE_KEY, bescheidReducer } from './+state/bescheid.reducer'; +import { BescheidListResourceService, createBescheidListResourceService } from './bescheid-list-resource-service'; +import { BescheidResourceService, createBescheidResourceService } from './bescheid-resource-service'; +import { BescheidService } from './bescheid.service'; @NgModule({ - imports: [CommonModule, StoreModule.forFeature(BESCHEID_FEATURE_KEY, bescheidReducer)], + imports: [CommonModule, VorgangSharedModule, StoreModule.forFeature(BESCHEID_FEATURE_KEY, bescheidReducer)], + providers: [ + { + provide: BescheidListResourceService, + useFactory: createBescheidListResourceService, + deps: [VorgangService, ResourceRepository, CommandService], + }, + { + provide: BescheidResourceService, + useFactory: createBescheidResourceService, + deps: [StateService, CommandService, VorgangService], + }, + BescheidService, + ], }) export class BescheidSharedModule {} diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts index ae974499af8180747f7915423b75c4e91a4a48a5..dfb4a3faec0806dafc81a3feaf6a70b60ec80f97 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.spec.ts @@ -28,6 +28,7 @@ import { BinaryFileService, } from '@alfa-client/binary-file-shared'; import { + CommandListResourceService, CommandOrder, CommandResource, CommandResourceService, @@ -42,9 +43,9 @@ import { createStateResource, EMPTY_STRING, getEmbeddedResources, - ResourceListService, ResourceRepository, StateResource, + StateService, } from '@alfa-client/tech-shared'; import { Mock, mock } from '@alfa-client/test-utils'; import { VorgangCommandService, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; @@ -121,6 +122,7 @@ describe('BescheidService', () => { let postfachService: Mock<PostfachService>; let bescheidResourceService: Mock<BescheidResourceService>; let bescheidListResourceService: Mock<BescheidListResourceService>; + let stateService: Mock<StateService>; const vorgangWithEingangResource: VorgangWithEingangResource = createVorgangWithEingangResource(); const vorgangWithEingangStateResource: StateResource<VorgangWithEingangResource> = @@ -138,7 +140,8 @@ describe('BescheidService', () => { binaryFileService = mock(BinaryFileService); postfachService = mock(PostfachService); bescheidResourceService = mock(CommandResourceService); - bescheidListResourceService = mock(ResourceListService); + bescheidListResourceService = mock(CommandListResourceService); + stateService = mock(StateService); (createBescheidResourceService as jest.Mock).mockReturnValue(bescheidResourceService); (createBescheidListResourceService as jest.Mock).mockReturnValue(bescheidListResourceService); @@ -148,6 +151,7 @@ describe('BescheidService', () => { { provide: VorgangService, useValue: vorgangService }, { provide: ResourceRepository, useValue: resourceRepository }, { provide: CommandService, useValue: commandService }, + { provide: StateService, useValue: stateService }, { provide: VorgangCommandService, useValue: vorgangCommandService }, { provide: BinaryFileService, useValue: binaryFileService }, { diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts index 22107e92d9b6ff28981edc35f13ab3da9b8880b8..7b88406c2f5b2784db25068eec6333ecccf09a23 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -27,7 +27,9 @@ import { BescheidDocument, BescheidLinkRel, BescheidListResource, + BescheidListResourceService, BescheidResource, + BescheidResourceService, BescheidSendBy, BescheidStatus, BescheidWizardStep, @@ -36,8 +38,6 @@ import { buildCreateBescheidDocumentFromFileProps, buildSendBescheidCommandProps, buildUpdateBescheidCommandProps, - createBescheidListResourceService, - createBescheidResourceService, createEmptyBescheidDocument, createEmptyUploadInProgress, createInitialWizard, @@ -72,7 +72,7 @@ import { sortByGermanDateStr, StateResource, } from '@alfa-client/tech-shared'; -import { VorgangCommandService, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { VorgangCommandService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { inject, Injectable } from '@angular/core'; import { getUrl, hasLink, LinkRel, Resource, ResourceUri } from '@ngxp/rest'; import { isNil } from 'lodash-es'; @@ -88,16 +88,9 @@ export class BescheidService { private readonly binaryFileService = inject(BinaryFileService); private readonly resourceRepository = inject(ResourceRepository); private readonly postfachService = inject(PostfachService); - private readonly vorgangService = inject(VorgangService); - // The injection of this services is problematic. - // It must be analysed how to inject BescheidService via providers in BescheidSharedModule. - private readonly bescheidResourceService = createBescheidResourceService( - this.resourceRepository, - this.commandService, - this.vorgangService, - ); - private readonly bescheidListResourceService = createBescheidListResourceService(this.resourceRepository, this.vorgangService); - // + private readonly bescheidResourceService = inject(BescheidResourceService); + private readonly bescheidListResourceService = inject(BescheidListResourceService); + readonly _bescheidDocument$: BehaviorSubject<BescheidDocument> = new BehaviorSubject(createEmptyBescheidDocument()); readonly _wizard$: BehaviorSubject<Wizard> = new BehaviorSubject(createInitialWizard()); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard-container.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard-container.component.ts index 75bf0b0c07f51e508304f2b353af195b6bc97254..480cef0b7e5aaccbc1fdb4a0ad334bb733433084 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard-container.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard-container.component.ts @@ -31,7 +31,11 @@ import { DIALOG_DATA, DialogRef } from '@angular/cdk/dialog'; import { Component, inject, OnDestroy, OnInit, ViewContainerRef } from '@angular/core'; import { hasLink } from '@ngxp/rest'; import { filter, first, Observable, of, Subscription, switchMap } from 'rxjs'; -import { BescheidWizardCancelDialogContainerComponent, CancelWizardDialogData, CancelWizardDialogResult, } from './bescheid-wizard/cancel-dialog-container/bescheid-wizard-cancel-dialog-container.component'; +import { + BescheidWizardCancelDialogContainerComponent, + CancelWizardDialogData, + CancelWizardDialogResult, +} from './bescheid-wizard/cancel-dialog-container/bescheid-wizard-cancel-dialog-container.component'; import { BescheidFormService } from './bescheid.formservice'; export interface BescheidWizardDialogData { @@ -68,6 +72,7 @@ export class BescheidWizardContainerComponent implements OnInit, OnDestroy { this.bescheidService.setNachrichtEmpfaenger(getEmpfaenger(this.vorgangWithEingangResource)); this.formService.setVorgangWithEingangResource(this.vorgangWithEingangResource); this.activeStep$ = this.bescheidService.getActiveStep(); + this.bescheidDraftStateResource$.subscribe((x) => console.log(x)); this.subscribeToBescheidResourceIfExists(); this.handleEscapeKey(); } diff --git a/alfa-client/libs/command-shared/src/lib/command-resource.service.ts b/alfa-client/libs/command-shared/src/lib/command-resource.service.ts index bd056eb22d1a668a63330b7387c7689f00b1d86d..8c8f356131fe2c22a1baf832d67d020360daa026 100644 --- a/alfa-client/libs/command-shared/src/lib/command-resource.service.ts +++ b/alfa-client/libs/command-shared/src/lib/command-resource.service.ts @@ -31,22 +31,13 @@ import { StateService, } from '@alfa-client/tech-shared'; import { Resource } from '@ngxp/rest'; -import { BehaviorSubject, filter, first, Observable, startWith, switchMap } from 'rxjs'; -import { - CommandResource, - CreateCommandProps, - DeleteCommandProps, - SaveCommandProps, -} from './command.model'; +import { filter, first, Observable, startWith, switchMap } from 'rxjs'; +import { CommandResource, CreateCommandProps, DeleteCommandProps, SaveCommandProps } from './command.model'; import { tapOnCommandSuccessfullyDone } from './command.rxjs.operator'; import { CommandService } from './command.service'; import { getEffectedResourceUrl } from './command.util'; export class CommandResourceService<B extends Resource, T extends Resource> extends ResourceService<B, T> { - deleteStateCommandResource: BehaviorSubject<StateResource<CommandResource>> = new BehaviorSubject< - StateResource<CommandResource> - >(createEmptyStateResource()); - constructor( protected config: ResourceServiceConfig<B>, protected stateService: StateService, @@ -61,9 +52,7 @@ export class CommandResourceService<B extends Resource, T extends Resource> exte ): Observable<StateResource<CommandResource>> { return this.selectResource().pipe( first(), - switchMap((stateResource: StateResource<T>) => - this.doSave(stateResource.resource, toSave, saveCommandProps), - ), + switchMap((stateResource: StateResource<T>) => this.doSave(stateResource.resource, toSave, saveCommandProps)), tapOnCommandSuccessfullyDone((commandStateResource: StateResource<CommandResource>) => this.loadByResourceUri(getEffectedResourceUrl(commandStateResource.resource)), ), @@ -72,14 +61,8 @@ export class CommandResourceService<B extends Resource, T extends Resource> exte ); } - doSave( - resource: T, - toSave: unknown, - saveCommandProps: SaveCommandProps, - ): Observable<StateResource<CommandResource>> { - return this.commandService.createCommandByProps( - this.buildSaveCommandProps<T>(resource, toSave, saveCommandProps), - ); + doSave(resource: T, toSave: unknown, saveCommandProps: SaveCommandProps): Observable<StateResource<CommandResource>> { + return this.commandService.createCommandByProps(this.buildSaveCommandProps<T>(resource, toSave, saveCommandProps)); } buildSaveCommandProps<T extends Resource>( @@ -106,28 +89,18 @@ export class CommandResourceService<B extends Resource, T extends Resource> exte deleteCommandProps: DeleteCommandProps = { snackBarMessage: EMPTY_STRING }, ): Observable<StateResource<CommandResource>> { return this.selectResource().pipe( - switchMap((stateResource: StateResource<T>) => - this.doDelete(stateResource.resource, deleteCommandProps), - ), + switchMap((stateResource: StateResource<T>) => this.doDelete(stateResource.resource, deleteCommandProps)), tapOnCommandSuccessfullyDone(() => this.clearResource()), filter(isStateResoureStable), startWith(createEmptyStateResource<CommandResource>(true)), ); } - doDelete( - resource: T, - deleteCommandProps: DeleteCommandProps, - ): Observable<StateResource<CommandResource>> { - return this.commandService.createCommandByProps( - this.buildDeleteCommandProps(resource, deleteCommandProps), - ); + doDelete(resource: T, deleteCommandProps: DeleteCommandProps): Observable<StateResource<CommandResource>> { + return this.commandService.createCommandByProps(this.buildDeleteCommandProps(resource, deleteCommandProps)); } - buildDeleteCommandProps<T extends Resource>( - resource: T, - deleteCommandProps: DeleteCommandProps, - ): CreateCommandProps { + buildDeleteCommandProps<T extends Resource>(resource: T, deleteCommandProps: DeleteCommandProps): CreateCommandProps { return { resource, linkRel: this.config.delete.linkRel, diff --git a/alfa-client/libs/kommentar-shared/src/lib/kommentar-list-resource.service.ts b/alfa-client/libs/kommentar-shared/src/lib/kommentar-list-resource.service.ts index 798b4879f7d528ff095841429853664669e027b5..43dc97366e7be50614a9575da238903645c0d34c 100644 --- a/alfa-client/libs/kommentar-shared/src/lib/kommentar-list-resource.service.ts +++ b/alfa-client/libs/kommentar-shared/src/lib/kommentar-list-resource.service.ts @@ -6,13 +6,12 @@ import { } from '@alfa-client/command-shared'; import { ResourceRepository } from '@alfa-client/tech-shared'; import { VorgangHeaderLinkRel, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; -import { Resource } from '@ngxp/rest'; import { KommentarListLinkRel } from './kommentar.linkrel'; import { KommentarListResource, KommentarResource } from './kommentar.model'; import { KOMMENTAR_FEATURE_KEY, KOMMENTAR_LIST_PATH } from './kommentar.state'; export class KommentarListResourceService extends CommandListResourceService< - Resource, + VorgangWithEingangResource, KommentarListResource, KommentarResource > {} @@ -21,7 +20,7 @@ export function createKommentarListResourceService( vorgangService: VorgangService, repository: ResourceRepository<KommentarResource>, commandService: CommandService, -) { +): KommentarListResourceService { return new KommentarListResourceService(buildConfig(vorgangService), repository, commandService); } diff --git a/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.spec.ts b/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.spec.ts index b72785f5932f04d9f714805fc0cd3a706667acf8..9469457ddc18bc645f784f73c8de8776796679bd 100644 --- a/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.spec.ts +++ b/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.spec.ts @@ -146,13 +146,13 @@ describe('KommentarService', () => { it('should be loaded if link avaible', () => { const kommentarResource: KommentarResource = createKommentarResource([KommentarLinkRel.ATTACHMENTS]); - service.getAttachments(kommentarResource); + service._getAttachments(kommentarResource); expect(binaryFileService.getFiles).toHaveBeenCalledWith(kommentarResource, KommentarLinkRel.ATTACHMENTS); }); it('should not be loaded if no link available', () => { - service.getAttachments(kommentarResource); + service._getAttachments(kommentarResource); expect(binaryFileService.getFiles).not.toHaveBeenCalled(); }); diff --git a/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.ts b/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.ts index e791715114f5878ddd0b44f26a5f8457675035a7..28a9a6cc7a0bb08dc5a8ceb3d823ac260dc1b816 100644 --- a/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.ts +++ b/alfa-client/libs/kommentar-shared/src/lib/kommentar.service.ts @@ -22,19 +22,8 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { BinaryFileListResource, BinaryFileService } from '@alfa-client/binary-file-shared'; -import { CommandOrder, tapOnCommandSuccessfullyDone, CommandResource, CommandService, CreateCommand, isDone } from '@alfa-client/command-shared'; -import { NavigationService } from '@alfa-client/navigation-shared'; -import { - createEmptyStateResource, - createStateResource, - doIfLoadingRequired, - EMPTY_STRING, - isLoaded, - isNotEmpty, - isNotNull, - StateResource, -} from '@alfa-client/tech-shared'; -import { VorgangResource, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { CommandResource, tapOnCommandSuccessfullyDone } from '@alfa-client/command-shared'; +import { createEmptyStateResource, EMPTY_STRING, isNotEmpty, StateResource } from '@alfa-client/tech-shared'; import { Injectable } from '@angular/core'; import { getUrl, hasLink, ResourceUri } from '@ngxp/rest'; import { BehaviorSubject, combineLatest, map, Observable, of } from 'rxjs'; @@ -45,15 +34,9 @@ import { Kommentar, KOMMENTAR_UPLOADED_ATTACHMENTS, KommentarListResource, Komme @Injectable() export class KommentarService { - readonly kommentarList$: BehaviorSubject<StateResource<KommentarListResource>> = new BehaviorSubject( - createEmptyStateResource<KommentarListResource>(), - ); readonly formularVisibility$: BehaviorSubject<boolean> = new BehaviorSubject(false); readonly _currentlyEdited$: BehaviorSubject<ResourceUri> = new BehaviorSubject(EMPTY_STRING); - - shouldReload: boolean = false; - constructor( private binaryFileService: BinaryFileService, private kommentarResourceService: KommentarResourceService, @@ -82,16 +65,16 @@ export class KommentarService { public createKommentar(toCreateKommentar: Kommentar): Observable<StateResource<CommandResource>> { return this.kommentarListResourceService .createListItem(toCreateKommentar) - .pipe(tapOnCommandSuccessfullyDone(() => this.afterCreateOrEditKommentarDone())); + .pipe(tapOnCommandSuccessfullyDone(() => this._afterCreateOrEditKommentarDone())); } public editKommentar(toEditKommentar: Kommentar): Observable<StateResource<CommandResource>> { return this.kommentarResourceService .save(toEditKommentar, { snackBarMessage: EMPTY_STRING }) - .pipe(tapOnCommandSuccessfullyDone(() => this.afterCreateOrEditKommentarDone())); + .pipe(tapOnCommandSuccessfullyDone(() => this._afterCreateOrEditKommentarDone())); } - afterCreateOrEditKommentarDone(): void { + _afterCreateOrEditKommentarDone(): void { this.hideNewKommentarFormular(); this.kommentarListResourceService.refresh(); } diff --git a/alfa-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-list-in-vorgang/kommentar-list-item-in-vorgang/kommentar-list-item-in-vorgang.component.ts b/alfa-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-list-in-vorgang/kommentar-list-item-in-vorgang/kommentar-list-item-in-vorgang.component.ts index c58a89660f33c75c1c4313fa6df17a7cb0452770..d78a19521ec5422a4315b332da5b51f8fa030564 100644 --- a/alfa-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-list-in-vorgang/kommentar-list-item-in-vorgang/kommentar-list-item-in-vorgang.component.ts +++ b/alfa-client/libs/kommentar/src/lib/kommentar-list-in-vorgang-container/kommentar-list-in-vorgang/kommentar-list-item-in-vorgang/kommentar-list-item-in-vorgang.component.ts @@ -50,7 +50,7 @@ export class KommentarListItemInVorgangComponent implements OnInit { public readonly KommentarLinkRel = KommentarLinkRel; ngOnInit(): void { - this.attachments$ = this.kommentarService.getAttachments(this.kommentar); + this.attachments$ = this.kommentarService._getAttachments(this.kommentar); } edit(): void { diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource.loader.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource.loader.ts index 5c38968831a043ebffeab3de3bc78f1136757321..d93c635a6a0c4f68b0b9d7b5f9a19ca2b88e9c3c 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource.loader.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource.loader.ts @@ -22,17 +22,9 @@ export class ResourceLoader<B extends Resource, T extends Resource> { ) {} public get(): Observable<StateResource<T>> { - return combineLatest([ - this.resourceStateService.selectResource(), - this.getConfigResource(), - ]).pipe( - tap(([stateResource, configResource]) => - this.handleResourceChanges(stateResource, configResource), - ), - filter( - ([stateResource, configResource]) => - !isInvalidResourceCombination(stateResource, configResource), - ), + return combineLatest([this.resourceStateService.selectResource(), this.getConfigResource()]).pipe( + tap(([stateResource, configResource]) => this.handleResourceChanges(stateResource, configResource)), + filter(([stateResource, configResource]) => !isInvalidResourceCombination(stateResource, configResource)), mapToFirst<T, B>(), startWith(createEmptyStateResource<T>(true)), ); @@ -43,6 +35,7 @@ export class ResourceLoader<B extends Resource, T extends Resource> { } handleResourceChanges(stateResource: StateResource<T>, configResource: B): void { + console.log(this.config); if (!isEqual(this.configResource, configResource)) { this.handleConfigResourceChanges(stateResource, configResource); } else if (this.shouldLoadResource(stateResource, configResource)) { @@ -66,10 +59,7 @@ export class ResourceLoader<B extends Resource, T extends Resource> { } shouldClearStateResource(stateResource: StateResource<T>, configResource: B): boolean { - return ( - (isNull(configResource) || this.hasNotGetLink(configResource)) && - !this.isStateResourceEmpty(stateResource) - ); + return (isNull(configResource) || this.hasNotGetLink(configResource)) && !this.isStateResourceEmpty(stateResource); } private hasNotGetLink(configResource: B) { @@ -85,11 +75,7 @@ export class ResourceLoader<B extends Resource, T extends Resource> { } shouldLoadResource(stateResource: StateResource<T>, configResource: B): boolean { - return ( - isNotNull(configResource) && - hasLink(configResource, this.config.getLinkRel) && - isLoadingRequired(stateResource) - ); + return isNotNull(configResource) && hasLink(configResource, this.config.getLinkRel) && isLoadingRequired(stateResource); } loadResource(configResource: B): void {