diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid.model.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid.model.ts index 6fee5ec006a52da9172c6491cc0bf38c4a0ba0df..24cbaccf50af06a9560638b4ea80884a05de7e07 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid.model.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid.model.ts @@ -118,3 +118,5 @@ export function createInitialWizard(): Wizard { bescheidCreated: false, }; } + +export const BESCHEID_UPLOADED_ATTACHMENTS: string = 'bescheid_uploaded_attachments'; \ No newline at end of file diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.spec.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.spec.ts index 977ca30abc3c3200416749391b488b397e75731c..9fbf45a5ca814d6ed15691e08259f1a664f836e0 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.spec.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.spec.ts @@ -24,7 +24,7 @@ import { BinaryFileListLinkRel, BinaryFileListResource, BinaryFileResource, BinaryFileService, } from '@alfa-client/binary-file-shared'; import { CommandOrder, CommandResource, CommandResourceService, CommandService, CreateCommandProps, getEffectedResourceUrl, } from '@alfa-client/command-shared'; import { PostfachService } from '@alfa-client/postfach-shared'; -import { createEmptyStateResource, createErrorStateResource, createLoadingStateResource, createStateResource, EMPTY_STRING, getEmbeddedResources, StateResource, } from '@alfa-client/tech-shared'; +import { createEmptyStateResource, createErrorStateResource, createStateResource, EMPTY_STRING, getEmbeddedResources, StateResource, } from '@alfa-client/tech-shared'; import { Mock, mock } from '@alfa-client/test-utils'; import { VorgangCommandService, VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { TestBed } from '@angular/core/testing'; @@ -39,12 +39,12 @@ import { createCommandErrorStateResource, createCommandResource, createCommandSt import { ResourceRepository } from '../../../tech-shared/src/lib/resource/resource.repository'; import { createFile } from '../../../tech-shared/test/file'; import { singleCold, singleColdCompleted } from '../../../tech-shared/test/marbles'; -import { createBescheid, createBescheidAttachments, createBescheidDocument, createBescheidResource } from '../test/bescheid'; +import { createBescheid, createBescheidDocument, createBescheidResource } from '../test/bescheid'; import { createDocumentResource } from '../test/document'; import { BescheidFacade } from './+state/bescheid.facade'; import { BescheidResourceService } from './bescheid-resource-service'; import { BescheidLinkRel } from './bescheid.linkrel'; -import { Bescheid, BescheidAttachments, BescheidDocument, BescheidResource, BescheidWizardStep, createEmptyBescheidAttachments, createEmptyBescheidDocument, createEmptyUploadInProgress, createInitialWizard, } from './bescheid.model'; +import { Bescheid, BESCHEID_UPLOADED_ATTACHMENTS, BescheidDocument, BescheidResource, BescheidWizardStep, createEmptyBescheidDocument, createEmptyUploadInProgress, createInitialWizard, } from './bescheid.model'; import { BescheidService2 } from './bescheid2.service'; import { DocumentLinkRel } from './document.linkrel'; import { DocumentResource } from './document.model'; @@ -115,16 +115,25 @@ describe('BescheidService', () => { expect(service.getActiveStep()).toBeObservable(singleCold(BescheidWizardStep.AntragBescheiden)); expect(service.getBescheidCreated()).toBeObservable(singleCold(false)); expect(service.getBescheidDocument()).toBeObservable(singleCold(createEmptyBescheidDocument())); - expect(service.getAttachments()).toBeObservable(singleCold(createEmptyBescheidAttachments())); }); }); describe('exit', () => { + beforeEach(() => { + service._clearUploadedFiles = jest.fn(); + }); + it('should reload postfach list', () => { service.exit(); expect(postfachService.setPostfachMailOnReload).toHaveBeenCalled(); }); + + it('should clear uploaded files', () => { + service.exit(); + + expect(service._clearUploadedFiles).toHaveBeenCalled(); + }); }); describe('skipBescheidCreation', () => { @@ -441,113 +450,16 @@ describe('BescheidService', () => { expect(binaryFileService.getFiles).not.toHaveBeenCalled(); }); - it('should emit attachments state', () => { + it('should add files', () => { const binaryFileListStateResource: StateResource<BinaryFileListResource> = createStateResource(createBinaryFileListResource()); binaryFileService.getFiles.mockReturnValue(of(binaryFileListStateResource)); - service.loadAttachments(bescheidResourceWithAttachments); - - expect(binaryFileService.getFiles).toHaveBeenCalledWith(bescheidResourceWithAttachments, BescheidLinkRel.ATTACHMENTS); - - expect(service.getAttachments()).toBeObservable( - singleCold({ - ...createEmptyBescheidAttachments(), - items: getEmbeddedResources(binaryFileListStateResource, BinaryFileListLinkRel.FILE_LIST), - }), - ); - }); - }); - - describe('uploadAttachment', () => { - const attachment: File = createFile(); - - beforeEach(() => { - binaryFileService.uploadFile.mockReturnValue(EMPTY); - service.handleAttachmentUpload = jest.fn(); - }); - - it('should emit upload loading', () => { - service.uploadAttachment(attachment, bescheidResource); - - expect(service.getAttachments()).toBeObservable( - singleCold({ - ...createEmptyBescheidAttachments(), - upload: { fileName: attachment.name, loading: true }, - uploadStateResource: createLoadingStateResource(), - } as BescheidAttachments), - ); - }); - - it('should call binary file service', () => { - service.uploadAttachment(attachment, bescheidResource); - - expect(binaryFileService.uploadFile).toHaveBeenCalledWith( - bescheidResource, - BescheidLinkRel.UPLOAD_ATTACHMENT, - attachment, - false, - ); - }); - - it('should handle attachment upload', () => { - const binaryFileStateResource: StateResource<BinaryFileResource> = createStateResource(createBinaryFileResource()); - binaryFileService.uploadFile.mockReturnValue(of(binaryFileStateResource)); - - service.uploadAttachment(attachment, bescheidResource); - expect(service.handleAttachmentUpload).toHaveBeenCalledWith(binaryFileStateResource); - }); - }); - - describe('handleAttachmentUpload', () => { - it('should emit state on success', () => { - const binaryFileStateResource: StateResource<BinaryFileResource> = createStateResource(createBinaryFileResource()); - - service.handleAttachmentUpload(binaryFileStateResource); - - expect(service.getAttachments()).toBeObservable( - singleCold({ - ...createEmptyBescheidAttachments(), - items: [binaryFileStateResource.resource], - uploadStateResource: binaryFileStateResource, - upload: { - ...createEmptyUploadInProgress(), - error: binaryFileStateResource.error, - loading: binaryFileStateResource.loading, - }, - } as BescheidAttachments), - ); - }); - - it('should emit state on error', () => { - const binaryFileStateResource: StateResource<BinaryFileResource> = createErrorStateResource(createProblemDetail()); - - service.handleAttachmentUpload(binaryFileStateResource); - - expect(service.getAttachments()).toBeObservable( - singleCold({ - ...createEmptyBescheidAttachments(), - items: [], - uploadStateResource: binaryFileStateResource, - upload: { - ...createEmptyUploadInProgress(), - error: binaryFileStateResource.error, - loading: binaryFileStateResource.loading, - }, - }), - ); - }); - }); - - describe('deleteAttachment', () => { - it('should delete', () => { - const binaryFileStateResource: StateResource<BinaryFileResource> = createStateResource(createBinaryFileResource()); - service.handleAttachmentUpload(binaryFileStateResource); - - service.deleteAttachment(binaryFileStateResource.resource); + service.loadAttachments(bescheidResourceWithAttachments); - expect(service.getAttachments()).toBeObservable( - singleCold({ ...createEmptyBescheidAttachments(), uploadStateResource: binaryFileStateResource } as BescheidAttachments), + expect(binaryFileService.addFiles).toHaveBeenCalledWith( + BESCHEID_UPLOADED_ATTACHMENTS, + getEmbeddedResources(binaryFileListStateResource, BinaryFileListLinkRel.FILE_LIST), ); }); }); @@ -885,11 +797,21 @@ describe('BescheidService', () => { }); describe('setActiveStep', () => { + beforeEach(() => { + service._clearUploadedFiles = jest.fn(); + }); + it('should emit changed active step', () => { service.setActiveStep(BescheidWizardStep.DokumenteHochladen); expect(service.getActiveStep()).toBeObservable(singleCold(BescheidWizardStep.DokumenteHochladen)); }); + + it('should clear uploaded files', () => { + service.setActiveStep(BescheidWizardStep.DokumenteHochladen); + + expect(service._clearUploadedFiles).toHaveBeenCalled(); + }); }); describe('getBescheidDraft', () => { @@ -939,23 +861,6 @@ describe('BescheidService', () => { }); }); - describe('finishAddingAttachments', () => { - it('should update state', () => { - const attachments: BescheidAttachments = createBescheidAttachments(); - service._attachments$.next(attachments); - - service.finishAddingAttachments(); - - expect(service.getAttachments()).toBeObservable( - singleCold({ - ...attachments, - upload: createEmptyUploadInProgress(), - uploadStateResource: createEmptyStateResource(), - } as BescheidAttachments), - ); - }); - }); - describe('finishAddingBescheidDocument', () => { it('should update state', () => { const bescheidDocument: BescheidDocument = createBescheidDocument(); @@ -972,4 +877,12 @@ describe('BescheidService', () => { ); }); }); + + describe('clear uploaded files', () => { + it('should call binary files service', () => { + service._clearUploadedFiles(); + + expect(binaryFileService.clearUploadedFiles).toHaveBeenCalledWith(BESCHEID_UPLOADED_ATTACHMENTS); + }); + }); }); diff --git a/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.ts b/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.ts index 3c5d8191390993f76b6456a8577d895b57dd6f55..8a48a4dbdf043a0994ac12c2a298a6ae2be2fb3e 100644 --- a/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.ts +++ b/alfa-client/libs/bescheid-shared/src/lib/bescheid2.service.ts @@ -1,6 +1,6 @@ import { Bescheid, - BescheidAttachments, + BESCHEID_UPLOADED_ATTACHMENTS, BescheidDocument, BescheidLinkRel, BescheidResource, @@ -11,7 +11,6 @@ import { buildCreateBescheidDocumentFromFileProps, buildSendBescheidCommandProps, buildUpdateBescheidCommandProps, - createEmptyBescheidAttachments, createEmptyBescheidDocument, createEmptyUploadInProgress, createInitialWizard, @@ -35,7 +34,6 @@ import { import { PostfachService } from '@alfa-client/postfach-shared'; import { createEmptyStateResource, - createLoadingStateResource, filterIsLoadedOrHasError, getEmbeddedResources, hasStateResourceError, @@ -63,17 +61,16 @@ export class BescheidService2 { private readonly bescheidResourceService = inject(BescheidResourceService); readonly _bescheidDocument$: BehaviorSubject<BescheidDocument> = new BehaviorSubject(createEmptyBescheidDocument()); - readonly _attachments$: BehaviorSubject<BescheidAttachments> = new BehaviorSubject(createEmptyBescheidAttachments()); readonly _wizard$: BehaviorSubject<Wizard> = new BehaviorSubject(createInitialWizard()); public init(): void { this._wizard$.next(createInitialWizard()); this._bescheidDocument$.next(createEmptyBescheidDocument()); - this._attachments$.next(createEmptyBescheidAttachments()); } public exit(): void { this.postfachService.setPostfachMailOnReload(); + this._clearUploadedFiles(); } public skipBescheidCreation( @@ -173,50 +170,10 @@ export class BescheidService2 { getEmbeddedResources<BinaryFileResource>(stateResource, BinaryFileListLinkRel.FILE_LIST), ), ) - .subscribe((files: BinaryFileResource[]) => this._attachments$.next({ ...this._attachments$.value, items: files })); + .subscribe((files: BinaryFileResource[]) => this.binaryFileService.addFiles(BESCHEID_UPLOADED_ATTACHMENTS, files)); } } - public uploadAttachment(attachment: File, bescheidResource: BescheidResource): void { - this._attachments$.next({ - ...this._attachments$.value, - upload: { fileName: attachment.name, loading: true }, - uploadStateResource: createLoadingStateResource(), - }); - this.binaryFileService - .uploadFile(bescheidResource, BescheidLinkRel.UPLOAD_ATTACHMENT, attachment, false) - .pipe(filterIsLoadedOrHasError(), first()) - .subscribe((binaryFileStateResource: StateResource<BinaryFileResource>) => - this.handleAttachmentUpload(binaryFileStateResource), - ); - } - - handleAttachmentUpload(binaryFileStateResource: StateResource<BinaryFileResource>) { - const value: BescheidAttachments = this._attachments$.value; - if (hasStateResourceError(binaryFileStateResource)) { - this._attachments$.next({ - ...value, - uploadStateResource: binaryFileStateResource, - upload: { ...value.upload, error: binaryFileStateResource.error, loading: binaryFileStateResource.loading }, - }); - } else { - this._attachments$.next({ - ...value, - uploadStateResource: binaryFileStateResource, - items: [...value.items, binaryFileStateResource.resource], - upload: { ...value.upload, error: binaryFileStateResource.error, loading: binaryFileStateResource.loading }, - }); - } - } - - public deleteAttachment(attachment: BinaryFileResource): void { - const value: BescheidAttachments = this._attachments$.value; - this._attachments$.next({ - ...value, - items: value.items.filter((each: BinaryFileResource) => getUrl(each) !== getUrl(attachment)), - }); - } - public uploadBescheidDocument(document: File, bescheid: BescheidResource): void { this._bescheidDocument$.next({ ...this._bescheidDocument$.value, upload: { fileName: document.name, loading: true } }); this.binaryFileService @@ -321,10 +278,6 @@ export class BescheidService2 { return this.bescheidResourceService.get(); } - public getAttachments(): Observable<BescheidAttachments> { - return this._attachments$.asObservable(); - } - public getBescheidDocument(): Observable<BescheidDocument> { return this._bescheidDocument$.asObservable(); } @@ -338,6 +291,7 @@ export class BescheidService2 { } public setActiveStep(step: BescheidWizardStep): void { + this._clearUploadedFiles(); this._wizard$.next({ ...this._wizard$.value, activeStep: step }); } @@ -369,14 +323,6 @@ export class BescheidService2 { this._wizard$.next({ ...this._wizard$.value, canBeSend: true }); } - public finishAddingAttachments(): void { - this._attachments$.next({ - ...this._attachments$.value, - upload: createEmptyUploadInProgress(), - uploadStateResource: createEmptyStateResource(), - }); - } - public finishAddingBescheidDocument(): void { this._bescheidDocument$.next({ ...this._bescheidDocument$.value, @@ -384,4 +330,8 @@ export class BescheidService2 { create: createEmptyStateResource(), }); } + + _clearUploadedFiles(): void { + this.binaryFileService.clearUploadedFiles(BESCHEID_UPLOADED_ATTACHMENTS); + } } diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.html deleted file mode 100644 index 622107cd6a88a6410e8c7bcdc7e08fd262f1635b..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.html +++ /dev/null @@ -1,21 +0,0 @@ -<ods-attachment-wrapper> - @for (attachment of attachments; track $index) { - <alfa-binary-file2-container - [file]="attachment" - [deletable]="deletable" - (startDelete)="delete.emit($event)" - [attr.data-test-id]="(attachment.name | convertForDataTest) + '-file2-container'" - > - </alfa-binary-file2-container> - } - @if (upload.loading || upload.error) { - <ods-attachment - [loadingCaption]="upload.fileName" - errorCaption="Fehler beim Hochladen" - [errorMessages]="upload.error | convertProblemDetailToErrorMessages" - description="Anhang wird hochgeladen" - [isLoading]="upload.loading" - data-test-id="attachment-upload-in-progress" - ></ods-attachment> - } -</ods-attachment-wrapper> diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.spec.ts deleted file mode 100644 index 92f027903e7ddb01410294bcced6f60759882b68..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.spec.ts +++ /dev/null @@ -1,165 +0,0 @@ -import { BescheidAttachments, createEmptyBescheidAttachments, createEmptyUploadInProgress } from '@alfa-client/bescheid-shared'; -import { BinaryFile2ContainerComponent } from '@alfa-client/binary-file'; -import { ConvertForDataTestPipe, ConvertProblemDetailToErrorMessagesPipe, ProblemDetail } from '@alfa-client/tech-shared'; -import { - existsAsHtmlElement, - getElementComponentFromFixtureByCss, - notExistsAsHtmlElement, - triggerEvent, -} from '@alfa-client/test-utils'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { AttachmentComponent, AttachmentWrapperComponent } from '@ods/system'; -import { MockComponent } from 'ng-mocks'; -import { createBescheidAttachments } from '../../../../../../../bescheid-shared/src/test/bescheid'; -import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test'; -import { createProblemDetail } from '../../../../../../../tech-shared/test/error'; -import { BescheidWizardAttachmentFilesComponent } from './bescheid-wizard-attachment-files.component'; - -describe('BescheidWizardAttachmentFileComponent', () => { - let component: BescheidWizardAttachmentFilesComponent; - let fixture: ComponentFixture<BescheidWizardAttachmentFilesComponent>; - - const convertForDataTest: ConvertForDataTestPipe = new ConvertForDataTestPipe(); - const convertProblemDetailsToErrorMessage: ConvertProblemDetailToErrorMessagesPipe = - new ConvertProblemDetailToErrorMessagesPipe(); - - const attachments: BescheidAttachments = createBescheidAttachments(); - - const binaryFileContainerTestId: string = getDataTestIdOf( - convertForDataTest.transform(attachments.items[0].name) + '-file2-container', - ); - const attachmentUploadTestId: string = getDataTestIdOf('attachment-upload-in-progress'); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ - BescheidWizardAttachmentFilesComponent, - MockComponent(BinaryFile2ContainerComponent), - MockComponent(AttachmentComponent), - MockComponent(AttachmentWrapperComponent), - ConvertForDataTestPipe, - ConvertProblemDetailToErrorMessagesPipe, - ], - }).compileComponents(); - - fixture = TestBed.createComponent(BescheidWizardAttachmentFilesComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - describe('component', () => { - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should set initial values', () => { - expect(component.upload).toEqual(createEmptyUploadInProgress()); - expect(component.attachments).toEqual(createEmptyBescheidAttachments().items); - }); - - describe('set attachments', () => { - it('should set attachments', () => { - component.attachments = attachments; - - expect(component.attachments).toEqual(attachments.items); - }); - - it('should set upload', () => { - component.attachments = attachments; - - expect(component.upload).toEqual(attachments.upload); - }); - }); - }); - - describe('template', () => { - describe('attachment binary file container', () => { - it('should exists', () => { - component.attachments = attachments; - - fixture.detectChanges(); - - existsAsHtmlElement(fixture, binaryFileContainerTestId); - }); - - it('should have been called with inputs', () => { - component.attachments = attachments; - - fixture.detectChanges(); - const binaryFileComponent: BinaryFile2ContainerComponent = - getElementComponentFromFixtureByCss<BinaryFile2ContainerComponent>(fixture, binaryFileContainerTestId); - - expect(binaryFileComponent.file).toEqual(attachments.items[0]); - expect(binaryFileComponent.deletable).toEqual(component.deletable); - }); - - describe('output', () => { - describe('startDelete', () => { - it('should emit', () => { - component.attachments = attachments; - component.delete.emit = jest.fn(); - - fixture.detectChanges(); - - triggerEvent({ - fixture, - elementSelector: binaryFileContainerTestId, - name: 'startDelete', - data: attachments.items[0], - }); - - expect(component.delete.emit).toHaveBeenCalledWith(attachments.items[0]); - }); - }); - }); - }); - - describe('upload attachment', () => { - it('should exists on loading', () => { - component.attachments = { ...attachments, upload: { ...attachments.upload, loading: true, error: null } }; - - fixture.detectChanges(); - - existsAsHtmlElement(fixture, attachmentUploadTestId); - }); - - it('should exists on error', () => { - component.attachments = { - ...attachments, - upload: { ...attachments.upload, loading: false, error: createProblemDetail() }, - }; - - fixture.detectChanges(); - - existsAsHtmlElement(fixture, attachmentUploadTestId); - }); - - it('should NOT exists', () => { - component.attachments = { - ...attachments, - upload: { ...attachments.upload, loading: false, error: null }, - }; - - fixture.detectChanges(); - - notExistsAsHtmlElement(fixture, attachmentUploadTestId); - }); - - it('should have been called with inputs', () => { - component.attachments = attachments; - - fixture.detectChanges(); - const attachmentComponent: AttachmentComponent = getElementComponentFromFixtureByCss<AttachmentComponent>( - fixture, - attachmentUploadTestId, - ); - - expect(attachmentComponent.loadingCaption).toEqual(attachments.upload.fileName); - expect(attachmentComponent.errorMessages).toEqual( - convertProblemDetailsToErrorMessage.transform(attachments.upload.error as ProblemDetail), - ); - expect(attachmentComponent.isLoading).toEqual(attachments.upload.loading); - }); - }); - }); -}); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.ts deleted file mode 100644 index b5a60cd795a7f6b7b918ce39a5fd5b45c1b3cb63..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - BescheidAttachments, - createEmptyBescheidAttachments, - createEmptyUploadInProgress, - UploadFileInProgress, -} from '@alfa-client/bescheid-shared'; -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { Component, EventEmitter, Input, Output } from '@angular/core'; - -@Component({ - selector: 'alfa-bescheid-wizard-attachment-files', - templateUrl: './bescheid-wizard-attachment-files.component.html', -}) -export class BescheidWizardAttachmentFilesComponent { - @Input() set attachments(value: BescheidAttachments) { - this._attachments = value; - this.upload = value.upload; - } - - get attachments(): BinaryFileResource[] { - return this._attachments.items; - } - - @Input() deletable: boolean; - - @Output() delete: EventEmitter<BinaryFileResource> = new EventEmitter(); - - public upload: UploadFileInProgress = createEmptyUploadInProgress(); - private _attachments: BescheidAttachments = createEmptyBescheidAttachments(); -} diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.html deleted file mode 100644 index c34bfce43f0959f56aa16e8a993f31b61bec0839..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.html +++ /dev/null @@ -1,6 +0,0 @@ -<alfa-bescheid-wizard-attachment-files - [attachments]="attachments$ | async" - [deletable]="(activeStep$ | async) === bescheidWizardStep.DokumenteHochladen" - (delete)="deleteAttachment($event)" - data-test-id="bescheid-attachments" -></alfa-bescheid-wizard-attachment-files> diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.spec.ts deleted file mode 100644 index 9c2cdd8df598bfddfb8b6fc3512066f44d58cc65..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.spec.ts +++ /dev/null @@ -1,123 +0,0 @@ -import { BescheidAttachments, BescheidWizardStep } from '@alfa-client/bescheid-shared'; -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { existsAsHtmlElement, getElementComponentFromFixtureByCss, mock, Mock, triggerEvent } from '@alfa-client/test-utils'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { MockComponent } from 'ng-mocks'; -import { of } from 'rxjs'; -import { BescheidService2 } from '../../../../../../bescheid-shared/src/lib/bescheid2.service'; -import { createBescheidAttachments } from '../../../../../../bescheid-shared/src/test/bescheid'; -import { createBinaryFileResource } from '../../../../../../binary-file-shared/test/binary-file'; -import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test'; -import { singleColdCompleted } from '../../../../../../tech-shared/test/marbles'; -import { BescheidWizardAttachmentFilesComponent } from './attachment-files/bescheid-wizard-attachment-files.component'; -import { BescheidWizardAttachmentFilesContainerComponent } from './bescheid-wizard-attachment-files-container.component'; - -describe('BescheidWizardAttachmentFileContainerComponent', () => { - let component: BescheidWizardAttachmentFilesContainerComponent; - let fixture: ComponentFixture<BescheidWizardAttachmentFilesContainerComponent>; - - const attachmentsFilesTestId: string = getDataTestIdOf('bescheid-attachments'); - - const attachments: BescheidAttachments = createBescheidAttachments(); - - let bescheidService: Mock<BescheidService2>; - - beforeEach(() => { - bescheidService = mock(BescheidService2); - }); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [BescheidWizardAttachmentFilesContainerComponent, MockComponent(BescheidWizardAttachmentFilesComponent)], - providers: [{ provide: BescheidService2, useValue: bescheidService }], - }).compileComponents(); - - fixture = TestBed.createComponent(BescheidWizardAttachmentFilesContainerComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - describe('component', () => { - it('should create', () => { - expect(component).toBeTruthy(); - }); - - describe('ngOnInit', () => { - it('should set attachments', () => { - bescheidService.getAttachments.mockReturnValue(of(attachments)); - - component.ngOnInit(); - - expect(component.attachments$).toBeObservable(singleColdCompleted(attachments)); - }); - - it('should set active step', () => { - bescheidService.getActiveStep.mockReturnValue(of(BescheidWizardStep.BescheidVersenden)); - - component.ngOnInit(); - - expect(component.activeStep$).toBeObservable(singleColdCompleted(BescheidWizardStep.BescheidVersenden)); - }); - }); - - describe('deleteAttachment', () => { - it('should call service', () => { - component.deleteAttachment = jest.fn(); - const binaryFileResource: BinaryFileResource = createBinaryFileResource(); - - component.deleteAttachment(binaryFileResource); - - expect(component.deleteAttachment).toHaveBeenCalledWith(binaryFileResource); - }); - }); - }); - - describe('template', () => { - describe('attachment files', () => { - function getComponent(): BescheidWizardAttachmentFilesComponent { - return getElementComponentFromFixtureByCss<BescheidWizardAttachmentFilesComponent>(fixture, attachmentsFilesTestId); - } - - it('should exists', () => { - existsAsHtmlElement(fixture, attachmentsFilesTestId); - }); - - it('should have been called with attachments', () => { - component.attachments$ = of(attachments); - - fixture.detectChanges(); - - expect(getComponent().attachments).toEqual(attachments); - }); - - it('should have been called with deletable true', () => { - component.activeStep$ = of(BescheidWizardStep.DokumenteHochladen); - - fixture.detectChanges(); - - expect(getComponent().deletable).toEqual(true); - }); - - it('should have been called with deletable false', () => { - component.activeStep$ = of(BescheidWizardStep.BescheidVersenden); - - fixture.detectChanges(); - - expect(getComponent().deletable).toEqual(false); - }); - - describe('output', () => { - describe('delete', () => { - it('should call handler', () => { - const binaryFileResource: BinaryFileResource = createBinaryFileResource(); - component.deleteAttachment = jest.fn(); - - triggerEvent({ fixture, elementSelector: attachmentsFilesTestId, name: 'delete', data: binaryFileResource }); - - expect(component.deleteAttachment).toHaveBeenCalledWith(binaryFileResource); - }); - }); - }); - }); - }); -}); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.ts deleted file mode 100644 index 50d2dea88ea12ba5fec926d895ff47044f017409..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BescheidAttachments, BescheidWizardStep } from '@alfa-client/bescheid-shared'; -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { Component, inject, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; -import { BescheidService2 } from '../../../../../../bescheid-shared/src/lib/bescheid2.service'; - -@Component({ - selector: 'alfa-bescheid-wizard-attachment-files-container', - templateUrl: './bescheid-wizard-attachment-files-container.component.html', -}) -export class BescheidWizardAttachmentFilesContainerComponent implements OnInit { - public readonly bescheidService = inject(BescheidService2); - - public attachments$: Observable<BescheidAttachments>; - public activeStep$: Observable<BescheidWizardStep>; - - public readonly bescheidWizardStep = BescheidWizardStep; - - ngOnInit(): void { - this.attachments$ = this.bescheidService.getAttachments(); - this.activeStep$ = this.bescheidService.getActiveStep(); - } - - public deleteAttachment(binaryFileResource: BinaryFileResource): void { - this.bescheidService.deleteAttachment(binaryFileResource); - } -} diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.html index 456fdbcb23a9cc1bca7ce775ccef70e8a544cf14..4f1ad6be37b4cce3aaca666cd2e5d41b3d25fbc9 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.html +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.html @@ -26,13 +26,20 @@ </ods-textarea-editor> </div> - <alfa-bescheid-wizard-dokumente-hochladen-summary - [isBescheidDocumentMissing]="false" - data-test-id="bescheid-versenden-dokumente" - ></alfa-bescheid-wizard-dokumente-hochladen-summary> + <alfa-bescheid-wizard-document-file-container data-test-id="bescheid-document-file"> + </alfa-bescheid-wizard-document-file-container> + @if (bescheidResource | hasLink: BescheidLinkRel.ATTACHMENTS) { + <alfa-binary-file-list-container + [resource]="bescheidResource" + [linkRel]="BescheidLinkRel.ATTACHMENTS" + [listOrientation]="BinaryFileListOrientation.VERTICAL" + data-test-id="bescheid-attachments" + ></alfa-binary-file-list-container> + } </div> + @if ( - (bescheidResource | hasLink: bescheidLinkRel.UPDATE) || (bescheidResource | hasLink: bescheidLinkRel.BESCHEIDEN_UND_SENDEN) + (bescheidResource | hasLink: BescheidLinkRel.UPDATE) || (bescheidResource | hasLink: BescheidLinkRel.BESCHEIDEN_UND_SENDEN) ) { <ods-button-with-spinner class="self-end" diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.spec.ts index e605449d8037e5d69d614a7a796060abb43a5c8f..3f2dd5b69457b1b28b56291e838c633fc17b120f 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.spec.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.spec.ts @@ -1,21 +1,12 @@ import { BescheidLinkRel, BescheidWizardDialogResult } from '@alfa-client/bescheid-shared'; -import { CommandResource } from '@alfa-client/command-shared'; +import { BinaryFileListContainerComponent } from '@alfa-client/binary-file'; import { createEmptyStateResource, createErrorStateResource, createLoadingStateResource, HasLinkPipe, - StateResource, } from '@alfa-client/tech-shared'; -import { - existsAsHtmlElement, - getElementComponentFromFixtureByCss, - mock, - Mock, - notExistsAsHtmlElement, - triggerEvent, - useFromMock, -} from '@alfa-client/test-utils'; +import { existsAsHtmlElement, mock, Mock, notExistsAsHtmlElement, useFromMock } from '@alfa-client/test-utils'; import { DialogRef } from '@angular/cdk/dialog'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; @@ -26,19 +17,18 @@ import { EMPTY, of } from 'rxjs'; import { BescheidService2 } from '../../../../../../../../bescheid-shared/src/lib/bescheid2.service'; import { createBescheidResource, createWizard } from '../../../../../../../../bescheid-shared/src/test/bescheid'; import { createSuccessfullyDoneCommandStateResource } from '../../../../../../../../command-shared/test/command'; -import { getDataTestIdAttributeOf, getDataTestIdOf } from '../../../../../../../../tech-shared/test/data-test'; +import { getDataTestIdOf } from '../../../../../../../../tech-shared/test/data-test'; import { createProblemDetail } from '../../../../../../../../tech-shared/test/error'; import { singleColdCompleted } from '../../../../../../../../tech-shared/test/marbles'; import { BescheidFormService } from '../../../../bescheid.formservice'; -import { BescheidWizardDokumenteHochladenSummaryComponent } from '../../../dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component'; +import { BescheidWizardDocumentFileContainerComponent } from '../../../document-file-container/bescheid-wizard-document-file-container.component'; import { BescheidWizardBescheidVersendenSendenComponent } from './bescheid-wizard-bescheid-versenden-senden.component'; describe('BescheidWizardBescheidVersendenSendenComponent', () => { let component: BescheidWizardBescheidVersendenSendenComponent; let fixture: ComponentFixture<BescheidWizardBescheidVersendenSendenComponent>; - const dokumenteTestsId: string = getDataTestIdOf('bescheid-versenden-dokumente'); - const submitButtonTestId: string = getDataTestIdAttributeOf('send-button'); + const attachmentsTestId: string = getDataTestIdOf('bescheid-attachments'); const empfaengerTestId: string = getDataTestIdOf('bescheid-nachricht-empfaenger'); let bescheidService: Mock<BescheidService2>; @@ -56,10 +46,11 @@ describe('BescheidWizardBescheidVersendenSendenComponent', () => { await TestBed.configureTestingModule({ declarations: [ BescheidWizardBescheidVersendenSendenComponent, - MockComponent(BescheidWizardDokumenteHochladenSummaryComponent), MockComponent(ButtonWithSpinnerComponent), MockComponent(TextareaEditorComponent), MockComponent(TextEditorComponent), + MockComponent(BinaryFileListContainerComponent), + MockComponent(BescheidWizardDocumentFileContainerComponent), HasLinkPipe, ReactiveFormsModule, ], @@ -246,68 +237,21 @@ describe('BescheidWizardBescheidVersendenSendenComponent', () => { }); }); - describe('dokumente hochladen summary', () => { + describe('attachment list', () => { it('should exists', () => { - existsAsHtmlElement(fixture, dokumenteTestsId); - }); + component.bescheidResource = createBescheidResource([BescheidLinkRel.ATTACHMENTS]); - it('should have inputs', () => { - const dokumentComponent: BescheidWizardDokumenteHochladenSummaryComponent = - getElementComponentFromFixtureByCss<BescheidWizardDokumenteHochladenSummaryComponent>(fixture, dokumenteTestsId); + fixture.detectChanges(); - expect(dokumentComponent.isBescheidDocumentMissing).toBe(false); + existsAsHtmlElement(fixture, attachmentsTestId); }); - describe('submit button', () => { - it('should exists with update link', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.UPDATE]); - - fixture.detectChanges(); - - existsAsHtmlElement(fixture, dokumenteTestsId); - }); - - it('should exists with bescheiden link', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN_UND_SENDEN]); - - fixture.detectChanges(); - - existsAsHtmlElement(fixture, dokumenteTestsId); - }); + it('should NOT exists', () => { + component.bescheidResource = createBescheidResource(); - it('should NOT exists on missing links', () => { - component.bescheidResource = createBescheidResource(); - - fixture.detectChanges(); - - notExistsAsHtmlElement(fixture, submitButtonTestId); - }); - - it('should have inputs', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN_UND_SENDEN]); - const submitCommandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource(); - component.submitStateResource$ = of(submitCommandStateResource); - - fixture.detectChanges(); - const submitButtonComponent: ButtonWithSpinnerComponent = - getElementComponentFromFixtureByCss<ButtonWithSpinnerComponent>(fixture, submitButtonTestId); - - expect(submitButtonComponent.stateResource).toEqual(submitCommandStateResource); - }); - - describe('output', () => { - describe('clickEmitter', () => { - it('should call handler', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN_UND_SENDEN]); - component.submit = jest.fn(); - fixture.detectChanges(); - - triggerEvent({ fixture, elementSelector: submitButtonTestId, name: 'clickEmitter' }); + fixture.detectChanges(); - expect(component.submit).toHaveBeenCalled(); - }); - }); - }); + notExistsAsHtmlElement(fixture, attachmentsTestId); }); }); }); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.ts index 5d03f994ed85918c979d7101e8d6b4ec14a59ee3..9f773a07f9008af8d653888cf198ed2a6b5ef11b 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/senden/bescheid-wizard-bescheid-versenden-senden.component.ts @@ -4,6 +4,7 @@ import { createEmptyStateResource, StateResource } from '@alfa-client/tech-share import { DialogRef } from '@angular/cdk/dialog'; import { Component, inject, Input } from '@angular/core'; import { Observable, of } from 'rxjs'; +import { BinaryFileListOrientation } from '../../../../../../../../binary-file/src/lib/directive/binary-file-list-orientation/binary-file-list-orientation.directive'; import { BescheidFormService } from '../../../../bescheid.formservice'; @Component({ @@ -22,8 +23,9 @@ export class BescheidWizardBescheidVersendenSendenComponent { public focusBetreff: boolean = false; public focusNachricht: boolean = false; - public readonly bescheidLinkRel = BescheidLinkRel; + public readonly BescheidLinkRel = BescheidLinkRel; public readonly formServiceClass = BescheidFormService; + public readonly BinaryFileListOrientation = BinaryFileListOrientation; public submit(): void { this._resetFocus(); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.html index 28a81da1c3c872131b56f1db53765a0608729194..7ab41e6c8a8e3b45c0f237d0de9eef96a4dfbd02 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.html +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.html @@ -1,14 +1,20 @@ <div class="flex h-full flex-col justify-between"> <div> <alfa-bescheid-wizard-antrag-bescheiden-summary></alfa-bescheid-wizard-antrag-bescheiden-summary> - <alfa-bescheid-wizard-dokumente-hochladen-summary - [isBescheidDocumentMissing]="false" - data-test-id="bescheid-versenden-dokumente" - ></alfa-bescheid-wizard-dokumente-hochladen-summary> + <alfa-bescheid-wizard-document-file-container data-test-id="bescheid-document-file"> + </alfa-bescheid-wizard-document-file-container> + @if (bescheidResource | hasLink: BescheidLinkRel.ATTACHMENTS) { + <alfa-binary-file-list-container + [resource]="bescheidResource" + [linkRel]="BescheidLinkRel.ATTACHMENTS" + [listOrientation]="BinaryFileListOrientation.VERTICAL" + data-test-id="bescheid-attachments" + ></alfa-binary-file-list-container> + } <p class="mb-8 text-base font-normal text-text">Der Bescheid muss manuell versendet werden.</p> </div> - @if ((bescheidResource | hasLink: bescheidLinkRel.UPDATE) || (bescheidResource | hasLink: bescheidLinkRel.BESCHEIDEN)) { + @if ((bescheidResource | hasLink: BescheidLinkRel.UPDATE) || (bescheidResource | hasLink: BescheidLinkRel.BESCHEIDEN)) { <ods-button-with-spinner class="self-end" [stateResource]="submitStateResource$ | async" diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.spec.ts index 40f0c44f14dc4e3e6c458f061f0c549cacd1763d..e73903700e781b9d36618c3a503f42395793fb21 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.spec.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.spec.ts @@ -1,4 +1,5 @@ import { BescheidLinkRel, BescheidWizardDialogResult } from '@alfa-client/bescheid-shared'; +import { BinaryFileListContainerComponent } from '@alfa-client/binary-file'; import { CommandResource } from '@alfa-client/command-shared'; import { createEmptyStateResource, @@ -28,14 +29,14 @@ import { createProblemDetail } from '../../../../../../../../tech-shared/test/er import { singleColdCompleted } from '../../../../../../../../tech-shared/test/marbles'; import { BescheidFormService } from '../../../../bescheid.formservice'; import { BescheidWizardAntragBescheidenSummaryComponent } from '../../../antrag-bescheiden/summary/bescheid-wizard-antrag-bescheiden-summary.component'; -import { BescheidWizardDokumenteHochladenSummaryComponent } from '../../../dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component'; +import { BescheidWizardDocumentFileContainerComponent } from '../../../document-file-container/bescheid-wizard-document-file-container.component'; import { BescheidWizardBescheidVersendenSpeichernComponent } from './bescheid-wizard-bescheid-versenden-speichern.component'; describe('BescheidWizardBescheidVersendenSpeichernComponent', () => { let component: BescheidWizardBescheidVersendenSpeichernComponent; let fixture: ComponentFixture<BescheidWizardBescheidVersendenSpeichernComponent>; - const dokumenteTestsId: string = getDataTestIdOf('bescheid-versenden-dokumente'); + const attachmentsTestId: string = getDataTestIdOf('bescheid-attachments'); const submitButtonTestId: string = getDataTestIdAttributeOf('confirm-and-save-button'); let formService: Mock<BescheidFormService>; @@ -52,7 +53,8 @@ describe('BescheidWizardBescheidVersendenSpeichernComponent', () => { declarations: [ BescheidWizardBescheidVersendenSpeichernComponent, MockComponent(BescheidWizardAntragBescheidenSummaryComponent), - MockComponent(BescheidWizardDokumenteHochladenSummaryComponent), + MockComponent(BinaryFileListContainerComponent), + MockComponent(BescheidWizardDocumentFileContainerComponent), MockComponent(ButtonWithSpinnerComponent), HasLinkPipe, ], @@ -118,66 +120,73 @@ describe('BescheidWizardBescheidVersendenSpeichernComponent', () => { }); describe('template', () => { - describe('dokumente hochladen summary', () => { + describe('attachment list', () => { it('should exists', () => { - existsAsHtmlElement(fixture, dokumenteTestsId); + component.bescheidResource = createBescheidResource([BescheidLinkRel.ATTACHMENTS]); + + fixture.detectChanges(); + + existsAsHtmlElement(fixture, attachmentsTestId); }); - it('should have inputs', () => { - const dokumentComponent: BescheidWizardDokumenteHochladenSummaryComponent = - getElementComponentFromFixtureByCss<BescheidWizardDokumenteHochladenSummaryComponent>(fixture, dokumenteTestsId); + it('should NOT exists', () => { + component.bescheidResource = createBescheidResource(); + + fixture.detectChanges(); - expect(dokumentComponent.isBescheidDocumentMissing).toBe(false); + notExistsAsHtmlElement(fixture, attachmentsTestId); }); + }); - describe('submit button', () => { - it('should exists with update link', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.UPDATE]); + describe('submit button', () => { + it('should exists with update link', () => { + component.bescheidResource = createBescheidResource([BescheidLinkRel.UPDATE]); - fixture.detectChanges(); + fixture.detectChanges(); - existsAsHtmlElement(fixture, dokumenteTestsId); - }); + existsAsHtmlElement(fixture, submitButtonTestId); + }); - it('should exists with bescheiden link', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); + it('should exists with bescheiden link', () => { + component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); - fixture.detectChanges(); + fixture.detectChanges(); - existsAsHtmlElement(fixture, dokumenteTestsId); - }); + existsAsHtmlElement(fixture, submitButtonTestId); + }); - it('should NOT exists on missing links', () => { - component.bescheidResource = createBescheidResource(); + it('should NOT exists on missing links', () => { + component.bescheidResource = createBescheidResource(); - fixture.detectChanges(); + fixture.detectChanges(); - notExistsAsHtmlElement(fixture, submitButtonTestId); - }); + notExistsAsHtmlElement(fixture, submitButtonTestId); + }); - it('should have inputs', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); - const submitCommandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource(); - component.submitStateResource$ = of(submitCommandStateResource); + it('should have inputs', () => { + component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); + const submitCommandStateResource: StateResource<CommandResource> = createSuccessfullyDoneCommandStateResource(); + component.submitStateResource$ = of(submitCommandStateResource); - fixture.detectChanges(); - const submitButtonComponent: ButtonWithSpinnerComponent = - getElementComponentFromFixtureByCss<ButtonWithSpinnerComponent>(fixture, submitButtonTestId); + fixture.detectChanges(); + const submitButtonComponent: ButtonWithSpinnerComponent = getElementComponentFromFixtureByCss<ButtonWithSpinnerComponent>( + fixture, + submitButtonTestId, + ); - expect(submitButtonComponent.stateResource).toEqual(submitCommandStateResource); - }); + expect(submitButtonComponent.stateResource).toEqual(submitCommandStateResource); + }); - describe('output', () => { - describe('clickEmitter', () => { - it('should call handler', () => { - component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); - component.submit = jest.fn(); - fixture.detectChanges(); + describe('output', () => { + describe('clickEmitter', () => { + it('should call handler', () => { + component.bescheidResource = createBescheidResource([BescheidLinkRel.BESCHEIDEN]); + component.submit = jest.fn(); + fixture.detectChanges(); - triggerEvent({ fixture, elementSelector: submitButtonTestId, name: 'clickEmitter' }); + triggerEvent({ fixture, elementSelector: submitButtonTestId, name: 'clickEmitter' }); - expect(component.submit).toHaveBeenCalled(); - }); + expect(component.submit).toHaveBeenCalled(); }); }); }); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.ts index f7ee9b36506b3b783c70df4e5238eb690a7bb0c2..4f6bf47fb09a2a4e3653fa43f32cacd95962aff4 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/speichern/bescheid-wizard-bescheid-versenden-speichern.component.ts @@ -4,6 +4,7 @@ import { createEmptyStateResource, StateResource } from '@alfa-client/tech-share import { DialogRef } from '@angular/cdk/dialog'; import { Component, inject, Input } from '@angular/core'; import { Observable, of } from 'rxjs'; +import { BinaryFileListOrientation } from '../../../../../../../../binary-file/src/lib/directive/binary-file-list-orientation/binary-file-list-orientation.directive'; import { BescheidFormService } from '../../../../bescheid.formservice'; @Component({ @@ -18,7 +19,8 @@ export class BescheidWizardBescheidVersendenSpeichernComponent { public submitStateResource$: Observable<StateResource<CommandResource>> = of(createEmptyStateResource<CommandResource>()); - public readonly bescheidLinkRel = BescheidLinkRel; + public readonly BinaryFileListOrientation = BinaryFileListOrientation; + public readonly BescheidLinkRel = BescheidLinkRel; public submit(): void { this.submitStateResource$ = this.formService diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.spec.ts index 749ab02b1417d171af7d7549c1c2994d4116fc04..26fb71e977b88813e501e3adcebe112e4077c3fb 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.spec.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.spec.ts @@ -112,12 +112,6 @@ describe('BescheidWizardDokumenteHochladenComponent', () => { }); describe('onWeiterClick', () => { - it('should finish adding attachments', () => { - component.onWeiterClick(); - - expect(bescheidService.finishAddingAttachments).toHaveBeenCalled(); - }); - it('should finish adding bescheid document', () => { component.onWeiterClick(); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.ts index eb90a6109b54253184476b5b3542bd31f0851d94..c15d92820a7e08b122ed18f729dc344adc8f8a58 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/bescheid-wizard-dokumente-hochladen-container.component.ts @@ -45,7 +45,6 @@ export class BescheidWizardDokumenteHochladenContainerComponent implements OnIni } public onWeiterClick(): void { - this.bescheidService.finishAddingAttachments(); this.bescheidService.finishAddingBescheidDocument(); this.bescheidService.setActiveStep(BescheidWizardStep.BescheidVersenden); } diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.html index b8c80fafbcec28185f7ff568c8b5357c197b1503..ecfcc883fa7680734dbf7dacb9c81fb197f6c5de 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.html +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.html @@ -34,6 +34,12 @@ </alfa-bescheid-wizard-document-file-container> </div> <div class="my-4"> - <alfa-bescheid-wizard-attachment-files-container data-test-id="bescheid-attachment-files"> - </alfa-bescheid-wizard-attachment-files-container> + <ods-file-upload-list-container + [parentFormArrayName]="BescheidFormService.FIELD_ATTACHMENTS" + [fileUploadType]="BESCHEID_UPLOADED_ATTACHMENTS" + [filesResource]="bescheidResource" + [filesLinkRel]="BescheidLinkRel.ATTACHMENTS" + [listOrientation]="BinaryFileListOrientation.VERTICAL" + data-test-id="bescheid-attachments" + ></ods-file-upload-list-container> </div> diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.spec.ts index 5ed6c9e5d11f1e5ebbe9fda0b395d70bc856c323..dd6eaf2ac287739ddbc00314a685b410f6740151 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.spec.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.spec.ts @@ -21,11 +21,11 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { FileUploadListContainerComponent } from '@alfa-client/binary-file'; import { existsAsHtmlElement, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test'; -import { BescheidWizardAttachmentFilesContainerComponent } from '../../attachment-files-container/bescheid-wizard-attachment-files-container.component'; import { BescheidWizardDocumentFileContainerComponent } from '../../document-file-container/bescheid-wizard-document-file-container.component'; import { BescheidWizardDokumenteHochladenSummaryComponent } from './bescheid-wizard-dokumente-hochladen-summary.component'; @@ -35,14 +35,14 @@ describe('BescheidWizardDokumenteHochladenSummaryComponent', () => { const missingBescheidErrorMessageTestId: string = getDataTestIdOf('missing-bescheid-document-error-message'); const documentFileTestId: string = getDataTestIdOf('bescheid-document-file'); - const attachmentFilesTestId: string = getDataTestIdOf('bescheid-attachment-files'); + const attachmentFilesTestId: string = getDataTestIdOf('bescheid-attachments'); beforeEach(async () => { await TestBed.configureTestingModule({ declarations: [ BescheidWizardDokumenteHochladenSummaryComponent, MockComponent(BescheidWizardDocumentFileContainerComponent), - MockComponent(BescheidWizardAttachmentFilesContainerComponent), + MockComponent(FileUploadListContainerComponent), ], }).compileComponents(); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.ts index 6bf136b2492c45205aa1fe115c3a033d92c1d174..7337d6cc572a2218be84e2c81b7c4da8f3109d86 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/dokumente-hochladen-container/summary/bescheid-wizard-dokumente-hochladen-summary.component.ts @@ -21,12 +21,21 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ +import { BESCHEID_UPLOADED_ATTACHMENTS, BescheidLinkRel, BescheidResource } from '@alfa-client/bescheid-shared'; import { Component, Input } from '@angular/core'; +import { BinaryFileListOrientation } from '../../../../../../../binary-file/src/lib/directive/binary-file-list-orientation/binary-file-list-orientation.directive'; +import { BescheidFormService } from '../../../bescheid.formservice'; @Component({ selector: 'alfa-bescheid-wizard-dokumente-hochladen-summary', templateUrl: './bescheid-wizard-dokumente-hochladen-summary.component.html', }) export class BescheidWizardDokumenteHochladenSummaryComponent { + @Input() bescheidResource: BescheidResource; @Input() isBescheidDocumentMissing: boolean; + + public readonly BESCHEID_UPLOADED_ATTACHMENTS = BESCHEID_UPLOADED_ATTACHMENTS; + public readonly BescheidLinkRel = BescheidLinkRel; + public readonly BescheidFormService = BescheidFormService; + public readonly BinaryFileListOrientation = BinaryFileListOrientation; } diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.html index 0442de58d2afd83f13f0adb7f928829302ffcea2..c81df29d6b8b5c614834ca40e8fd419ad24088cc 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.html +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.html @@ -1,5 +1,7 @@ -<alfa-bescheid-wizard-upload-attachment-button - [attachments]="attachments$ | async" - (uploadFile)="uploadFile($event)" +<ods-multi-file-upload-editor + label="Anhang hochladen" + [fileUploadType]="BESCHEID_UPLOADED_ATTACHMENTS" + [uploadResource]="bescheidResource" + [uploadLinkRelation]="BescheidLinkRel.UPLOAD_ATTACHMENT" data-test-id="upload-attachment-button" -></alfa-bescheid-wizard-upload-attachment-button> +></ods-multi-file-upload-editor> diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.spec.ts index 6035095eb818710798ad643934245f0ad1cf503f..4cbffd3fd1f894ec6b10e64f579b8021e6c86d72 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.spec.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.spec.ts @@ -1,37 +1,15 @@ -import { BescheidAttachments, BescheidResource } from '@alfa-client/bescheid-shared'; -import { getElementComponentFromFixtureByCss, Mock, mock, triggerEvent } from '@alfa-client/test-utils'; +import { MultiFileUploadEditorComponent } from '@alfa-client/binary-file'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { MockComponent } from 'ng-mocks'; -import { of } from 'rxjs'; -import { BescheidService2 } from '../../../../../../bescheid-shared/src/lib/bescheid2.service'; -import { createBescheidAttachments, createBescheidResource } from '../../../../../../bescheid-shared/src/test/bescheid'; -import { getDataTestIdOf } from '../../../../../../tech-shared/test/data-test'; -import { createFile } from '../../../../../../tech-shared/test/file'; -import { singleColdCompleted } from '../../../../../../tech-shared/test/marbles'; import { BescheidWizardUploadAttachmentButtonContainerComponent } from './bescheid-wizard-upload-attachment-button-container.component'; -import { BescheidWizardUploadAttachmentButtonComponent } from './upload-attachment-button/bescheid-wizard-upload-attachment-button.component'; describe('BescheidWizardUploadAttachmentButtonContainerComponent', () => { let component: BescheidWizardUploadAttachmentButtonContainerComponent; let fixture: ComponentFixture<BescheidWizardUploadAttachmentButtonContainerComponent>; - const uploadAttachmentButtonTestId: string = getDataTestIdOf('upload-attachment-button'); - - const bescheidAttachments: BescheidAttachments = createBescheidAttachments(); - - let bescheidService: Mock<BescheidService2>; - - beforeEach(() => { - bescheidService = mock(BescheidService2); - }); - beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - BescheidWizardUploadAttachmentButtonContainerComponent, - MockComponent(BescheidWizardUploadAttachmentButtonComponent), - ], - providers: [{ provide: BescheidService2, useValue: bescheidService }], + declarations: [BescheidWizardUploadAttachmentButtonContainerComponent, MockComponent(MultiFileUploadEditorComponent)], }).compileComponents(); createComponent(); @@ -43,59 +21,7 @@ describe('BescheidWizardUploadAttachmentButtonContainerComponent', () => { fixture.detectChanges(); } - describe('component', () => { - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should set initial values', () => { - bescheidService.getAttachments.mockReturnValue(of(bescheidAttachments)); - - createComponent(); - - expect(component.attachments$).toBeObservable(singleColdCompleted(bescheidAttachments)); - }); - - describe('uploadFile', () => { - it('should call bescheid service', () => { - const bescheidResource: BescheidResource = createBescheidResource(); - const file: File = createFile(); - component.bescheidResource = bescheidResource; - - component.uploadFile(file); - - expect(bescheidService.uploadAttachment).toHaveBeenCalledWith(file, bescheidResource); - }); - }); - }); - - describe('template', () => { - describe('upload attachment button', () => { - it('should have been called with inputs', () => { - bescheidService.getAttachments.mockReturnValue(of(bescheidAttachments)); - createComponent(); - - const uploadAttachmentButtonComponent: BescheidWizardUploadAttachmentButtonComponent = - getElementComponentFromFixtureByCss<BescheidWizardUploadAttachmentButtonComponent>( - fixture, - uploadAttachmentButtonTestId, - ); - - expect(uploadAttachmentButtonComponent.attachments).toEqual(bescheidAttachments); - }); - - describe('output', () => { - describe('uploadFile', () => { - it('should call handler', () => { - component.uploadFile = jest.fn(); - const file: File = createFile(); - - triggerEvent({ fixture, elementSelector: uploadAttachmentButtonTestId, name: 'uploadFile', data: file }); - - expect(component.uploadFile).toHaveBeenCalledWith(file); - }); - }); - }); - }); + it('should create', () => { + expect(component).toBeTruthy(); }); }); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.ts index 620adb8db26f04e7dc6b810c37c6acdef0c12d4e..527ce7e4280a9523aa396e918cac1436441f685e 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component.ts @@ -1,7 +1,5 @@ -import { BescheidAttachments, BescheidResource } from '@alfa-client/bescheid-shared'; -import { Component, inject, Input } from '@angular/core'; -import { Observable } from 'rxjs'; -import { BescheidService2 } from '../../../../../../bescheid-shared/src/lib/bescheid2.service'; +import { BESCHEID_UPLOADED_ATTACHMENTS, BescheidLinkRel, BescheidResource } from '@alfa-client/bescheid-shared'; +import { Component, Input } from '@angular/core'; @Component({ selector: 'alfa-bescheid-wizard-upload-attachment-button-container', @@ -10,11 +8,6 @@ import { BescheidService2 } from '../../../../../../bescheid-shared/src/lib/besc export class BescheidWizardUploadAttachmentButtonContainerComponent { @Input() bescheidResource: BescheidResource; - private readonly bescheidService = inject(BescheidService2); - - public readonly attachments$: Observable<BescheidAttachments> = this.bescheidService.getAttachments(); - - public uploadFile(file: File): void { - this.bescheidService.uploadAttachment(file, this.bescheidResource); - } + public readonly BESCHEID_UPLOADED_ATTACHMENTS = BESCHEID_UPLOADED_ATTACHMENTS; + public readonly BescheidLinkRel = BescheidLinkRel; } diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.html b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.html deleted file mode 100644 index daa2be54c067aee56f12918fc97895d4a9cfd87f..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.html +++ /dev/null @@ -1,11 +0,0 @@ -<div [formGroup]="formService.form"> - <ods-file-upload-editor - [parentFormArrayName]="formServiceClass.FIELD_ATTACHMENTS" - [uploadInProgress]="upload" - [fileLinkList]="fileUrls" - (newFile)="uploadFile.emit($event)" - label="Anhang hochladen" - data-test-id="bescheid-wizard-upload-editor" - > - </ods-file-upload-editor> -</div> diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.spec.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.spec.ts deleted file mode 100644 index 91693776e3fecd1def3f2f7ce3cde0c54acefa23..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.spec.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { createEmptyStateResource, createStateResource } from '@alfa-client/tech-shared'; -import { getElementComponentFromFixtureByCss, triggerEvent } from '@alfa-client/test-utils'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; -import { faker } from '@faker-js/faker'; -import { FileUploadEditorComponent } from '@ods/component'; -import { MockComponent } from 'ng-mocks'; -import { createBinaryFileResource } from '../../../../../../../binary-file-shared/test/binary-file'; -import { getDataTestIdOf } from '../../../../../../../tech-shared/test/data-test'; -import { createFile } from '../../../../../../../tech-shared/test/file'; -import { BescheidFormService } from '../../../bescheid.formservice'; -import { BescheidWizardUploadAttachmentButtonComponent } from './bescheid-wizard-upload-attachment-button.component'; - -describe('BescheidWizardUploadAttachmentButtonComponent', () => { - let component: BescheidWizardUploadAttachmentButtonComponent; - let fixture: ComponentFixture<BescheidWizardUploadAttachmentButtonComponent>; - - const uploadEditorTestId: string = getDataTestIdOf('bescheid-wizard-upload-editor'); - - let formService: BescheidFormService; - - beforeEach(() => { - formService = new BescheidFormService(new FormBuilder(), null); - }); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [BescheidWizardUploadAttachmentButtonComponent, MockComponent(FileUploadEditorComponent)], - providers: [{ provide: BescheidFormService, useValue: formService }], - imports: [ReactiveFormsModule], - }).compileComponents(); - - fixture = TestBed.createComponent(BescheidWizardUploadAttachmentButtonComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - describe('component', () => { - it('should create', () => { - expect(component).toBeTruthy(); - }); - - it('should set initial values', () => { - expect(component.upload).toEqual(createEmptyStateResource()); - expect(component.fileUrls).toEqual([]); - }); - }); - - describe('template', () => { - describe('upload editor', () => { - it('should have been called with inputs', () => { - component.upload = createStateResource(createBinaryFileResource()); - component.fileUrls = [faker.internet.url()]; - - fixture.detectChanges(); - const uploadEditorComponent: FileUploadEditorComponent = getElementComponentFromFixtureByCss<FileUploadEditorComponent>( - fixture, - uploadEditorTestId, - ); - - expect(uploadEditorComponent.parentFormArrayName).toEqual(BescheidFormService.FIELD_ATTACHMENTS); - expect(uploadEditorComponent.uploadInProgress).toEqual(component.upload); - expect(uploadEditorComponent.fileLinkList).toEqual(component.fileUrls); - }); - - describe('output', () => { - describe('newFile', () => { - it('should emit', () => { - component.uploadFile.emit = jest.fn(); - const file: File = createFile(); - - triggerEvent({ fixture, elementSelector: uploadEditorTestId, name: 'newFile', data: file }); - - expect(component.uploadFile.emit).toHaveBeenCalledWith(file); - }); - }); - }); - }); - }); -}); diff --git a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.ts b/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.ts deleted file mode 100644 index 0ec17648a4f94e19a0b6184e4a2cbb68f1b6edcd..0000000000000000000000000000000000000000 --- a/alfa-client/libs/bescheid/src/lib/bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component.ts +++ /dev/null @@ -1,32 +0,0 @@ -import { BescheidAttachments, createEmptyBescheidAttachments } from '@alfa-client/bescheid-shared'; -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; -import { Component, EventEmitter, inject, Input, Output } from '@angular/core'; -import { getUrl } from '@ngxp/rest'; -import { BescheidFormService } from '../../../bescheid.formservice'; - -@Component({ - selector: 'alfa-bescheid-wizard-upload-attachment-button', - templateUrl: './bescheid-wizard-upload-attachment-button.component.html', -}) -export class BescheidWizardUploadAttachmentButtonComponent { - @Input() set attachments(value: BescheidAttachments) { - this.updateAttachments(value); - } - - @Output() uploadFile: EventEmitter<File> = new EventEmitter<File>(); - - public readonly formService: BescheidFormService = inject(BescheidFormService); - - public fileUrls: string[] = []; - public upload: StateResource<BinaryFileResource> = createEmptyStateResource(); - private _attachments: BescheidAttachments = createEmptyBescheidAttachments(); - - public readonly formServiceClass = BescheidFormService; - - updateAttachments(value: BescheidAttachments) { - this._attachments = value; - this.upload = value.uploadStateResource; - this.fileUrls = this._attachments.items.map((binaryFileResource: BinaryFileResource) => getUrl(binaryFileResource)); - } -} diff --git a/alfa-client/libs/bescheid/src/lib/bescheid.module.ts b/alfa-client/libs/bescheid/src/lib/bescheid.module.ts index e4e7092380ee0cdc7f9e1c206af6e03863b13b0c..f098c06d4ec7b163b55a8bad5f60c7682521866c 100644 --- a/alfa-client/libs/bescheid/src/lib/bescheid.module.ts +++ b/alfa-client/libs/bescheid/src/lib/bescheid.module.ts @@ -22,24 +22,12 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { BescheidSharedModule } from '@alfa-client/bescheid-shared'; -import { BinaryFileModule } from '@alfa-client/binary-file'; +import { BinaryFileModule, FileUploadListContainerComponent, MultiFileUploadEditorComponent } from '@alfa-client/binary-file'; import { CommandSharedModule } from '@alfa-client/command-shared'; -import { - ConvertForDataTestPipe, - ConvertProblemDetailToErrorMessagesPipe, - GetUrlPipe, - HasLinkPipe, - ToEmbeddedResourcesPipe, -} from '@alfa-client/tech-shared'; +import { ConvertForDataTestPipe, ConvertProblemDetailToErrorMessagesPipe, GetUrlPipe, HasLinkPipe, ToEmbeddedResourcesPipe, } from '@alfa-client/tech-shared'; import { CommonModule } from '@angular/common'; import { NgModule } from '@angular/core'; -import { - ButtonWithSpinnerComponent, - FileUploadEditorComponent, - SingleFileUploadEditorComponent, - TextareaEditorComponent, - TextEditorComponent, -} from '@ods/component'; +import { ButtonWithSpinnerComponent, FileUploadEditorComponent, SingleFileUploadEditorComponent, TextareaEditorComponent, TextEditorComponent, } from '@ods/component'; import { BescheidInVorgangContainerComponent } from './bescheid-in-vorgang-container/bescheid-in-vorgang-container.component'; import { BescheidInVorgangComponent } from './bescheid-in-vorgang-container/bescheid-in-vorgang/bescheid-in-vorgang.component'; import { BescheidListInVorgangContainerComponent } from './bescheid-list-in-vorgang-container/bescheid-list-in-vorgang-container.component'; @@ -48,31 +36,10 @@ import { DocumentInBescheidContainerComponent } from './bescheid-list-in-vorgang import { BeschiedenDateContainerComponent } from './beschieden-date-in-vorgang-container/beschieden-date-container/beschieden-date-container.component'; import { BeschiedenDateInVorgangContainerComponent } from './beschieden-date-in-vorgang-container/beschieden-date-in-vorgang-container.component'; -import { - DateEditorComponent, - ExpansionPanelComponent, - OzgcloudStrokedButtonWithSpinnerComponent, - SpinnerComponent, -} from '@alfa-client/ui'; +import { DateEditorComponent, ExpansionPanelComponent, OzgcloudStrokedButtonWithSpinnerComponent, SpinnerComponent, } from '@alfa-client/ui'; import { ReactiveFormsModule } from '@angular/forms'; import { MatIcon } from '@angular/material/icon'; -import { - AttachmentComponent, - AttachmentWrapperComponent, - BescheidGenerateIconComponent, - BescheidStatusTextComponent, - BescheidUploadIconComponent, - BescheidWrapperComponent, - ButtonCardComponent, - ButtonComponent, - CheckIconComponent, - CloseIconComponent, - RadioButtonCardComponent, - SaveIconComponent, - SendIconComponent, - SpinnerIconComponent, - StampIconComponent, -} from '@ods/system'; +import { AttachmentComponent, AttachmentWrapperComponent, BescheidGenerateIconComponent, BescheidStatusTextComponent, BescheidUploadIconComponent, BescheidWrapperComponent, ButtonCardComponent, ButtonComponent, CheckIconComponent, CloseIconComponent, RadioButtonCardComponent, SaveIconComponent, SendIconComponent, SpinnerIconComponent, StampIconComponent, } from '@ods/system'; import { FormatFullDatePipe } from '../../../tech-shared/src/lib/pipe/format-full-date.pipe'; import { BescheidWizardContainerComponent } from './bescheid-wizard-container/bescheid-wizard-container.component'; import { BescheidWizardAbschliessenButtonComponent } from './bescheid-wizard-container/bescheid-wizard/antrag-bescheiden/abschliessen-button/bescheid-wizard-abschliessen-button.component'; @@ -80,8 +47,6 @@ import { BescheidWizardAbschliessenDialogContainerComponent } from './bescheid-w import { BescheidWizardAntragBescheidenContainerComponent } from './bescheid-wizard-container/bescheid-wizard/antrag-bescheiden/bescheid-wizard-antrag-bescheiden-container.component'; import { BescheidWizardAntragBescheidenFormComponent } from './bescheid-wizard-container/bescheid-wizard/antrag-bescheiden/form/bescheid-wizard-antrag-bescheiden-form.component'; import { BescheidWizardAntragBescheidenSummaryComponent } from './bescheid-wizard-container/bescheid-wizard/antrag-bescheiden/summary/bescheid-wizard-antrag-bescheiden-summary.component'; -import { BescheidWizardAttachmentFilesComponent } from './bescheid-wizard-container/bescheid-wizard/attachment-files-container/attachment-files/bescheid-wizard-attachment-files.component'; -import { BescheidWizardAttachmentFilesContainerComponent } from './bescheid-wizard-container/bescheid-wizard/attachment-files-container/bescheid-wizard-attachment-files-container.component'; import { BescheidWizardBescheidVersendenContainerComponent } from './bescheid-wizard-container/bescheid-wizard/bescheid-versenden/bescheid-wizard-bescheid-versenden-container.component'; import { BescheidWizardBescheidVersendenFormComponent } from './bescheid-wizard-container/bescheid-wizard/bescheid-versenden/form/bescheid-wizard-bescheid-versenden-form.component'; import { BescheidWizardBescheidVersendenSummaryComponent } from './bescheid-wizard-container/bescheid-wizard/bescheid-versenden/summary/bescheid-wizard-bescheid-versenden-summary.component'; @@ -102,7 +67,6 @@ import { BescheidWizardStepperComponent } from './bescheid-wizard-container/besc import { BescheidWizardStepComponent } from './bescheid-wizard-container/bescheid-wizard/stepper/step/bescheid-wizard-step.component'; import { BescheidWizardSummaryComponent } from './bescheid-wizard-container/bescheid-wizard/summary/bescheid-wizard-summary.component'; import { BescheidWizardUploadAttachmentButtonContainerComponent } from './bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/bescheid-wizard-upload-attachment-button-container.component'; -import { BescheidWizardUploadAttachmentButtonComponent } from './bescheid-wizard-container/bescheid-wizard/upload-attachment-button-container/upload-attachment-button/bescheid-wizard-upload-attachment-button.component'; import { BescheidWizardUploadDocumentButtonContainerComponent } from './bescheid-wizard-container/bescheid-wizard/upload-document-button-container/bescheid-wizard-upload-document-button-container.component'; import { BescheidWizardUploadDocumentButtonComponent } from './bescheid-wizard-container/bescheid-wizard/upload-document-button-container/upload-document-button/bescheid-wizard-upload-document-button.component'; import { BescheidWizardWeiterButtonComponent } from './bescheid-wizard-container/bescheid-wizard/weiter-button/bescheid-wizard-weiter-button.component'; @@ -146,6 +110,8 @@ import { BescheidWizardWeiterButtonComponent } from './bescheid-wizard-container TextareaEditorComponent, ConvertForDataTestPipe, ConvertProblemDetailToErrorMessagesPipe, + FileUploadListContainerComponent, + MultiFileUploadEditorComponent, ], declarations: [ BescheidInVorgangContainerComponent, @@ -179,9 +145,6 @@ import { BescheidWizardWeiterButtonComponent } from './bescheid-wizard-container BescheidWizardDocumentFileContainerComponent, BescheidWizardDocumentFileComponent, BescheidWizardUploadAttachmentButtonContainerComponent, - BescheidWizardUploadAttachmentButtonComponent, - BescheidWizardAttachmentFilesContainerComponent, - BescheidWizardAttachmentFilesComponent, BescheidWizardBescheidVersendenContainerComponent, BescheidWizardBescheidVersendenFormComponent, BescheidWizardBescheidVersendenSummaryComponent,