diff --git a/alfa-client/libs/admin-settings/src/lib/admin-settings-resource.service.ts b/alfa-client/libs/admin-settings/src/lib/admin-settings-resource.service.ts index 16d26ceec252126720a29c4ff57821faac79d6d5..96cf4048294a52d88c8d3371c5a89f0fe0656991 100644 --- a/alfa-client/libs/admin-settings/src/lib/admin-settings-resource.service.ts +++ b/alfa-client/libs/admin-settings/src/lib/admin-settings-resource.service.ts @@ -6,6 +6,7 @@ import { import { Resource } from '@ngxp/rest'; import { SettingListLinkRel } from './admin-settings.linkrel'; import { SettingItemResource, SettingListResource } from './admin-settings.model'; +import { SETTING_FEATURE_KEY, SETTING_LIST_PATH } from './admin-settings.state'; import { ConfigurationLinkRel } from './configuration/configuration.linkrel'; import { ConfigurationResource } from './configuration/configuration.model'; import { ConfigurationService } from './configuration/configuration.service'; @@ -26,7 +27,7 @@ function buildConfig( configurationService: ConfigurationService, ): ListResourceServiceConfig<ConfigurationResource> { return { - stateInfo: { name: 'SettingState', featureName: 'settingList' }, + stateInfo: { name: SETTING_FEATURE_KEY, path: SETTING_LIST_PATH }, baseResource: configurationService.get(), createLinkRel: SettingListLinkRel.CREATE, getLinkRel: ConfigurationLinkRel.SETTING, diff --git a/alfa-client/libs/admin-settings/src/lib/admin-settings.module.ts b/alfa-client/libs/admin-settings/src/lib/admin-settings.module.ts index ddb76b52e80053f8f5ebe1bb356741640c498cb6..380a7a84aae3a18558414dae2e9cd3a390f75275 100644 --- a/alfa-client/libs/admin-settings/src/lib/admin-settings.module.ts +++ b/alfa-client/libs/admin-settings/src/lib/admin-settings.module.ts @@ -13,6 +13,7 @@ import { SettingListResourceService, } from './admin-settings-resource.service'; import { SettingsService } from './admin-settings.service'; +import { SETTING_FEATURE_KEY, settingReducers } from './admin-settings.state'; import { ConfigurationResourceService, createConfigurationResourceService, @@ -69,6 +70,7 @@ import { TextFieldComponent } from './shared/text-field/text-field.component'; ReactiveFormsModule, StoreModule.forFeature(CONFIGURATION_FEATURE_KEY, configurationReducers), StoreModule.forFeature(POSTFACH_FEATURE_KEY, postfachReducers), + StoreModule.forFeature(SETTING_FEATURE_KEY, settingReducers), ], exports: [ PostfachContainerComponent, diff --git a/alfa-client/libs/admin-settings/src/lib/admin-settings.state.ts b/alfa-client/libs/admin-settings/src/lib/admin-settings.state.ts new file mode 100644 index 0000000000000000000000000000000000000000..cdcf69b4254adf314f5c8003faeb64ab4015ec35 --- /dev/null +++ b/alfa-client/libs/admin-settings/src/lib/admin-settings.state.ts @@ -0,0 +1,20 @@ +import { + ListResourceReducer, + ListResourceState, + createListResourceActions, +} from '@alfa-client/tech-shared'; +import { Action, ActionReducerMap } from '@ngrx/store'; + +export const SETTING_FEATURE_KEY = 'SettingState'; + +export const SETTING_LIST_PATH = 'settingList'; + +export function settingListResourceReducer(state: ListResourceState, action: Action) { + const resourceReducer: ListResourceReducer = new ListResourceReducer( + createListResourceActions({ name: SETTING_FEATURE_KEY, path: SETTING_LIST_PATH }), + ); + return resourceReducer.reducer(state, action); +} +export const settingReducers: ActionReducerMap<any> = { + [SETTING_LIST_PATH]: settingListResourceReducer, +}; diff --git a/alfa-client/libs/admin-settings/src/lib/configuration/configuration-resource.service.ts b/alfa-client/libs/admin-settings/src/lib/configuration/configuration-resource.service.ts index 51fcf93f8aab03e0865abfcd741bf2d9b3a393ad..36dc80f5070dda3a40534607456592feb37bc2db 100644 --- a/alfa-client/libs/admin-settings/src/lib/configuration/configuration-resource.service.ts +++ b/alfa-client/libs/admin-settings/src/lib/configuration/configuration-resource.service.ts @@ -25,7 +25,7 @@ function buildConfig(apiRootService: ApiRootService): ResourceServiceConfig<ApiR return { stateInfo: { name: CONFIGURATION_FEATURE_KEY, - featureName: CONFIGURATION_PATH, + path: CONFIGURATION_PATH, }, baseResource: apiRootService.getApiRoot(), getLinkRel: ApiRootLinkRel.CONFIGURATION, diff --git a/alfa-client/libs/admin-settings/src/lib/configuration/configuration.state.ts b/alfa-client/libs/admin-settings/src/lib/configuration/configuration.state.ts index c2c220bc4a5d3d6048053593b734f66e1747a0fe..a81bde1ea33419b997015f82dab0c9e6def8a22c 100644 --- a/alfa-client/libs/admin-settings/src/lib/configuration/configuration.state.ts +++ b/alfa-client/libs/admin-settings/src/lib/configuration/configuration.state.ts @@ -11,7 +11,7 @@ export const CONFIGURATION_PATH = 'configuration'; export function configurationResourceReducer(state: ListResourceState, action: Action) { const resourceReducer: ListResourceReducer = new ListResourceReducer( - createListResourceActions({ name: CONFIGURATION_FEATURE_KEY, featureName: CONFIGURATION_PATH }), + createListResourceActions({ name: CONFIGURATION_FEATURE_KEY, path: CONFIGURATION_PATH }), ); return resourceReducer.reducer(state, action); } diff --git a/alfa-client/libs/admin-settings/src/lib/postfach/postfach.state.ts b/alfa-client/libs/admin-settings/src/lib/postfach/postfach.state.ts index cb024086786e251dbf1b9ed14347619e381a6055..7e34ebbde765debb137d31df6105d03aa67e6566 100644 --- a/alfa-client/libs/admin-settings/src/lib/postfach/postfach.state.ts +++ b/alfa-client/libs/admin-settings/src/lib/postfach/postfach.state.ts @@ -11,7 +11,7 @@ export const POSTFACH_PATH = 'postfach'; export function postfachResourceReducer(state: SingleResourceState, action: Action) { const resourceReducer: SingleResourceReducer = new SingleResourceReducer( - createSingleResourceActions({ name: POSTFACH_FEATURE_KEY, featureName: POSTFACH_PATH }), + createSingleResourceActions({ name: POSTFACH_FEATURE_KEY, path: POSTFACH_PATH }), ); return resourceReducer.reducer(state, action); } 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 8d0c95be8fc0643e04432c68ddc92e0a3f913756..689bb74c77980db6e07ab8a5338c59ed38bb9a9c 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 @@ -80,14 +80,14 @@ export const reducers: ActionReducerMap<any> = { function bescheidDraftResourceReducer(state: BescheidState, action: Action) { const resourceReducer: SingleResourceReducer = new SingleResourceReducer( - createSingleResourceActions({ name: BESCHEID_FEATURE_KEY, featureName: BESCHEID_DRAFT_PATH }), + createSingleResourceActions({ name: BESCHEID_FEATURE_KEY, path: BESCHEID_DRAFT_PATH }), ); return resourceReducer.reducer(state, action); } function bescheidListResourceReducer(state: BescheidState, action: Action) { const resourceReducer: ListResourceReducer = new ListResourceReducer( - createListResourceActions({ name: BESCHEID_FEATURE_KEY, featureName: BESCHEID_LIST_PATH }), + createListResourceActions({ name: BESCHEID_FEATURE_KEY, path: BESCHEID_LIST_PATH }), ); return resourceReducer.reducer(state, action); } 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 46e1442dc34c7c73d29f653e8400525f7c3c9c82..f66c35f1058ec3bddca743c441b6eeeb6b5cb926 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -10,10 +10,10 @@ import { CommandService, getEffectedResourceUrl, tapOnCommandSuccessfullyDone, + CommandListResourceService } from '@alfa-client/command-shared'; import { HttpError, - ResourceListService, StateResource, createEmptyStateResource, createStateResource, @@ -77,7 +77,7 @@ import { DocumentResource } from './document.model'; @Injectable({ providedIn: 'root' }) export class BescheidService { bescheidDraftService: CommandResourceService<VorgangWithEingangResource, BescheidResource>; - bescheidListService: ResourceListService< + bescheidListService: CommandListResourceService< VorgangWithEingangResource, BescheidListResource, BescheidResource @@ -118,9 +118,10 @@ export class BescheidService { this.stateService, this.commandService, ); - this.bescheidListService = new ResourceListService( + this.bescheidListService = new CommandListResourceService( this.buildBescheidListServiceConfig(), this.stateService, + this.commandService, ); } @@ -128,7 +129,7 @@ export class BescheidService { return { stateInfo: { name: BESCHEID_FEATURE_KEY, - featureName: BESCHEID_DRAFT_PATH, + path: BESCHEID_DRAFT_PATH, }, baseResource: this.vorgangService.getVorgangWithEingang(), getLinkRel: VorgangWithEingangLinkRel.BESCHEID_DRAFT, @@ -141,7 +142,7 @@ export class BescheidService { return { stateInfo: { name: BESCHEID_FEATURE_KEY, - featureName: BESCHEID_LIST_PATH, + path: BESCHEID_LIST_PATH, }, baseResource: this.vorgangService.getVorgangWithEingang(), getLinkRel: VorgangWithEingangLinkRel.BESCHEIDE, diff --git a/alfa-client/libs/command-shared/src/index.ts b/alfa-client/libs/command-shared/src/index.ts index ebafbac511a499d1cea385d069c8fe876d21373f..1f89975aca737ea5e6bcfb99243f8f35aeb7f7b5 100644 --- a/alfa-client/libs/command-shared/src/index.ts +++ b/alfa-client/libs/command-shared/src/index.ts @@ -22,6 +22,7 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ export * from './lib/+state/command.actions'; +export * from './lib/command-list-resource.service'; export * from './lib/command-resource.service'; export * from './lib/command-shared.module'; export * from './lib/command.linkrel'; diff --git a/alfa-client/libs/command-shared/src/lib/command-list-resource.service.ts b/alfa-client/libs/command-shared/src/lib/command-list-resource.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..af377e2b26e461ae6803ded022adf1cbe422ddd9 --- /dev/null +++ b/alfa-client/libs/command-shared/src/lib/command-list-resource.service.ts @@ -0,0 +1,106 @@ +import { + ListItemResource, + ListResource, + ListResourceServiceConfig, + ResourceListService, + StateResource, + createEmptyStateResource, +} from '@alfa-client/tech-shared'; +import { Resource } from '@ngxp/rest'; +import { StateService } from 'libs/tech-shared/src/lib/ngrx/resource.state.service'; +import { Observable, startWith, switchMap } from 'rxjs'; +import { CommandResource, CreateCommandProps } from './command.model'; +import { CommandService } from './command.service'; + +export class CommandListResourceService< + B extends Resource, + T extends ListResource, + I extends ListItemResource, +> extends ResourceListService<B, T, I> { + constructor( + protected config: ListResourceServiceConfig<B>, + protected stateService: StateService, + private commandService: CommandService, + ) { + super(config, stateService); + } + + public create(props: CreateCommandProps): Observable<StateResource<CommandResource>> { + return this.resourceStateService.selectResource().pipe( + switchMap((listStateResource: StateResource<T>) => + this.commandService.createCommandByProps({ + ...props, + resource: listStateResource.resource, + linkRel: this.config.createLinkRel, + }), + ), + startWith(createEmptyStateResource<CommandResource>(true)), + ); + } + // return this.createCreateWiedervorlageCommand( + // this.wiedervorlageList$.value.resource, + // toCreate, + // ).pipe( + // filter((commandStateResource) => !commandStateResource.loading), + // tap((commandStateResource) => + // this.proceedAfterReceiveCommand( + // commandStateResource, + // this.buildMessage(WiedervorlageMessages.CREATED, toCreate), + // ), + // ), + // startWith(createEmptyStateResource<CommandResource>(true)), + // ); + // } + + // createCreateWiedervorlageCommand( + // listResource: T, + // props: CreateCommandProps, + // ): Observable<StateResource<CommandResource>> { + // return this.commandService.createCommandByProps({ + // ...props, + // resource: listResource, + // linkRel: this.config.createLinkRel + // }); + // return null; + // return this.commandService.createCommandByProps({ + // resource: listResource, + // linkRel: this.config.createLinkRel, + // command: this.buildCreateWiedervorlageCommand(props.toCreate), + // snackBarMessage: props.snackbarMessage + // }); + // return this.commandService.createCommand( + // listResource, + // this.config.createLinkRel, //CREATE_WIEDERVORLAGE, + // this.buildCreateWiedervorlageCommand(toCreate), + // ); + // } + + // proceedAfterReceiveCommand( + // commandStateResource: StateResource<CommandResource>, + // message: string, + // ): void { + // this.submitInProgress$.next({ + // ...this.submitInProgress$.value, + // resource: commandStateResource.resource, + // }); + // if (isDone(commandStateResource.resource)) { + // this.submitInProgress$.next(createStateResource(commandStateResource.resource)); + // this.snackbarService.show(commandStateResource.resource, message); + // this.setWiedervorlageListReload(); + // } else if (hasError(commandStateResource)) { + // this.submitInProgress$.next(createStateResource(commandStateResource.resource)); + // } + // } + + // private buildMessage(message: string, toCreate: unknown) { + // return replacePlaceholder(message, 'betreff', wiedervorlage.betreff); + // } + + // private buildCreateWiedervorlageCommand(toCreate: unknown): Command { + // return <any>{ order: CommandOrder.CREATE_WIEDERVORLAGE, toCreate, body: null }; + // } + + // setWiedervorlageListReload(): void { + // this.wiedervorlageList$.next({ ...this.wiedervorlageList$.value, reload: true }); + // } +} diff --git a/alfa-client/libs/tech-shared/src/index.ts b/alfa-client/libs/tech-shared/src/index.ts index 4cea35d10a9f276badbf29c48538e1902a398959..94e7e15c69b85bf4bdb209f2f0925c5cc185806d 100644 --- a/alfa-client/libs/tech-shared/src/index.ts +++ b/alfa-client/libs/tech-shared/src/index.ts @@ -31,7 +31,7 @@ export * from './lib/form.util'; export * from './lib/http.util'; export * from './lib/message-code'; export * from './lib/ngrx/actions'; -export * from './lib/ngrx/del.resource.reducer'; +export * from './lib/ngrx/resource.reducer'; export * from './lib/ngrx/resource.state'; export * from './lib/ngrx/resource.state.service'; export * from './lib/pipe/convert-for-data-test.pipe'; diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/actions.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/actions.ts index 2976dafda8b4e771e373859918c69b36077b5c0e..933c202a343115d6e4ab48ad600d6a9425b92acd 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/actions.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/actions.ts @@ -55,8 +55,6 @@ export interface LoadResourceFailureProps { error: HttpError; } -export interface LoadResourceSuccessProps {} - export interface ResourceActions { loadAction: TypedActionCreatorWithProps<ResourceUriProps>; loadFailureAction: TypedActionCreatorWithProps<LoadResourceFailureProps>; @@ -73,28 +71,28 @@ export interface ListResourceLoadActions extends ResourceActions { } export function createSingleResourceActions(stateInfo: StateInfo): SingleResourceLoadActions { - const stateName: string = stateInfo.name; - const subPath: string = stateInfo.featureName; + const actions: ResourceActions = createResourceActions( + stateInfo.name, + `${stateInfo.path} Resource`, + ); + return { ...actions, loadSuccessAction: createLoadSuccessAction(stateInfo) }; +} - const actions: ResourceActions = createResourceActions(stateName, `${subPath} Resource`); - const loadSuccessAction: TypedActionCreatorWithProps<LoadResourceSuccessProps> = createAction( - createActionType(stateName, `Load ${subPath} Resource Success`), +function createLoadSuccessAction( + stateInfo: StateInfo, +): TypedActionCreatorWithProps<LoadResourceSuccessProps> { + return createAction( + createActionType(stateInfo.name, `Load ${stateInfo.path} Resource Success`), props<LoadResourceSuccessProps>(), ); - return { ...actions, loadSuccessAction }; } export function createListResourceActions(stateInfo: StateInfo): ListResourceLoadActions { - const stateName: string = stateInfo.name; - const subPath: string = stateInfo.featureName; - - const actions: ResourceActions = createResourceActions(stateName, `${subPath} ListResource`); - const loadListSuccessAction: TypedActionCreatorWithProps<LoadListResourceSuccessProps> = - createAction( - createActionType(stateName, `Load ${subPath} ListResource Success`), - props<LoadListResourceSuccessProps>(), - ); - return { ...actions, loadListSuccessAction }; + const actions: ResourceActions = createResourceActions( + stateInfo.name, + `${stateInfo.path} ListResource`, + ); + return { ...actions, loadListSuccessAction: createLoadListSuccessAction(stateInfo) }; } function createResourceActions(stateName: string, message: string): ResourceActions { @@ -118,3 +116,12 @@ function createResourceActions(stateName: string, message: string): ResourceActi function createActionType(stateName: string, message: string): string { return `[${stateName}] ${message}`; } + +function createLoadListSuccessAction( + stateInfo: StateInfo, +): TypedActionCreatorWithProps<LoadListResourceSuccessProps> { + return createAction( + createActionType(stateInfo.name, `Load ${stateInfo.path} ListResource Success`), + props<LoadListResourceSuccessProps>(), + ); +} diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/del.reducer.service.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/del.reducer.service.ts index 22fc605c62099e8930b8c10a799f6d89b3289641..7f14f5558b3e1594fc6033f2262787a62a2ae4b7 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/del.reducer.service.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/del.reducer.service.ts @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core'; import { Action, ActionReducer, ActionReducerMap, ReducerManager } from '@ngrx/store'; import { StateInfo } from '../resource/resource.model'; import { SingleResourceLoadActions } from './actions'; -import { SingleResourceReducer } from './del.resource.reducer'; +import { SingleResourceReducer } from './resource.reducer'; import { SingleResourceStateService } from './resource.state.service'; @Injectable({ diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.loader.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.loader.ts index 1805d65a48f8a621ce519c44f5c6f0e4a427fec6..a0f969b7177a5fd84b580f2f53918777f93f38d2 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.loader.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.loader.ts @@ -11,14 +11,14 @@ import { isStateResoureStable, } from '../resource/resource.util'; import { isNotNull } from '../tech.util'; -import { GenerellResourceStateService } from './resource.state.service'; +import { ResourceStateService } from './resource.state.service'; export class ResourceLoader<B extends Resource, T extends Resource> { configResource: B = null; constructor( private config: ServiceConfig<B>, - private resourceStateService: GenerellResourceStateService<T>, + private resourceStateService: ResourceStateService<T>, ) {} public get(): Observable<StateResource<T>> { diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/del.resource.reducer.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.reducer.ts similarity index 52% rename from alfa-client/libs/tech-shared/src/lib/ngrx/del.resource.reducer.ts rename to alfa-client/libs/tech-shared/src/lib/ngrx/resource.reducer.ts index 05a1f89bd3b429bb50a83f3b0d1748209e0fff08..e941b917ad8d7fa7483ffabc5a415559814e7ade 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/del.resource.reducer.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.reducer.ts @@ -1,4 +1,4 @@ -import { Action, ActionReducer, createReducer, on } from '@ngrx/store'; +import { Action, ActionReducer, ReducerTypes, createReducer, on } from '@ngrx/store'; import { createEmptyStateResource, createErrorStateResource, @@ -9,7 +9,9 @@ import { LoadListResourceSuccessProps, LoadResourceFailureProps, LoadResourceSuccessProps, + ResourceUriProps, SingleResourceLoadActions, + TypedActionCreatorWithProps, } from './actions'; import { ListResourceState, @@ -22,56 +24,74 @@ export class SingleResourceReducer { public reducer: ActionReducer<any, Action>; constructor(private actions: SingleResourceLoadActions) { - this.init(); + this.initReducer(); } - private init(): void { + private initReducer(): void { this.reducer = createReducer( initialResourceState, - on(this.actions.loadAction, (state: SingleResourceState): SingleResourceState => { - console.info('State after LOAD', { - ...state, - resource: { ...state.resource, loading: true, reload: false }, - }); + this.createLoadActionReducer(), + this.createLoadSuccessActionReducer(), + this.createFailureActionReducer(), + this.createClearActionReducer(), + this.createReloadActionReducer(), + ); + } + + private createLoadActionReducer(): ReducerTypes< + SingleResourceState, + [TypedActionCreatorWithProps<ResourceUriProps>] + > { + return on(this.actions.loadAction, (state: SingleResourceState): SingleResourceState => { + return { + ...state, + resource: { ...state.resource, loading: true }, + }; + }); + } + + private createLoadSuccessActionReducer(): ReducerTypes< + SingleResourceState, + [TypedActionCreatorWithProps<LoadResourceSuccessProps>] + > { + return on( + this.actions.loadSuccessAction, + (state: SingleResourceState, props: LoadResourceSuccessProps): SingleResourceState => { return { ...state, - resource: { ...state.resource, loading: true }, + resource: createStateResource(props.resource), }; + }, + ); + } + + private createFailureActionReducer() { + return on( + this.actions.loadFailureAction, + (state: SingleResourceState, props: LoadResourceFailureProps): SingleResourceState => ({ + ...state, + resource: createErrorStateResource(props.error), + }), + ); + } + + private createClearActionReducer() { + return on( + this.actions.clearAction, + (state: SingleResourceState): SingleResourceState => ({ + ...state, + resource: createEmptyStateResource(), + }), + ); + } + + private createReloadActionReducer() { + return on( + this.actions.reloadAction, + (state: SingleResourceState): SingleResourceState => ({ + ...state, + resource: { ...state.resource, reload: true }, }), - on( - this.actions.loadSuccessAction, - (state: SingleResourceState, props: LoadResourceSuccessProps): SingleResourceState => { - console.info('State after SUCCESS', { - ...state, - resource: createStateResource(props.resource), - }); - return { - ...state, - resource: createStateResource(props.resource), - }; - }, - ), - on( - this.actions.loadFailureAction, - (state: SingleResourceState, props: LoadResourceFailureProps): SingleResourceState => ({ - ...state, - resource: createErrorStateResource(props.error), - }), - ), - on( - this.actions.clearAction, - (state: SingleResourceState): SingleResourceState => ({ - ...state, - resource: createEmptyStateResource(), - }), - ), - on( - this.actions.reloadAction, - (state: SingleResourceState): SingleResourceState => ({ - ...state, - resource: { ...state.resource, reload: true }, - }), - ), ); } } @@ -80,17 +100,13 @@ export class ListResourceReducer { public reducer: ActionReducer<any, Action>; constructor(private actions: ListResourceLoadActions) { - this.init(); + this.initReducer(); } - private init(): void { + private initReducer(): void { this.reducer = createReducer( initialListResourceState, on(this.actions.loadAction, (state: ListResourceState): ListResourceState => { - console.info('State after LOAD', { - ...state, - resource: { ...state.listResource, loading: true, reload: false }, - }); return { ...state, listResource: { ...state.listResource, loading: true }, @@ -99,10 +115,6 @@ export class ListResourceReducer { on( this.actions.loadListSuccessAction, (state: ListResourceState, props: LoadListResourceSuccessProps): ListResourceState => { - console.info('State after SUCCESS', { - ...state, - listResource: createStateResource(props.listResource), - }); return { ...state, listResource: createStateResource(props.listResource), diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.selector.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.selector.ts index 76fd21b9bfa86f970c3d674849998ed7d24d6450..ab2a6729e760da2a19e3a08d29398efc0849fe1a 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.selector.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.selector.ts @@ -2,6 +2,7 @@ import { createFeatureSelector, createSelector } from '@ngrx/store'; import { StateInfo } from '../resource/resource.model'; import { ListResourceState, SingleResourceState } from './resource.state'; +//Single Resource export const selectResource = <T>(stateInfo: StateInfo) => createSelector( createFeatureSelector<SingleResourceState>(stateInfo.name), @@ -16,6 +17,7 @@ export const existResource = <T>(stateInfo: StateInfo) => <T>getFeatureState<SingleResourceState>(stateInfo, state).resource.loaded, ); +//List Resource export const selectListResource = <T>(stateInfo: StateInfo) => createSelector( createFeatureSelector<ListResourceState>(stateInfo.name), @@ -23,19 +25,6 @@ export const selectListResource = <T>(stateInfo: StateInfo) => <T>getFeatureState<ListResourceState>(stateInfo, state).listResource, ); -// export const selectListItems = <T>( -// stateInfo: StateInfo, -// ): MemoizedSelector<object, T, (s1: ResourceState) => T> => -// createSelector( -// createFeatureSelector<ResourceState>(stateInfo.name), -// (state: ResourceState) => { -// const featureState = getFeatureState<ListResourceState>(stateInfo, state); -// const listResource: StateResource<T> = isNotNull(featureState.listResource.resource) && - -// // return <T>getFeatureState<ResourceState>(stateInfo, state).resource; -// } -// ); - function getFeatureState<T>(stateInfo: StateInfo, state: any): T { - return <T>state.hasOwnProperty(stateInfo.featureName) ? state[stateInfo.featureName] : state; + return <T>state.hasOwnProperty(stateInfo.path) ? state[stateInfo.path] : state; } diff --git a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.state.service.ts b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.state.service.ts index e866a4f7741d9986c83755315f8b5e5f657033ad..9dba6d4d8a99cd3e84bded6949fe8b9d14b39443 100644 --- a/alfa-client/libs/tech-shared/src/lib/ngrx/resource.state.service.ts +++ b/alfa-client/libs/tech-shared/src/lib/ngrx/resource.state.service.ts @@ -31,7 +31,7 @@ export class StateService { } } -export abstract class GenerellResourceStateService<T> { +export abstract class ResourceStateService<T> { actions: ResourceActions; constructor( @@ -66,7 +66,7 @@ export abstract class GenerellResourceStateService<T> { public abstract selectResource<T>(): Observable<StateResource<T>>; } -export class SingleResourceStateService<T> extends GenerellResourceStateService<T> { +export class SingleResourceStateService<T> extends ResourceStateService<T> { actions: SingleResourceLoadActions; constructor( @@ -94,7 +94,7 @@ export class SingleResourceStateService<T> extends GenerellResourceStateService< } } -export class ListResourceStateService<T> extends GenerellResourceStateService<T> { +export class ListResourceStateService<T> extends ResourceStateService<T> { actions: ListResourceLoadActions; constructor( diff --git a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts index e7fa7cbce2463605e09e6b289ffe160a7409e4ad..34a081301e817eb5c20c45f8f99be619651270ec 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/list-resource.service.ts @@ -10,7 +10,7 @@ import { ListResource, StateResource, getEmbeddedResources } from './resource.ut * T = Type of listresource * I = Type of items in listresource */ -export class ResourceListService< +export abstract class ResourceListService< B extends Resource, T extends ListResource, I extends ListItemResource, @@ -26,14 +26,14 @@ export class ResourceListService< // createEmptyStateResource(), // ); - baseResource: B = null; + // baseResource: B = null; resourceStateService: ListResourceStateService<T>; resourceLoader: ResourceLoader<B, T>; constructor( - private config: ListResourceServiceConfig<B>, - private stateService: StateService, + protected config: ListResourceServiceConfig<B>, + protected stateService: StateService, ) { this.initStateService(); this.initResourceLoader(); @@ -53,6 +53,14 @@ export class ResourceListService< return this.resourceLoader.get(); } + public selectList(): Observable<StateResource<T>> { + return this.resourceStateService.selectResource(); + } + + // public loadByGivenBaseResource(baseResource: B):StateResource<T> { + // return this.resourceLoader.getByBaseResource(baseResource); + // } + //TODO migrieren // public getList(): Observable<StateResource<T>> { diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource.model.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource.model.ts index 09437b2a437b9686b8b7367196b97167c77a3e32..9f03b96d37ea579c1716d98444c90ff47497e551 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource.model.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource.model.ts @@ -4,7 +4,7 @@ import { StateResource } from './resource.util'; export interface StateInfo { name: string; - featureName: string; //TODO Rename + path: string; } export interface ServiceConfig<B> { diff --git a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.spec.ts index 9048ea218b5a838a57884121a7e6be9b35173dcc..1952b0e3d8eae2d42b02a8471bef42b4246c1a99 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.spec.ts @@ -1,5 +1,14 @@ -import { AktenzeichenEditDialogComponent } from '@alfa-client/vorgang-detail'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { + COMMAND_ERROR_MESSAGES, + CommandErrorMessage, + hasError, + isSuccessfulDone, +} from '@alfa-client/command-shared'; +import { + createEmptyStateResource, + hasContent, + isClipboardReadSupported, +} from '@alfa-client/tech-shared'; import { mock } from '@alfa-client/test-utils'; import { OzgcloudPasteTextButtonComponent, @@ -7,8 +16,9 @@ import { SnackBarService, TextEditorComponent, } from '@alfa-client/ui'; -import { MockComponent, MockDirective } from 'ng-mocks'; import { VorgangService } from '@alfa-client/vorgang-shared'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { FormBuilder, ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; import { MAT_DIALOG_DATA, MatDialogActions, @@ -16,27 +26,17 @@ import { MatDialogRef, } from '@angular/material/dialog'; import { MatIcon } from '@angular/material/icon'; +import { cold, hot } from 'jest-marbles'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; -import { - createEmptyStateResource, - hasContent, - isClipboardReadSupported, -} from '@alfa-client/tech-shared'; +import { MockComponent, MockDirective } from 'ng-mocks'; import { EMPTY, NEVER } from 'rxjs'; -import { FormBuilder, ReactiveFormsModule, UntypedFormControl } from '@angular/forms'; -import { cold, hot } from 'jest-marbles'; import { createCommandErrorResource, createCommandResource, } from '../../../../command-shared/test/command'; -import { - COMMAND_ERROR_MESSAGES, - CommandErrorMessage, - hasError, - isSuccessfulDone, -} from '@alfa-client/command-shared'; -import { AktenzeichenEditDialogMessages } from './aktenzeichen-edit-dialog.message'; +import { AktenzeichenEditDialogComponent } from './aktenzeichen-edit-dialog.component'; import { AktenzeichenEditDialogFormservice } from './aktenzeichen-edit-dialog.formservice'; +import { AktenzeichenEditDialogMessages } from './aktenzeichen-edit-dialog.message'; jest.mock('@alfa-client/tech-shared'); const isClipboardReadSupportedMock = isClipboardReadSupported as jest.Mock; diff --git a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-editable/aktenzeichen-editable.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-editable/aktenzeichen-editable.component.spec.ts index 0c89af4e82cab281dd3dcd6afe2c8cab28a6574c..ff9fac80cc66eab370ef4677e805fe24aa697c8e 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-editable/aktenzeichen-editable.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-editable/aktenzeichen-editable.component.spec.ts @@ -21,17 +21,16 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { AktenzeichenEditableComponent } from '@alfa-client/vorgang-detail'; -import { DialogService } from '@alfa-client/ui'; +import { HasLinkPipe } from '@alfa-client/tech-shared'; import { mock } from '@alfa-client/test-utils'; -import { MockComponent } from 'ng-mocks'; -import { OzgcloudIconButtonPrimaryComponent } from '@alfa-client/ui'; +import { DialogService, OzgcloudIconButtonPrimaryComponent } from '@alfa-client/ui'; +import { VorgangWithEingangLinkRel } from '@alfa-client/vorgang-shared'; import { AktenzeichenComponent } from '@alfa-client/vorgang-shared-ui'; -import { AktenzeichenEditDialogComponent } from '@alfa-client/vorgang-detail'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; -import { createEmptyStateResource, HasLinkPipe } from '@alfa-client/tech-shared'; -import { VorgangWithEingangLinkRel } from '@alfa-client/vorgang-shared'; +import { MockComponent } from 'ng-mocks'; +import { AktenzeichenEditDialogComponent } from '../aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component'; +import { AktenzeichenEditableComponent } from './aktenzeichen-editable.component'; describe('AktenzeichenComponent', () => { let component: AktenzeichenEditableComponent; diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-header/vorgang-detail-header.component.spec.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-header/vorgang-detail-header.component.spec.ts index 14c286f23318ad1a488b34f845e4ab24c3253228..ad3b01b5a42db9f13796e5e482b2e4a0a507c94a 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-header/vorgang-detail-header.component.spec.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-area/vorgang-detail-header/vorgang-detail-header.component.spec.ts @@ -24,7 +24,6 @@ import { BeschiedenDateInVorgangContainerComponent } from '@alfa-client/bescheid'; import { EMPTY_STRING, EnumToLabelPipe, HasLinkPipe } from '@alfa-client/tech-shared'; import { getDebugElementFromFixtureByCss } from '@alfa-client/test-utils'; -import { AktenzeichenEditableComponent } from '@alfa-client/vorgang-detail'; import { VorgangHeaderLinkRel } from '@alfa-client/vorgang-shared'; import { VorgangNummerComponent, @@ -39,6 +38,7 @@ import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { UserProfileInVorgangContainerComponent } from 'libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang-container.component'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; +import { AktenzeichenEditableComponent } from '../../../aktenzeichen-editable/aktenzeichen-editable.component'; import { VorgangDetailHeaderComponent } from './vorgang-detail-header.component'; describe('VorgangDetailHeaderComponent', () => { diff --git a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-list-resource.service.ts b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-list-resource.service.ts new file mode 100644 index 0000000000000000000000000000000000000000..86f4718839f432f20eb0aa6006d70f3636327561 --- /dev/null +++ b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-list-resource.service.ts @@ -0,0 +1,38 @@ +import { CommandListResourceService, CommandService } from '@alfa-client/command-shared'; +import { ListResourceServiceConfig, StateService } from '@alfa-client/tech-shared'; +import { + VorgangHeaderLinkRel, + VorgangService, + VorgangWithEingangResource, +} from '@alfa-client/vorgang-shared'; +import { WiedervorlageListLinkRel } from './wiedervorlage.linkrel'; +import { WiedervorlageListResource, WiedervorlageResource } from './wiedervorlage.model'; +import { WIEDERVORLAGE_FEATURE_KEY, WIEDERVORLAGE_LIST_PATH } from './wiedervorlage.state'; + +export class WiedervorlageListResourceService extends CommandListResourceService< + VorgangWithEingangResource, + WiedervorlageListResource, + WiedervorlageResource +> {} + +export function createWiedervorlageListResourceService( + vorgangService: VorgangService, + stateService: StateService, + commandService: CommandService, +) { + return new CommandListResourceService(buildConfig(vorgangService), stateService, commandService); +} + +function buildConfig( + vorgangService: VorgangService, +): ListResourceServiceConfig<VorgangWithEingangResource> { + return { + stateInfo: { + name: WIEDERVORLAGE_FEATURE_KEY, + path: WIEDERVORLAGE_LIST_PATH, + }, + baseResource: vorgangService.getVorgangWithEingang(), + getLinkRel: VorgangHeaderLinkRel.WIEDERVORLAGEN, + listResourceListLinkRel: WiedervorlageListLinkRel.WIEDERVORLAGE_LIST, + }; +} diff --git a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-shared.module.ts b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-shared.module.ts index ef0580cbd675dc17aea810fba6988b6c48b57354..a74ce1b8471dc94f60757d8cc8c7e0b6b1ee5842 100644 --- a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-shared.module.ts +++ b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage-shared.module.ts @@ -21,10 +21,10 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; +import { WiedervorlageService } from './wiedervorlage.service'; @NgModule({ - imports: [CommonModule], + providers: [WiedervorlageService], }) export class WiedervorlageSharedModule {} diff --git a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts index a96d7ca4e7cd27b2936a41b5b91e9fcbfc1f853d..52cf5e2fa57ccfc42ee4e3a677432c62e9b444f0 100644 --- a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts +++ b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts @@ -23,7 +23,6 @@ */ import { BinaryFileListResource, BinaryFileService } from '@alfa-client/binary-file-shared'; import { - Command, CommandOrder, CommandResource, CommandService, @@ -38,7 +37,6 @@ import { decodeUrlFromEmbedding, doIfLoadingRequired, hasError, - isNotNull, isNotUndefined, replacePlaceholder, } from '@alfa-client/tech-shared'; @@ -48,8 +46,9 @@ import { Injectable, OnDestroy } from '@angular/core'; import { Params } from '@angular/router'; import { ResourceUri, getUrl, hasLink } from '@ngxp/rest'; import { isEqual, isNil, isNull, isUndefined } from 'lodash-es'; -import { BehaviorSubject, Observable, Subscription, combineLatest } from 'rxjs'; +import { BehaviorSubject, Observable, Subscription } from 'rxjs'; import { filter, map, startWith, tap } from 'rxjs/operators'; +import { WiedervorlageListResourceService } from './wiedervorlage-list-resource.service'; import { WiedervorlageLinkRel, WiedervorlageListLinkRel } from './wiedervorlage.linkrel'; import { WiedervorlageMessages } from './wiedervorlage.message'; import { @@ -63,7 +62,7 @@ import { WiedervorlageRepository } from './wiedervorlage.repository'; import { WiedervorlageRoutes } from './wiedervorlage.route'; import { createErledigenCommand, createWiedereroeffnenCommand } from './wiedervorlage.util'; -@Injectable({ providedIn: 'root' }) +@Injectable() export class WiedervorlageService implements OnDestroy { static encodedWiedervorlageUriParam: string = 'wiedervorlageUrl'; @@ -274,8 +273,8 @@ export class WiedervorlageService implements OnDestroy { ); } - private buildCreateWiedervorlageCommand(wiedervorlage: Wiedervorlage): Command { - return <any>{ order: CommandOrder.CREATE_WIEDERVORLAGE, wiedervorlage, body: null }; + private buildCreateWiedervorlageCommand(wiedervorlage: Wiedervorlage): CreateCommand { + return { order: CommandOrder.CREATE_WIEDERVORLAGE, body: wiedervorlage }; } public saveWiedervorlage( diff --git a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.state.ts b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.state.ts new file mode 100644 index 0000000000000000000000000000000000000000..1314b37bc9bc3faf2db6a679599a9bef788cb347 --- /dev/null +++ b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.state.ts @@ -0,0 +1,17 @@ +import { ListResourceReducer, createListResourceActions } from '@alfa-client/tech-shared'; +import { Action, ActionReducerMap } from '@ngrx/store'; + +export const WIEDERVORLAGE_FEATURE_KEY = 'WiedervorlageState'; + +export const WIEDERVORLAGE_LIST_PATH = 'wiedervorlage'; + +export const reducers: ActionReducerMap<any> = { + [WIEDERVORLAGE_LIST_PATH]: wiedervorlageListReducer, +}; + +function wiedervorlageListReducer(state: unknown, action: Action) { + const resourceReducer: ListResourceReducer = new ListResourceReducer( + createListResourceActions({ name: WIEDERVORLAGE_FEATURE_KEY, path: WIEDERVORLAGE_LIST_PATH }), + ); + return resourceReducer.reducer(state, action); +} diff --git a/alfa-client/libs/wiedervorlage/src/lib/wiedervorlage.module.ts b/alfa-client/libs/wiedervorlage/src/lib/wiedervorlage.module.ts index 6e00e592bad7252dd3f375d439adbef4f17cd2d7..6d808d351778c02f73b17cf16f68c6e39be3b565 100644 --- a/alfa-client/libs/wiedervorlage/src/lib/wiedervorlage.module.ts +++ b/alfa-client/libs/wiedervorlage/src/lib/wiedervorlage.module.ts @@ -21,15 +21,16 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { CommonModule, DatePipe } from '@angular/common'; -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; import { BinaryFileModule } from '@alfa-client/binary-file'; import { TechSharedModule } from '@alfa-client/tech-shared'; import { UiModule } from '@alfa-client/ui'; import { UserProfileModule } from '@alfa-client/user-profile'; import { VorgangSharedModule } from '@alfa-client/vorgang-shared'; import { VorgangSharedUiModule } from '@alfa-client/vorgang-shared-ui'; +import { WiedervorlageSharedModule } from '@alfa-client/wiedervorlage-shared'; +import { CommonModule, DatePipe } from '@angular/common'; +import { NgModule } from '@angular/core'; +import { RouterModule, Routes } from '@angular/router'; import { CreateWiedervorlageButtonContainerComponent } from './create-wiedervorlage-button-container/create-wiedervorlage-button-container.component'; import { ErledigenButtonContainerComponent } from './erledigen-button-container/erledigen-button-container.component'; import { SubmitWiedervorlageButtonComponent } from './submit-wiedervorlage-button/submit-wiedervorlage-button.component'; @@ -69,6 +70,7 @@ const routes: Routes = [ VorgangSharedUiModule, BinaryFileModule, UserProfileModule, + WiedervorlageSharedModule, ], declarations: [ WiedervorlagePageComponent, diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java index 55b885acd5287b15b723de70261722f444ddce02..9621509f759ed337fd0dc1d5a30ed7712844c311 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/common/command/CommandBody.java @@ -45,6 +45,7 @@ import de.ozgcloud.alfa.wiedervorlage.Wiedervorlage; @Type(value = AssignUserCommandBody.class, name = "ASSIGN_USER"), @Type(value = RedirectRequest.class, name = "REDIRECT_VORGANG"), @Type(value = Wiedervorlage.class, name = "WIEDERVORLAGE"), + @Type(value = Wiedervorlage.class, name = "CREATE_WIEDERVORLAGE"), @Type(value = Kommentar.class, name = "KOMMENTAR"), @Type(value = LoeschAnforderung.class, name = "LOESCH_ANFORDERUNG"), @Type(value = DeleteLoeschAnforderung.class, name = "DELETE_LOESCH_ANFORDERUNG"), diff --git a/alfa-service/src/main/java/de/ozgcloud/alfa/wiedervorlage/WiedervorlageCommandController.java b/alfa-service/src/main/java/de/ozgcloud/alfa/wiedervorlage/WiedervorlageCommandController.java index 9435cef625d6ce8c64681ea60bc92ec1e73d6091..54ce4e874c11f9c1d945d1170be4286c6b5a5fe1 100644 --- a/alfa-service/src/main/java/de/ozgcloud/alfa/wiedervorlage/WiedervorlageCommandController.java +++ b/alfa-service/src/main/java/de/ozgcloud/alfa/wiedervorlage/WiedervorlageCommandController.java @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController; import de.ozgcloud.alfa.common.command.Command; import de.ozgcloud.alfa.common.command.CommandController; +import de.ozgcloud.alfa.common.command.CreateCommand; import de.ozgcloud.alfa.common.command.LegacyOrder; import de.ozgcloud.common.errorhandling.TechnicalException; import lombok.RequiredArgsConstructor; @@ -93,8 +94,8 @@ public class WiedervorlageCommandController { private final WiedervorlageService service; @PostMapping - public ResponseEntity<Void> createWiedervorlage(@RequestBody WiedervorlageCommand command, @PathVariable String vorgangId) { - var createdCommand = service.createWiedervorlage(command.getWiedervorlage(), vorgangId); + public ResponseEntity<Void> createWiedervorlage(@RequestBody CreateCommand command, @PathVariable String vorgangId) { + var createdCommand = service.createWiedervorlage((Wiedervorlage) command.getBody(), vorgangId); service.updateNextFrist(vorgangId);