From 99f7fa0c768d4cccae05461db86bfa033ab96560 Mon Sep 17 00:00:00 2001 From: OZGCloud <ozgcloud@mgm-tp.com> Date: Thu, 23 May 2024 13:38:26 +0200 Subject: [PATCH] OZG-5708 rename function in order to avoid ambiguity --- .../libs/bescheid-shared/src/lib/bescheid.service.ts | 10 +++++----- .../command-shared/src/lib/+state/command.effects.ts | 4 ++-- .../libs/command-shared/src/lib/command.util.spec.ts | 8 ++++---- .../libs/command-shared/src/lib/command.util.ts | 4 ++-- .../forwarding-shared/src/lib/forwarding.service.ts | 4 ++-- .../libs/postfach-shared/src/lib/postfach.service.ts | 4 ++-- .../postfach-mail-button-container.component.ts | 4 ++-- .../src/lib/resource/resource.rxjs.operator.ts | 4 ++-- .../libs/tech-shared/src/lib/resource/resource.util.ts | 4 ++-- .../src/lib/service/formservice.abstract.ts | 4 ++-- .../src/lib/user-icon/user-icon.component.ts | 4 ++-- .../user-profile-in-vorgang.component.ts | 4 ++-- .../aktenzeichen-edit-dialog.component.spec.ts | 4 ++-- .../aktenzeichen-edit-dialog.component.ts | 6 +++--- ...g-detail-bescheiden-result-attachments.component.ts | 4 ++-- ...organg-detail-bescheiden-steps-content.component.ts | 4 ++-- .../src/lib/wiedervorlage.service.ts | 4 ++-- 17 files changed, 40 insertions(+), 40 deletions(-) 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 1bb8e64482..05a83a1c48 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.service.ts @@ -19,7 +19,7 @@ import { createStateResource, filterIsLoadedOrHasError, getEmbeddedResources, - hasError, + hasStateResourceError, isLoaded, isNotEmpty, sortByGermanDateStr, @@ -353,7 +353,7 @@ export class BescheidService { bescheid: BescheidResource, binaryFileStateResource: StateResource<BinaryFileResource>, ): void { - if (hasError(binaryFileStateResource)) { + if (hasStateResourceError(binaryFileStateResource)) { this.setUploadBescheidDocumentInProgressError(binaryFileStateResource.error); } else { this.createBescheidDocumentFromFile(bescheid, binaryFileStateResource.resource); @@ -373,7 +373,7 @@ export class BescheidService { commandStateResource: StateResource<CommandResource>, binaryFile: BinaryFileResource, ): void { - if (hasError(commandStateResource)) { + if (hasStateResourceError(commandStateResource)) { this.setUploadBescheidDocumentInProgressError(commandStateResource.error); } else { this.bescheidDocument$.next(createEmptyStateResource()); @@ -425,7 +425,7 @@ export class BescheidService { private handleCreateBescheidDocumentResponse( commandStateResource: StateResource<CommandResource>, ): void { - if (hasError(commandStateResource)) { + if (hasStateResourceError(commandStateResource)) { this.setCreateBescheidDocumentInProgressError(commandStateResource.error); } else { const documentUri: ResourceUri = getEffectedResourceUrl(commandStateResource.resource); @@ -546,7 +546,7 @@ export class BescheidService { } handleAttachmentUpload(binaryFileStateResource: StateResource<BinaryFileResource>) { - if (hasError(binaryFileStateResource)) { + if (hasStateResourceError(binaryFileStateResource)) { this.uploadAttachmentInProgress$.next({ loading: false, error: binaryFileStateResource.error, 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 d9521a3ab9..3d7151381f 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 @@ -8,7 +8,7 @@ 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 { hasError, isConcurrentModification, isPending, isRevokeable } from '../command.util'; +import { hasCommandError, isConcurrentModification, isPending, isRevokeable } from '../command.util'; import { CommandProps, LoadCommandListProps, @@ -97,7 +97,7 @@ export class CommandEffects { if (isRevokeable(command)) { return [createCommandSuccess({ command }), showRevokeSnackbar({ command })]; } - if (hasError(command) && isConcurrentModification(command.errorMessage)) { + if (hasCommandError(command) && isConcurrentModification(command.errorMessage)) { this.showError(command); return [createCommandSuccess({ command }), publishConcurrentModificationAction()]; } diff --git a/alfa-client/libs/command-shared/src/lib/command.util.spec.ts b/alfa-client/libs/command-shared/src/lib/command.util.spec.ts index cd3f65d6bd..7567dbc61f 100644 --- a/alfa-client/libs/command-shared/src/lib/command.util.spec.ts +++ b/alfa-client/libs/command-shared/src/lib/command.util.spec.ts @@ -31,7 +31,7 @@ import { CommandErrorMessage } from './command.message'; import { CommandListResource, CommandResource } from './command.model'; import { getPendingCommandByOrder, - hasError, + hasCommandError, isConcurrentModification, isDone, isPending, @@ -81,19 +81,19 @@ describe('CommandUtil', () => { describe('hasError', () => { it('should be true if no update link is present and command has error message', () => { - const result = hasError(createCommandErrorResource()); + const result = hasCommandError(createCommandErrorResource()); expect(result).toBeTruthy(); }); it('should be false if update link is present', () => { - const result = hasError(createCommandResource([CommandLinkRel.UPDATE])); + const result = hasCommandError(createCommandResource([CommandLinkRel.UPDATE])); expect(result).toBeFalsy(); }); it('should be false if error message is not present', () => { - const result = hasError(createCommandResource()); + const result = hasCommandError(createCommandResource()); expect(result).toBeFalsy(); }); diff --git a/alfa-client/libs/command-shared/src/lib/command.util.ts b/alfa-client/libs/command-shared/src/lib/command.util.ts index 8132a7d316..2dc64f425d 100644 --- a/alfa-client/libs/command-shared/src/lib/command.util.ts +++ b/alfa-client/libs/command-shared/src/lib/command.util.ts @@ -43,7 +43,7 @@ export function hasErrorMessage(commandResource: CommandResource): boolean { return !isNil(commandResource.errorMessage) && !isEmpty(commandResource.errorMessage); } -export function hasError(commandResource: CommandResource): boolean { +export function hasCommandError(commandResource: CommandResource): boolean { return hasErrorMessage(commandResource) && !isPending(commandResource); } @@ -73,7 +73,7 @@ export function isConcurrentModification(errorMessage: string): boolean { } export function isSuccessfulDone(commandResource: CommandResource): boolean { - return isDone(commandResource) && !hasError(commandResource); + return isDone(commandResource) && !hasCommandError(commandResource); } export function getEffectedResourceUrl(command: CommandResource): ResourceUri { diff --git a/alfa-client/libs/forwarding-shared/src/lib/forwarding.service.ts b/alfa-client/libs/forwarding-shared/src/lib/forwarding.service.ts index c425ea44e5..21f33261b1 100644 --- a/alfa-client/libs/forwarding-shared/src/lib/forwarding.service.ts +++ b/alfa-client/libs/forwarding-shared/src/lib/forwarding.service.ts @@ -35,7 +35,7 @@ import { StateResource, createEmptyStateResource, createStateResource, - hasError, + hasStateResourceError, } from '@alfa-client/tech-shared'; import { ForwardRequest, @@ -162,7 +162,7 @@ export class ForwardingService implements OnDestroy { } reloadCurrentVorgang(command: StateResource<CommandResource>): void { - if (!hasError(command)) { + if (!hasStateResourceError(command)) { this.vorgangService.reloadCurrentVorgang(); } } diff --git a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts index dec067e551..f4bc26e468 100644 --- a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts +++ b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts @@ -31,7 +31,7 @@ import { CommandResource, CommandService, doIfCommandIsDone, - hasError, + hasCommandError, isDone, isPending, } from '@alfa-client/command-shared'; @@ -152,7 +152,7 @@ export class PostfachService { } private showSnackbar(commandResource: CommandResource): void { - if (hasError(commandResource)) { + if (hasCommandError(commandResource)) { this.snackbarService.showError(PostfachMessages.SEND_FAILED); } else { this.snackbarService.show(commandResource, PostfachMessages.SEND_SUCCESSFUL); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts index 6a4d16d49c..e52afef42b 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts @@ -28,7 +28,7 @@ import { PostfachMailListResource, PostfachService, } from '@alfa-client/postfach-shared'; -import { StateResource, hasError, isNotNull, isNotUndefined } from '@alfa-client/tech-shared'; +import { StateResource, hasStateResourceError, isNotNull, isNotUndefined } from '@alfa-client/tech-shared'; import { DialogService, FixedDialogComponent } from '@alfa-client/ui'; import { VorgangHeaderLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { getEmpfaenger } from '@alfa-client/vorgang-shared-ui'; @@ -89,7 +89,7 @@ export class PostfachMailButtonContainerComponent { closeDialog(commandStateResource: StateResource<CommandResource>): void { if ( - !hasError(commandStateResource) && + !hasStateResourceError(commandStateResource) && commandStateResource.loaded && isNotUndefined(this.dialogRef) ) { diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource.rxjs.operator.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource.rxjs.operator.ts index b7bc23b173..c2d7bc185f 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource.rxjs.operator.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource.rxjs.operator.ts @@ -1,6 +1,6 @@ import { Resource } from '@ngxp/rest'; import { Observable, filter, map } from 'rxjs'; -import { StateResource, hasError, isLoaded } from './resource.util'; +import { StateResource, hasStateResourceError, isLoaded } from './resource.util'; export function filterIsLoadedOrHasError<T>(): ( source: Observable<StateResource<T>>, @@ -8,7 +8,7 @@ export function filterIsLoadedOrHasError<T>(): ( return (source: Observable<StateResource<T>>): Observable<StateResource<T>> => { return source.pipe( filter( - (stateResource: StateResource<T>) => hasError(stateResource) || isLoaded(stateResource), + (stateResource: StateResource<T>) => hasStateResourceError(stateResource) || isLoaded(stateResource), ), ); }; diff --git a/alfa-client/libs/tech-shared/src/lib/resource/resource.util.ts b/alfa-client/libs/tech-shared/src/lib/resource/resource.util.ts index deaa71132a..17394d5b91 100644 --- a/alfa-client/libs/tech-shared/src/lib/resource/resource.util.ts +++ b/alfa-client/libs/tech-shared/src/lib/resource/resource.util.ts @@ -69,7 +69,7 @@ export function isLoaded<T>(stateResource: StateResource<T>): boolean { return !stateResource.loading && !stateResource.reload && isNotNull(stateResource.resource); } -export function hasError(stateResource: StateResource<any>): boolean { +export function hasStateResourceError(stateResource: StateResource<any>): boolean { return !isNil(stateResource.error); } @@ -115,7 +115,7 @@ export function getSuccessfullyLoaded<T extends Resource>( stateResources: StateResource<T>[], ): StateResource<T>[] { return stateResources.filter( - (stateResource) => isLoaded(stateResource) && !hasError(stateResource), + (stateResource) => isLoaded(stateResource) && !hasStateResourceError(stateResource), ); } diff --git a/alfa-client/libs/tech-shared/src/lib/service/formservice.abstract.ts b/alfa-client/libs/tech-shared/src/lib/service/formservice.abstract.ts index 753c742264..a02d2bab0a 100644 --- a/alfa-client/libs/tech-shared/src/lib/service/formservice.abstract.ts +++ b/alfa-client/libs/tech-shared/src/lib/service/formservice.abstract.ts @@ -27,7 +27,7 @@ import { Resource } from '@ngxp/rest'; import { isNil } from 'lodash-es'; import { Observable } from 'rxjs'; import { map } from 'rxjs/operators'; -import { StateResource, hasError } from '../resource/resource.util'; +import { StateResource, hasStateResourceError } from '../resource/resource.util'; import { ApiError, HttpError, InvalidParam, Issue, ProblemDetail } from '../tech.model'; import { isNotUndefined } from '../tech.util'; import { @@ -56,7 +56,7 @@ export abstract class AbstractFormService { handleResponse(result: StateResource<Resource | HttpError>): StateResource<Resource | HttpError> { if (result.loading) return result; - if (hasError(result)) { + if (hasStateResourceError(result)) { this.handleError(result.error); } return result; diff --git a/alfa-client/libs/user-profile/src/lib/user-icon/user-icon.component.ts b/alfa-client/libs/user-profile/src/lib/user-icon/user-icon.component.ts index 78547141a5..2a5c2244d1 100644 --- a/alfa-client/libs/user-profile/src/lib/user-icon/user-icon.component.ts +++ b/alfa-client/libs/user-profile/src/lib/user-icon/user-icon.component.ts @@ -25,7 +25,7 @@ import { Component, Input, SimpleChanges } from '@angular/core'; import { ApiError, createEmptyStateResource, - hasError, + hasStateResourceError, MessageCode, StateResource, } from '@alfa-client/tech-shared'; @@ -61,7 +61,7 @@ export class UserIconComponent { if (this.userProfileStateResource.resource) { return this.getUserTooltip(); } - if (hasError(this.userProfileStateResource)) { + if (hasStateResourceError(this.userProfileStateResource)) { return this.getErrorTooltip(); } return userProfileMessage.UNASSIGNED; diff --git a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-in-vorgang.component.ts b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-in-vorgang.component.ts index 4a93a23e00..1f150a1e04 100644 --- a/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-in-vorgang.component.ts +++ b/alfa-client/libs/user-profile/src/lib/user-profile-in-vorgang-container/user-profile-in-vorgang/user-profile-in-vorgang.component.ts @@ -26,7 +26,7 @@ import { ApiError, StateResource, createEmptyStateResource, - hasError, + hasStateResourceError, isServiceUnavailableMessageCode, } from '@alfa-client/tech-shared'; import { UserProfileResource } from '@alfa-client/user-profile-shared'; @@ -46,7 +46,7 @@ export class UserProfileInVorgangComponent { readonly vorgangLinkRel = VorgangWithEingangLinkRel; public isUserServiceAvailable(stateResource: StateResource<Resource>): boolean { - if (hasError(stateResource) && isServiceUnavailableMessageCode(<ApiError>stateResource.error)) { + if (hasStateResourceError(stateResource) && isServiceUnavailableMessageCode(<ApiError>stateResource.error)) { return false; } return true; 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 9048ea218b..504eb7692a 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 @@ -32,7 +32,7 @@ import { import { COMMAND_ERROR_MESSAGES, CommandErrorMessage, - hasError, + hasCommandError, isSuccessfulDone, } from '@alfa-client/command-shared'; import { AktenzeichenEditDialogMessages } from './aktenzeichen-edit-dialog.message'; @@ -41,7 +41,7 @@ import { AktenzeichenEditDialogFormservice } from './aktenzeichen-edit-dialog.fo jest.mock('@alfa-client/tech-shared'); const isClipboardReadSupportedMock = isClipboardReadSupported as jest.Mock; jest.mock('@alfa-client/command-shared'); -const hasErrorMock = hasError as jest.Mock; +const hasErrorMock = hasCommandError as jest.Mock; const isSuccessfulDoneMock = isSuccessfulDone as jest.Mock; const hasContentMock = hasContent as jest.Mock; const createEmptyStateResourceMock = createEmptyStateResource as jest.Mock; diff --git a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.ts b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.ts index 0ce392d569..d618bb16fb 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/aktenzeichen-edit-dialog/aktenzeichen-edit-dialog.component.ts @@ -1,7 +1,7 @@ import { COMMAND_ERROR_MESSAGES, CommandResource, - hasError, + hasCommandError, isSuccessfulDone, } from '@alfa-client/command-shared'; import { @@ -73,7 +73,7 @@ export class AktenzeichenEditDialogComponent implements OnInit { } onResponse(commandResource: CommandResource) { - if (commandResource && hasError(commandResource)) { + if (commandResource && hasCommandError(commandResource)) { this.showSnackbar(commandResource); } else if (isSuccessfulDone(commandResource)) { this.vorgangService.reloadCurrentVorgang(); @@ -82,7 +82,7 @@ export class AktenzeichenEditDialogComponent implements OnInit { } showSnackbar(commandResource: CommandResource): void { - if (hasError(commandResource)) { + if (hasCommandError(commandResource)) { this.snackBarService.showError(this.getErrorMessage(commandResource)); } } diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts index 2fc7831dfd..084a5361b9 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-result/vorgang-detail-bescheiden-result-attachments/vorgang-detail-bescheiden-result-attachments.component.ts @@ -4,7 +4,7 @@ import { StateResource, containsLoading, getSuccessfullyLoaded, - hasError, + hasStateResourceError, isLoaded, isNotNil, } from '@alfa-client/tech-shared'; @@ -65,7 +65,7 @@ export class VorgangDetailBescheidenResultAttachmentsComponent implements OnDest buildUploadedAttachments( uploadStateResource: StateResource<BinaryFileResource>, ): StateResource<BinaryFileResource>[] { - if (isLoaded(uploadStateResource) || hasError(uploadStateResource)) { + if (isLoaded(uploadStateResource) || hasStateResourceError(uploadStateResource)) { return [...getSuccessfullyLoaded(this.uploadedAttachments), uploadStateResource]; } else if (uploadStateResource.loading && !containsLoading(this.uploadedAttachments)) { return [...getSuccessfullyLoaded(this.uploadedAttachments), uploadStateResource]; diff --git a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-steps-content.component.ts b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-steps-content.component.ts index 8bb8b9b2cd..a05c072bc6 100644 --- a/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-steps-content.component.ts +++ b/alfa-client/libs/vorgang-detail/src/lib/vorgang-detail-page/vorgang-detail-bescheiden/vorgang-detail-bescheiden-steps/vorgang-detail-bescheiden-steps-content/vorgang-detail-bescheiden-steps-content.component.ts @@ -1,4 +1,4 @@ -import { HttpError, StateResource, hasError, isLoaded } from '@alfa-client/tech-shared'; +import { HttpError, StateResource, hasStateResourceError, isLoaded } from '@alfa-client/tech-shared'; import { VorgangService, VorgangWithEingangLinkRel, @@ -61,6 +61,6 @@ export class VorgangDetailBescheidenStepsContentComponent implements OnInit { } noError(stateResource: StateResource<Resource | HttpError>): boolean { - return isLoaded(stateResource) && !hasError(stateResource); + return isLoaded(stateResource) && !hasStateResourceError(stateResource); } } 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 a96d7ca4e7..c9633abfed 100644 --- a/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts +++ b/alfa-client/libs/wiedervorlage-shared/src/lib/wiedervorlage.service.ts @@ -37,7 +37,7 @@ import { createStateResource, decodeUrlFromEmbedding, doIfLoadingRequired, - hasError, + hasStateResourceError, isNotNull, isNotUndefined, replacePlaceholder, @@ -327,7 +327,7 @@ export class WiedervorlageService implements OnDestroy { this.submitInProgress$.next(createStateResource(commandStateResource.resource)); this.snackbarService.show(commandStateResource.resource, message); this.setWiedervorlageListReload(); - } else if (hasError(commandStateResource)) { + } else if (hasStateResourceError(commandStateResource)) { this.submitInProgress$.next(createStateResource(commandStateResource.resource)); } } -- GitLab