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

OZG-5167: add utitlty function

parent 2bfa4181
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
CommandResourceService, CommandResourceService,
CommandService, CommandService,
getEffectedResourceUrl, getEffectedResourceUrl,
hasCommandError, notHasCommandError,
tapOnCommandSuccessfullyDone, tapOnCommandSuccessfullyDone,
} from '@alfa-client/command-shared'; } from '@alfa-client/command-shared';
import { import {
...@@ -430,7 +430,7 @@ export class BescheidService { ...@@ -430,7 +430,7 @@ export class BescheidService {
commandStateResource: StateResource<CommandResource>, commandStateResource: StateResource<CommandResource>,
): void { ): void {
this.createBescheidDocumentInProgress$.next(commandStateResource); this.createBescheidDocumentInProgress$.next(commandStateResource);
if (!hasCommandError(commandStateResource.resource)) { if (notHasCommandError(commandStateResource.resource)) {
const documentUri: ResourceUri = getEffectedResourceUrl(commandStateResource.resource); const documentUri: ResourceUri = getEffectedResourceUrl(commandStateResource.resource);
this.bescheidDocumentUri$.next(documentUri); this.bescheidDocumentUri$.next(documentUri);
this.loadBescheidDocumentByUri(documentUri); this.loadBescheidDocumentByUri(documentUri);
......
...@@ -21,23 +21,11 @@ ...@@ -21,23 +21,11 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { import { createCommandErrorResource, createCommandListResource, createCommandResource, } from 'libs/command-shared/test/command';
createCommandErrorResource,
createCommandListResource,
createCommandResource,
} from 'libs/command-shared/test/command';
import { CommandLinkRel } from './command.linkrel'; import { CommandLinkRel } from './command.linkrel';
import { CommandErrorMessage } from './command.message'; import { CommandErrorMessage } from './command.message';
import { CommandListResource, CommandResource } from './command.model'; import { CommandListResource, CommandResource } from './command.model';
import { import { getPendingCommandByOrder, hasCommandError, isConcurrentModification, isDone, isPending, isRevokeable, isSuccessfulDone, notHasCommandError, } from './command.util';
getPendingCommandByOrder,
hasCommandError,
isConcurrentModification,
isDone,
isPending,
isRevokeable,
isSuccessfulDone,
} from './command.util';
describe('CommandUtil', () => { describe('CommandUtil', () => {
describe('isRevokeable', () => { describe('isRevokeable', () => {
...@@ -172,4 +160,18 @@ describe('CommandUtil', () => { ...@@ -172,4 +160,18 @@ describe('CommandUtil', () => {
expect(isDoneSuccessfuly).toBeFalsy(); expect(isDoneSuccessfuly).toBeFalsy();
}); });
}); });
describe('notHasCommandError', () => {
it('should return true', () => {
const hasError: boolean = notHasCommandError(createCommandResource());
expect(hasError).toBeTruthy();
});
it('should return false', () => {
const hasError: boolean = notHasCommandError(createCommandErrorResource());
expect(hasError).toBeFalsy();
});
});
}); });
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* Die sprachspezifischen Genehmigungen und Beschränkungen * Die sprachspezifischen Genehmigungen und Beschränkungen
* unter der Lizenz sind dem Lizenztext zu entnehmen. * unter der Lizenz sind dem Lizenztext zu entnehmen.
*/ */
import { ResourceUri, getEmbeddedResource, getUrl, hasLink } from '@ngxp/rest'; import { getEmbeddedResource, getUrl, hasLink, ResourceUri } from '@ngxp/rest';
import { isEmpty, isNil, isObject } from 'lodash-es'; import { isEmpty, isNil, isObject } from 'lodash-es';
import { CommandLinkRel, CommandListLinkRel } from './command.linkrel'; import { CommandLinkRel, CommandListLinkRel } from './command.linkrel';
import { CommandErrorMessage } from './command.message'; import { CommandErrorMessage } from './command.message';
...@@ -47,6 +47,10 @@ export function hasCommandError(commandResource: CommandResource): boolean { ...@@ -47,6 +47,10 @@ export function hasCommandError(commandResource: CommandResource): boolean {
return hasErrorMessage(commandResource) && !isPending(commandResource); return hasErrorMessage(commandResource) && !isPending(commandResource);
} }
export function notHasCommandError(commandResource: CommandResource): boolean {
return !hasCommandError(commandResource);
}
export function getPendingCommandByOrder( export function getPendingCommandByOrder(
pendingCommands: CommandListResource, pendingCommands: CommandListResource,
commandOrder: any[], commandOrder: any[],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment