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

OZG-5796: handle error state resource for uploaded attachment

parent 512b4505
Branches
No related tags found
No related merge requests found
...@@ -315,6 +315,17 @@ describe('VorgangDetailBescheidenResultAttachmentsComponent', () => { ...@@ -315,6 +315,17 @@ describe('VorgangDetailBescheidenResultAttachmentsComponent', () => {
expect(component.uploadedAttachments).toEqual([]); expect(component.uploadedAttachments).toEqual([]);
}); });
it('should leave errors in uploaded', () => {
const error: StateResource<BinaryFileResource> = createStateResource(
createBinaryFileResource(),
);
component.uploadedAttachments = [error];
component.deleteFile(uploadedAttachmentStateResource.resource);
expect(component.uploadedAttachments).toEqual([error]);
});
it('should not delete attachment from existing', () => { it('should not delete attachment from existing', () => {
component.uploadedAttachments = [uploadedAttachmentStateResource]; component.uploadedAttachments = [uploadedAttachmentStateResource];
component.existingAttachments = [existingAttachment]; component.existingAttachments = [existingAttachment];
......
import { BescheidService, UploadFileInProgress } from '@alfa-client/bescheid-shared'; import { BescheidService, UploadFileInProgress } from '@alfa-client/bescheid-shared';
import { BinaryFileResource } from '@alfa-client/binary-file-shared'; import { BinaryFileResource } from '@alfa-client/binary-file-shared';
import { import {
StateResource,
containsLoading, containsLoading,
getSuccessfullyLoaded, getSuccessfullyLoaded,
hasStateResourceError, hasStateResourceError,
isLoaded, isLoaded,
isNotNil, isNotNil,
StateResource,
} from '@alfa-client/tech-shared'; } from '@alfa-client/tech-shared';
import { Component, Input, OnDestroy, OnInit } from '@angular/core'; import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { getUrl } from '@ngxp/rest'; import { getUrl } from '@ngxp/rest';
import { Observable, Subscription, first } from 'rxjs'; import { first, Observable, Subscription } from 'rxjs';
import { BescheidenFormService } from '../../bescheiden.formservice'; import { BescheidenFormService } from '../../bescheiden.formservice';
@Component({ @Component({
...@@ -76,10 +76,11 @@ export class VorgangDetailBescheidenResultAttachmentsComponent implements OnDest ...@@ -76,10 +76,11 @@ export class VorgangDetailBescheidenResultAttachmentsComponent implements OnDest
deleteFile(file: BinaryFileResource): void { deleteFile(file: BinaryFileResource): void {
this.formService.deleteFile(file); this.formService.deleteFile(file);
this.uploadedAttachments = this.uploadedAttachments.filter( this.uploadedAttachments = this.uploadedAttachments.filter(
(attachment) => getUrl(attachment.resource) !== getUrl(file), (attachment: StateResource<BinaryFileResource>) =>
!hasStateResourceError(attachment) && getUrl(attachment.resource) !== getUrl(file),
); );
this.existingAttachments = this.existingAttachments.filter( this.existingAttachments = this.existingAttachments.filter(
(attachment) => getUrl(attachment) !== getUrl(file), (attachment: BinaryFileResource) => getUrl(attachment) !== getUrl(file),
); );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment