diff --git a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/postfach-mail/postfach-mail.cy.ts b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/postfach-mail/postfach-mail.cy.ts index 83ccb2b2cac8628bf8755dacc14c81a9acd7d65a..044306b1063a79e993a306928e4a1bf7d9cbf827 100644 --- a/alfa-client/apps/alfa-e2e/src/e2e/main-tests/postfach-mail/postfach-mail.cy.ts +++ b/alfa-client/apps/alfa-e2e/src/e2e/main-tests/postfach-mail/postfach-mail.cy.ts @@ -22,61 +22,27 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { faker } from '@faker-js/faker'; -import { - AttachmentContainerE2EComponent, - AttachmentListE2EComponent, -} from 'apps/alfa-e2e/src/components/attachment/attachment.e2e.component'; +import { AttachmentContainerE2EComponent, AttachmentListE2EComponent, } from 'apps/alfa-e2e/src/components/attachment/attachment.e2e.component'; import { BinaryFileSnackbarMessageE2E } from 'apps/alfa-e2e/src/model/binary-file'; import { PostfachMailFormularE2EComponent } from '../../../components/postfach/postfach-mail-formular.e2e.component'; -import { - PostfachMailE2EComponent, - PostfachMailListItem, -} from '../../../components/postfach/postfach-mail.e2e.component'; +import { PostfachMailE2EComponent, PostfachMailListItem } from '../../../components/postfach/postfach-mail.e2e.component'; import { FixedDialogE2EComponent } from '../../../components/ui/fixed-dialog.e2e.component'; import { SnackBarE2EComponent } from '../../../components/ui/snackbar.e2e.component'; import { VorgangListE2EComponent } from '../../../components/vorgang/vorgang-list.e2e.component'; import { VorgangSubnavigationE2EComponent } from '../../../components/vorgang/vorgang-subnavigation'; import { ClientAttributeNameE2E, ClientAttributesE2E, VorgangE2E } from '../../../model/vorgang'; -import { - PostfachMailItemE2E, - PostfachNachrichtSnackbarMessageE2E, - VorgangAttachedItemClientE2E, - VorgangAttachedItemE2E, -} from '../../../model/vorgang-attached-item'; +import { PostfachMailItemE2E, PostfachNachrichtSnackbarMessageE2E, VorgangAttachedItemClientE2E, VorgangAttachedItemE2E, } from '../../../model/vorgang-attached-item'; import { MainPage, waitForSpinnerToDisappear } from '../../../page-objects/main.po'; import { PostfachMailPage } from '../../../page-objects/postfach-mail.component.po'; import { VorgangPage } from '../../../page-objects/vorgang.po'; import { expectIconWithBadge, expectIconWithoutBadge } from '../../../support/angular.util'; import { dropCollections, readFileFromDownloads } from '../../../support/cypress-helper'; -import { - beChecked, - contains, - exist, - notBeChecked, - notBeVisible, - notExist, - visible, -} from '../../../support/cypress.util'; -import { - TEST_FILE_WITHOUT_CONTENT, - TEST_FILE_WITH_CONTENT, - TEST_FILE_WITH_CONTENT_4_MB, -} from '../../../support/data.util'; +import { beChecked, contains, exist, notBeChecked, notBeVisible, notExist, visible } from '../../../support/cypress.util'; +import { TEST_FILE_WITH_CONTENT, TEST_FILE_WITH_CONTENT_4_MB, TEST_FILE_WITHOUT_CONTENT } from '../../../support/data.util'; import { uploadEmptyFile, uploadFile } from '../../../support/file-upload'; import { initUsermanagerUsers, loginAsSabine } from '../../../support/user-util'; -import { - createPostfachNachrichtAttachedItem, - createPostfachNachrichtReplyItem, - initVorgangAttachedItem, -} from '../../../support/vorgang-attached-item-util'; -import { - buildVorgang, - createHasNewPostfachNachrichtClientAttribute, - createHasPostfachNachrichtClientAttribute, - createVorgang, - initVorgaenge, - objectIds, -} from '../../../support/vorgang-util'; +import { createPostfachNachrichtAttachedItem, createPostfachNachrichtReplyItem, initVorgangAttachedItem, } from '../../../support/vorgang-attached-item-util'; +import { buildVorgang, createHasNewPostfachNachrichtClientAttribute, createHasPostfachNachrichtClientAttribute, createVorgang, initVorgaenge, objectIds, } from '../../../support/vorgang-util'; describe('PostfachMail', () => { const mainPage: MainPage = new MainPage(); @@ -87,20 +53,16 @@ describe('PostfachMail', () => { const postfachMailContainer: PostfachMailE2EComponent = vorgangPage.getPostfachMailcontainer(); const subnavigation: VorgangSubnavigationE2EComponent = vorgangPage.getSubnavigation(); const fixedDialog: FixedDialogE2EComponent = vorgangPage.getFixedDialog(); - const postfachMailFormular: PostfachMailFormularE2EComponent = - vorgangPage.getPostfachMailFormular(); - const attachmentContainer: AttachmentContainerE2EComponent = - postfachMailFormular.getAttachmentContainer(); + const postfachMailFormular: PostfachMailFormularE2EComponent = vorgangPage.getPostfachMailFormular(); + const attachmentContainer: AttachmentContainerE2EComponent = postfachMailFormular.getAttachmentContainer(); const attachmentList: AttachmentListE2EComponent = attachmentContainer.getList(); const postfachMailPage: PostfachMailPage = new PostfachMailPage(); const clientAttributes: ClientAttributesE2E = { [VorgangAttachedItemClientE2E.OZGCLOUD_NACHRICHTEN_MANAGER]: { - [ClientAttributeNameE2E.HAS_NEW_POSTFACH_NACHRICHT]: - createHasNewPostfachNachrichtClientAttribute(true), - [ClientAttributeNameE2E.HAS_POSTFACH_NACHRICHT]: - createHasPostfachNachrichtClientAttribute(true), + [ClientAttributeNameE2E.HAS_NEW_POSTFACH_NACHRICHT]: createHasNewPostfachNachrichtClientAttribute(true), + [ClientAttributeNameE2E.HAS_POSTFACH_NACHRICHT]: createHasPostfachNachrichtClientAttribute(true), }, }; @@ -149,9 +111,7 @@ describe('PostfachMail', () => { describe('mail icon with badge', () => { it('should be visible and have a badge', () => { - const postfachStatusIcon: HTMLElement = vorgangList - .getListItem(vorgangWithReply.name) - .getPostfachIconMatIcon(); + const postfachStatusIcon: HTMLElement = vorgangList.getListItem(vorgangWithReply.name).getPostfachIconMatIcon(); expectIconWithBadge(postfachStatusIcon); }); }); @@ -273,10 +233,7 @@ describe('PostfachMail', () => { }); it('should show attachment with content after uploading it', () => { - uploadFile( - postfachMailFormular.getAttachmentContainer().getUploadInput(), - TEST_FILE_WITH_CONTENT, - ); + uploadFile(postfachMailFormular.getAttachmentContainer().getUploadInput(), TEST_FILE_WITH_CONTENT); waitForSpinnerToDisappear(); exist(attachmentList.getItem(TEST_FILE_WITH_CONTENT).getRoot()); @@ -305,26 +262,16 @@ describe('PostfachMail', () => { }); describe('attach file > 3 MB', () => { - it('should show error snackbar', () => { - uploadFile( - postfachMailFormular.getAttachmentContainer().getUploadInput(), - TEST_FILE_WITH_CONTENT_4_MB, - ); + it('should show failed upload', () => { + uploadFile(postfachMailFormular.getAttachmentContainer().getUploadInput(), TEST_FILE_WITH_CONTENT_4_MB); waitForSpinnerToDisappear(); - exist(snackbar.getMessage()); + exist(attachmentList.getLoadingOrErrorItem(TEST_FILE_WITH_CONTENT_4_MB).getRoot()); contains( - snackbar.getMessage(), + attachmentList.getLoadingOrErrorItem(TEST_FILE_WITH_CONTENT_4_MB).getRoot(), BinaryFileSnackbarMessageE2E.ATTACHMENT_NOT_ADDED.replace('{size}', '3MB'), ); }); - - it('should close snackbar on close button', () => { - snackbar.getCloseButton().click(); - - notExist(snackbar.getCloseButton()); - notExist(snackbar.getMessage()); - }); }); describe('reply option button', () => { @@ -356,9 +303,7 @@ describe('PostfachMail', () => { }); it('should show postfach mail in list', () => { - const postfachMailItem: PostfachMailListItem = postfachMailContainer.getListItem( - postfachMailToSend.subject, - ); + const postfachMailItem: PostfachMailListItem = postfachMailContainer.getListItem(postfachMailToSend.subject); exist(postfachMailItem.getRoot()); exist(postfachMailItem.getUserProfile().getRoot()); @@ -370,9 +315,7 @@ describe('PostfachMail', () => { describe('click on postfach mail item with attachment', () => { it('should show postfach item list', () => { - const postfachMailItem: PostfachMailListItem = postfachMailContainer.getListItem( - postfachMailToSend.subject, - ); + const postfachMailItem: PostfachMailListItem = postfachMailContainer.getListItem(postfachMailToSend.subject); postfachMailItem.getRoot().click(); waitForSpinnerToDisappear(); @@ -380,34 +323,27 @@ describe('PostfachMail', () => { }); it('should contain mail item with attachment', () => { - const postfachListItem: PostfachMailListItem = postfachMailPage.getListItem( - postfachMailToSend.subject, - ); + const postfachListItem: PostfachMailListItem = postfachMailPage.getListItem(postfachMailToSend.subject); - exist( - postfachListItem - .getAttachmentContainer() - .getList() - .getItem(TEST_FILE_WITH_CONTENT) - .getRoot(), - ); + exist(postfachListItem.getAttachmentContainer().getList().getItem(TEST_FILE_WITH_CONTENT).getRoot()); }); it('should download attachment after click', () => { - const postfachListItem: PostfachMailListItem = postfachMailPage.getListItem( - postfachMailToSend.subject, - ); + const postfachListItem: PostfachMailListItem = postfachMailPage.getListItem(postfachMailToSend.subject); - postfachListItem - .getAttachmentContainer() - .getList() - .getItem(TEST_FILE_WITH_CONTENT) - .getDownloadButton() - .click(); + postfachListItem.getAttachmentContainer().getList().getItem(TEST_FILE_WITH_CONTENT).getDownloadButton().click(); waitForSpinnerToDisappear(); exist(readFileFromDownloads(TEST_FILE_WITHOUT_CONTENT)); }); + + it('should not contain failed upload', () => { + const postfachListItem: PostfachMailListItem = postfachMailPage.getListItem(postfachMailToSend.subject); + + notExist( + postfachListItem.getAttachmentContainer().getList().getLoadingOrErrorItem(TEST_FILE_WITH_CONTENT_4_MB).getRoot(), + ); + }); }); describe('click on back button', () => { @@ -451,10 +387,7 @@ describe('PostfachMail', () => { }); it('should show text for no postfach attached', () => { - contains( - postfachMailContainer.getNoPostfachText(), - 'Dieser Vorgang ist nicht mit einem Postfach verknüpft.', - ); + contains(postfachMailContainer.getNoPostfachText(), 'Dieser Vorgang ist nicht mit einem Postfach verknüpft.'); }); it('should navigate back to list', () => { @@ -498,10 +431,7 @@ describe('PostfachMail', () => { }); it('should show text', () => { - contains( - postfachMailContainer.getListItem(postfachMailReply.subject).getText(), - postfachMailReply.mailBody, - ); + contains(postfachMailContainer.getListItem(postfachMailReply.subject).getText(), postfachMailReply.mailBody); }); }); @@ -566,9 +496,7 @@ describe('PostfachMail', () => { }); it('should be visible and not have a badge', () => { - const postfachStatusIcon: HTMLElement = vorgangList - .getListItem(vorgangWithReply.name) - .getPostfachIconMatIcon(); + const postfachStatusIcon: HTMLElement = vorgangList.getListItem(vorgangWithReply.name).getPostfachIconMatIcon(); expectIconWithoutBadge(postfachStatusIcon); }); }); diff --git a/alfa-client/libs/admin/postfach-shared/src/lib/postfach.model.ts b/alfa-client/libs/admin/postfach-shared/src/lib/postfach.model.ts index e3ce2fb8bd6153796bea9bf82422718d2324721e..89072ed299d081cfe531c40579b4de859a3e41f1 100644 --- a/alfa-client/libs/admin/postfach-shared/src/lib/postfach.model.ts +++ b/alfa-client/libs/admin/postfach-shared/src/lib/postfach.model.ts @@ -37,3 +37,5 @@ export interface Postfach { } export declare type PostfachResource = SettingItemResource<Postfach>; + +export const POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS: string = 'POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS'; diff --git a/alfa-client/libs/binary-file/src/index.ts b/alfa-client/libs/binary-file/src/index.ts index 0797fec271485748cb2070218373df404cf2f29b..4b274b2c74e7e1542d6f68309e12d91a6ab4a7e2 100644 --- a/alfa-client/libs/binary-file/src/index.ts +++ b/alfa-client/libs/binary-file/src/index.ts @@ -27,6 +27,7 @@ export * from './lib/binary-file-list-container/binary-file-list-container.compo export * from './lib/binary-file-uri-container/binary-file-uri-container.component'; export * from './lib/binary-file.module'; export * from './lib/binary-file2-container/binary-file2-container.component'; +export * from './lib/directive/binary-file-list-orientation/binary-file-list-orientation.directive'; export * from './lib/file-upload-list-container/file-upload-list-container.component'; export * from './lib/horizontal-binary-file-list/horizontal-binary-file-list.component'; export * from './lib/multi-file-upload-editor/multi-file-upload-editor.component'; diff --git a/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts b/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts index f26deaae319cf2f62a1dc3c0aebce901dff4709d..678219f735fd5882a763a535687688c630bd5045 100644 --- a/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts +++ b/alfa-client/libs/postfach-shared/src/lib/postfach.service.spec.ts @@ -21,40 +21,21 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { - BinaryFileListResource, - BinaryFileResource, - BinaryFileService, -} from '@alfa-client/binary-file-shared'; +import { BinaryFileService } from '@alfa-client/binary-file-shared'; import { CommandResource, CommandService } from '@alfa-client/command-shared'; import { NavigationService } from '@alfa-client/navigation-shared'; -import { - StateResource, - createEmptyStateResource, - createStateResource, -} from '@alfa-client/tech-shared'; -import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; +import { createEmptyStateResource, createStateResource, StateResource } from '@alfa-client/tech-shared'; +import { Mock, mock } from '@alfa-client/test-utils'; import { SnackBarService } from '@alfa-client/ui'; import { VorgangService, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { TestBed } from '@angular/core/testing'; import { MatDialog } from '@angular/material/dialog'; -import { - createBinaryFileListResource, - createBinaryFileResource, -} from 'libs/binary-file-shared/test/binary-file'; +import { expect } from '@jest/globals'; import { CommandLinkRel } from 'libs/command-shared/src/lib/command.linkrel'; -import { - createCommandErrorResource, - createCommandResource, -} from 'libs/command-shared/test/command'; +import { createCommandErrorResource, createCommandResource } from 'libs/command-shared/test/command'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { BehaviorSubject, of } from 'rxjs'; -import { - createPostfachFeatures, - createPostfachMail, - createPostfachMailListResource, - createPostfachMailResource, - createPostfachSettings, -} from '../../test/postfach'; +import { createPostfachFeatures, createPostfachMail, createPostfachMailListResource, createPostfachMailResource, createPostfachSettings, } from '../../test/postfach'; import { PostfachFacade } from './+state/postfach.facade'; import { PostfachMailLinkRel, PostfachMailListLinkRel } from './postfach.linkrel'; import { PostfachMessages } from './postfach.message'; @@ -72,8 +53,8 @@ describe('PostfachService', () => { const vorgangService: Mock<VorgangService> = mock(VorgangService); const snackbarService: Mock<SnackBarService> = mock(SnackBarService); const dialog: Mock<MatDialog> = <Mock<MatDialog>>{ closeAll: jest.fn() }; - const binaryFileService: Mock<BinaryFileService> = mock(BinaryFileService); const postfachFacade: Mock<PostfachFacade> = mock(PostfachFacade); + const binaryFileService: Mock<BinaryFileService> = mock(BinaryFileService); const urlChangedParams = {}; @@ -83,16 +64,21 @@ describe('PostfachService', () => { repository = mock(PostfachRepository); - service = new PostfachService( - useFromMock(repository), - useFromMock(commandService), - useFromMock(navigationService), - useFromMock(vorgangService), - useFromMock(snackbarService), - useFromMock(dialog), - useFromMock(binaryFileService), - useFromMock(postfachFacade), - ); + TestBed.configureTestingModule({ + providers: [ + { provide: CommandService, useValue: commandService }, + { provide: NavigationService, useValue: navigationService }, + { provide: VorgangService, useValue: vorgangService }, + { provide: SnackBarService, useValue: snackbarService }, + { provide: MatDialog, useValue: dialog }, + { provide: PostfachFacade, useValue: postfachFacade }, + { provide: BinaryFileService, useValue: binaryFileService }, + { provide: PostfachRepository, useValue: repository }, + PostfachService, + ], + }); + + service = TestBed.inject(PostfachService); }); it('should be created', () => { @@ -101,8 +87,7 @@ describe('PostfachService', () => { describe('send message', () => { const postfachMail: PostfachMail = createPostfachMail(); - const commandStateResource: StateResource<CommandResource> = - createStateResource(createCommandResource()); + const commandStateResource: StateResource<CommandResource> = createStateResource(createCommandResource()); beforeEach(() => { commandService.createCommand.mockReturnValue(of(commandStateResource)); @@ -144,9 +129,7 @@ describe('PostfachService', () => { }); it('should not execute on pending command', () => { - commandService.createCommand.mockReturnValue( - of(createStateResource(createCommandResource([CommandLinkRel.UPDATE]))), - ); + commandService.createCommand.mockReturnValue(of(createStateResource(createCommandResource([CommandLinkRel.UPDATE])))); service.sendMail(postfachMail); @@ -159,8 +142,7 @@ describe('PostfachService', () => { const postfachNachricht: PostfachMailResource = createPostfachMailResource(); const nachricht: PostfachMail = createPostfachMail(); - const commandStateResource: StateResource<CommandResource> = - createStateResource(createCommandResource()); + const commandStateResource: StateResource<CommandResource> = createStateResource(createCommandResource()); it('should call doSendNachricht', () => { service.doSendNachricht = jest.fn(); @@ -183,12 +165,8 @@ describe('PostfachService', () => { beforeEach(() => { service.handleSendPostfachMailIsDone = jest.fn(); - commandService.createCommand.mockReturnValue( - of(createStateResource(createCommandResource())), - ); - vorgangService.getPendingSendPostfachMailCommand.mockReturnValue( - of(createStateResource(createCommandResource())), - ); + commandService.createCommand.mockReturnValue(of(createStateResource(createCommandResource()))); + vorgangService.getPendingSendPostfachMailCommand.mockReturnValue(of(createStateResource(createCommandResource()))); }); it('should call vorgang service and set command on loading', () => { @@ -210,9 +188,7 @@ describe('PostfachService', () => { }); it('should NOT call handleSendPostfachMailIsDone if command is pending', () => { - commandService.createCommand.mockReturnValue( - of(createStateResource(createCommandResource([CommandLinkRel.UPDATE]))), - ); + commandService.createCommand.mockReturnValue(of(createStateResource(createCommandResource([CommandLinkRel.UPDATE])))); service.resendMail(postfachMailResource); expect(service.handleSendPostfachMailIsDone).not.toHaveBeenCalled(); @@ -231,8 +207,7 @@ describe('PostfachService', () => { }); describe('handleSendNachrichtCommand', () => { - const commandStateResource: StateResource<CommandResource> = - createStateResource(createCommandResource()); + const commandStateResource: StateResource<CommandResource> = createStateResource(createCommandResource()); beforeEach(() => { service.commandIsDone = jest.fn(); @@ -241,9 +216,7 @@ describe('PostfachService', () => { it('should call vorgang service', () => { service.handleSendNachrichtCommand(commandStateResource); - expect(vorgangService.setPendingSendPostfachMailCommand).toHaveBeenCalledWith( - commandStateResource, - ); + expect(vorgangService.setPendingSendPostfachMailCommand).toHaveBeenCalledWith(commandStateResource); }); it('should call commandIsDone', () => { @@ -277,10 +250,7 @@ describe('PostfachService', () => { service.commandIsDone(commandStateResource); - expect(snackbarService.show).toHaveBeenCalledWith( - commandStateResource.resource, - PostfachMessages.SEND_SUCCESSFUL, - ); + expect(snackbarService.show).toHaveBeenCalledWith(commandStateResource.resource, PostfachMessages.SEND_SUCCESSFUL); }); }); @@ -392,9 +362,7 @@ describe('PostfachService', () => { service.pollSendPostfachMailCommand = jest.fn(); commandService.pollCommand.mockReturnValue(of(createStateResource(createCommandResource()))); - vorgangService.getPendingSendPostfachMailCommand.mockReturnValue( - of(createStateResource(createCommandResource())), - ); + vorgangService.getPendingSendPostfachMailCommand.mockReturnValue(of(createStateResource(createCommandResource()))); }); it('should call navigation service', () => { @@ -405,15 +373,12 @@ describe('PostfachService', () => { }); describe('resetHasNewPostfachNachrichten', () => { - const postfachListNachrichtenResource: PostfachMailListResource = - createPostfachMailListResource(); + const postfachListNachrichtenResource: PostfachMailListResource = createPostfachMailListResource(); it('should call doResetHasNewPostfachNachrichten', () => { service.getPostfachMailListByVorgang = jest.fn(); service.doResetHasNewPostfachNachrichten = jest.fn(); - (<any>service.getPostfachMailListByVorgang).mockReturnValue( - of(postfachListNachrichtenResource), - ); + (<any>service.getPostfachMailListByVorgang).mockReturnValue(of(postfachListNachrichtenResource)); service.resetHasNewPostfachNachrichten(); @@ -423,28 +388,24 @@ describe('PostfachService', () => { describe('doResetHasNewPostfachNachrichten', () => { describe('on existing link', () => { - const postfachNachrichtenListResource: PostfachMailListResource = - createPostfachMailListResource([PostfachMailListLinkRel.RESET_HAS_NEW_POSTFACH_NACHRICHT]); + const postfachNachrichtenListResource: PostfachMailListResource = createPostfachMailListResource([ + PostfachMailListLinkRel.RESET_HAS_NEW_POSTFACH_NACHRICHT, + ]); beforeEach(() => { service.postfachMailList$.next(createStateResource(postfachNachrichtenListResource)); - repository.resetHasNewPostfachNachrichten.mockReturnValue( - of(postfachNachrichtenListResource), - ); + repository.resetHasNewPostfachNachrichten.mockReturnValue(of(postfachNachrichtenListResource)); }); it('should call repository if link exists', () => { service.doResetHasNewPostfachNachrichten(); - expect(repository.resetHasNewPostfachNachrichten).toHaveBeenCalledWith( - postfachNachrichtenListResource, - ); + expect(repository.resetHasNewPostfachNachrichten).toHaveBeenCalledWith(postfachNachrichtenListResource); }); }); it('should NOT call repository if link not exists', () => { - const postfachNachrichtenListResource: PostfachMailListResource = - createPostfachMailListResource(); + const postfachNachrichtenListResource: PostfachMailListResource = createPostfachMailListResource(); service.postfachMailList$.next(createStateResource(postfachNachrichtenListResource)); service.doResetHasNewPostfachNachrichten(); @@ -460,9 +421,7 @@ describe('PostfachService', () => { repository.loadPostfachMailList.mockReturnValue(of(postfachMailList)); service.setPostfachMailListLoading = jest.fn(); service.setPostfachMailList = jest.fn(); - vorgangService.getVorgangWithEingang.mockReturnValue( - of(createStateResource(createVorgangWithEingangResource())), - ); + vorgangService.getVorgangWithEingang.mockReturnValue(of(createStateResource(createVorgangWithEingangResource()))); service.postfachMailList$.next(createEmptyStateResource()); }); @@ -492,8 +451,7 @@ describe('PostfachService', () => { }); describe('handleSendPostfachMailIsDone', () => { - const stateResource: StateResource<CommandResource> = - createStateResource(createCommandResource()); + const stateResource: StateResource<CommandResource> = createStateResource(createCommandResource()); beforeEach(() => { service.setPollingFalse = jest.fn(); @@ -521,26 +479,6 @@ describe('PostfachService', () => { }); }); - describe('loadAttachments', () => { - const postfachNachricht: PostfachMailResource = createPostfachMailResource(); - const fileListStateResource: StateResource<BinaryFileListResource> = createStateResource( - createBinaryFileListResource(), - ); - - beforeEach(() => { - binaryFileService.getFiles.mockReturnValue(of(fileListStateResource)); - }); - - it('should call binaryFile service with resource', () => { - service.loadAttachments(postfachNachricht); - - expect(binaryFileService.getFiles).toHaveBeenCalledWith( - postfachNachricht, - PostfachMailLinkRel.ATTACHMENTS, - ); - }); - }); - describe('isDownloadPdfInProgress', () => { const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource(); @@ -582,54 +520,9 @@ describe('PostfachService', () => { }); }); - describe('getAttachments', () => { - const postfachNachricht: PostfachMailResource = createPostfachMailResource(); - const binaryFileResource: BinaryFileResource = createBinaryFileResource(); - const BinaryFileListResource: BinaryFileListResource = createBinaryFileListResource([ - binaryFileResource, - ]); - - beforeEach(() => { - postfachFacade.getAttachmentList.mockReturnValue( - of(createStateResource(BinaryFileListResource)), - ); - }); - - it('should get attachments', () => { - service.getAttachments(postfachNachricht); - - expect(postfachFacade.getAttachmentList).toHaveBeenCalled(); - }); - - it('should load attachments if loading is required', () => { - postfachFacade.getAttachmentList.mockReturnValue(of(createEmptyStateResource())); - - service.getAttachments(postfachNachricht).subscribe(); - - expect(postfachFacade.loadAttachmentList).toHaveBeenCalledWith(postfachNachricht); - }); - - it('should return value', (done) => { - service.getAttachments(postfachNachricht).subscribe((attachments: BinaryFileResource[]) => { - expect(attachments).toEqual([binaryFileResource]); - done(); - }); - }); - }); - - describe('clearAttachmentList', () => { - it('should call facade', () => { - service.clearAttachmentList(); - - expect(postfachFacade.clearAttachmentList).toHaveBeenCalled(); - }); - }); - describe('getFeatures', () => { it('should return features by list stateResource', (done) => { - service.postfachMailList$ = new BehaviorSubject( - createStateResource(createPostfachMailListResource()), - ); + service.postfachMailList$ = new BehaviorSubject(createStateResource(createPostfachMailListResource())); service.getFeatures().subscribe((features) => { expect(features).toEqual(createPostfachFeatures()); @@ -640,9 +533,7 @@ describe('PostfachService', () => { describe('getSettings', () => { it('should return settings by list stateResource', (done) => { - service.postfachMailList$ = new BehaviorSubject( - createStateResource(createPostfachMailListResource()), - ); + service.postfachMailList$ = new BehaviorSubject(createStateResource(createPostfachMailListResource())); service.getSettings().subscribe((settings) => { expect(settings).toEqual(createPostfachSettings()); @@ -650,4 +541,16 @@ describe('PostfachService', () => { }); }); }); + + describe('close open dialogs', () => { + beforeEach(() => { + service.clearUploadedFiles = jest.fn(); + }); + + it('should clear uploaded files', () => { + service.closeOpenDialogs(); + + expect(service.clearUploadedFiles).toHaveBeenCalled(); + }); + }); }); diff --git a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts index 189ab9a2059f0941773bc7754a8929799889bf30..e39019766d5f873a246643dec3c951cc4e2efd39 100644 --- a/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts +++ b/alfa-client/libs/postfach-shared/src/lib/postfach.service.ts @@ -21,55 +21,38 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { - BinaryFileListLinkRel, - BinaryFileListResource, - BinaryFileResource, - BinaryFileService, -} from '@alfa-client/binary-file-shared'; -import { - CommandResource, - CommandService, - doIfCommandIsDone, - hasCommandError, - isDone, - isPending, -} from '@alfa-client/command-shared'; +import { POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS } from '@admin-client/postfach-shared'; +import { BinaryFileService } from '@alfa-client/binary-file-shared'; +import { CommandResource, CommandService, doIfCommandIsDone, hasCommandError, isDone, isPending, } from '@alfa-client/command-shared'; import { NavigationService } from '@alfa-client/navigation-shared'; -import { - StateResource, - createEmptyStateResource, - createStateResource, - doIfLoadingRequired, - getEmbeddedResources, - isNotNull, - isNotUndefined, -} from '@alfa-client/tech-shared'; +import { createEmptyStateResource, createStateResource, doIfLoadingRequired, isNotNull, isNotUndefined, StateResource, } from '@alfa-client/tech-shared'; import { SnackBarService } from '@alfa-client/ui'; import { VorgangResource, VorgangService } from '@alfa-client/vorgang-shared'; -import { Injectable } from '@angular/core'; +import { inject, Injectable } from '@angular/core'; import { MatDialog } from '@angular/material/dialog'; import { Params } from '@angular/router'; -import { Resource, hasLink } from '@ngxp/rest'; +import { hasLink, Resource } from '@ngxp/rest'; import { isNil, isNull } from 'lodash-es'; -import { BehaviorSubject, Observable, Subscription, combineLatest } from 'rxjs'; +import { BehaviorSubject, combineLatest, Observable, Subscription } from 'rxjs'; import { first, map, take, tap } from 'rxjs/operators'; import { PostfachFacade } from './+state/postfach.facade'; import { PostfachMailLinkRel, PostfachMailListLinkRel } from './postfach.linkrel'; import { PostfachMessages } from './postfach.message'; -import { - CreatePostfachMailCommand, - PostfachFeatures, - PostfachMail, - PostfachMailListResource, - PostfachMailResource, - PostfachSettings, -} from './postfach.model'; +import { CreatePostfachMailCommand, PostfachFeatures, PostfachMail, PostfachMailListResource, PostfachMailResource, PostfachSettings, } from './postfach.model'; import { PostfachRepository } from './postfach.repository'; import { createResendPostfachMailCommand, createSendPostfachMailCommand } from './postfach.util'; @Injectable({ providedIn: 'root' }) export class PostfachService { + private readonly repository = inject(PostfachRepository); + private readonly commandService = inject(CommandService); + private readonly navigationService = inject(NavigationService); + private readonly vorgangService = inject(VorgangService); + private readonly snackbarService = inject(SnackBarService); + private readonly dialog = inject(MatDialog); + private readonly postfachFacade = inject(PostfachFacade); + private readonly binaryFileService = inject(BinaryFileService); + private readonly isPollSendPostachMail: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false); postfachMailList$: BehaviorSubject<StateResource<PostfachMailListResource>> = new BehaviorSubject< StateResource<PostfachMailListResource> @@ -82,16 +65,7 @@ export class PostfachService { private vorgangSubscription: Subscription; private postfachNachrichtenListSubscription: Subscription; - constructor( - private repository: PostfachRepository, - private commandService: CommandService, - private navigationService: NavigationService, - private vorgangService: VorgangService, - private snackbarService: SnackBarService, - private dialog: MatDialog, - private binaryFileService: BinaryFileService, - private postfachFacade: PostfachFacade, - ) { + constructor() { this.listenToNavigation(); } @@ -193,6 +167,7 @@ export class PostfachService { closeOpenDialogs(): void { this.dialog.closeAll(); + this.clearUploadedFiles(); } unsubscribe(): void { @@ -299,10 +274,6 @@ export class PostfachService { this.postfachMailList$.next(createStateResource(postfachMailList)); } - public loadAttachments(postfachNachricht: PostfachMailResource): Observable<StateResource<BinaryFileListResource>> { - return this.binaryFileService.getFiles(postfachNachricht, PostfachMailLinkRel.ATTACHMENTS); - } - public isDownloadPdfInProgress(): Observable<boolean> { return combineLatest([this.vorgangService.getVorgangWithEingang(), this.postfachFacade.isDownloadPdfInProgress()]).pipe( tap(([vorgang, isDownloadInProgress]) => { @@ -318,21 +289,6 @@ export class PostfachService { this.postfachFacade.startDownloadPdf(); } - public getAttachments(postfachNachricht: PostfachMailResource): Observable<BinaryFileResource[]> { - return this.postfachFacade.getAttachmentList().pipe( - tap((attachmentList) => - doIfLoadingRequired(attachmentList, () => this.postfachFacade.loadAttachmentList(postfachNachricht)), - ), - map((binaryFileListResource: StateResource<BinaryFileListResource>) => - getEmbeddedResources(binaryFileListResource, BinaryFileListLinkRel.FILE_LIST), - ), - ); - } - - public clearAttachmentList(): void { - this.postfachFacade.clearAttachmentList(); - } - public getFeatures(): Observable<PostfachFeatures> { return this.getPostfachMailListByVorgang().pipe( map((listStateResource: StateResource<PostfachMailListResource>) => listStateResource.resource.features), @@ -344,4 +300,8 @@ export class PostfachService { map((listStateResource: StateResource<PostfachMailListResource>) => listStateResource.resource.settings), ); } + + public clearUploadedFiles(): void { + this.binaryFileService.clearUploadedFiles(POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS); + } } diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.spec.ts index 7ac87155bd62df629b16f7b90a8485f833e7cea5..e520088dd7a78278b713934277034613dd2d9cff 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.spec.ts @@ -22,23 +22,15 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { PostfachMailFormComponent } from '@alfa-client/postfach'; -import { - PostfachMailFormDialogData, - PostfachMailListResource, - PostfachService, -} from '@alfa-client/postfach-shared'; -import { - HasLinkPipe, - StateResource, - createErrorStateResource, - createStateResource, -} from '@alfa-client/tech-shared'; +import { PostfachMailFormDialogData, PostfachMailListResource, PostfachService } from '@alfa-client/postfach-shared'; +import { createErrorStateResource, createStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared'; import { mock } from '@alfa-client/test-utils'; import { DialogService } from '@alfa-client/ui'; import { VorgangHeaderLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { getEmpfaenger } from '@alfa-client/vorgang-shared-ui'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { faker } from '@faker-js/faker'; +import { expect } from '@jest/globals'; import { createCommandResource } from 'libs/command-shared/test/command'; import { createPostfachMailListResource } from 'libs/postfach-shared/test/postfach'; import { createApiError } from 'libs/tech-shared/test/error'; @@ -62,11 +54,7 @@ describe('PostfachMailButtonContainerComponent', () => { beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [ - PostfachMailButtonContainerComponent, - HasLinkPipe, - MockComponent(PostfachMailButtonComponent), - ], + declarations: [PostfachMailButtonContainerComponent, HasLinkPipe, MockComponent(PostfachMailButtonComponent)], providers: [ { provide: DialogService, @@ -92,9 +80,7 @@ describe('PostfachMailButtonContainerComponent', () => { }); describe('vorgang changes', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ - VorgangHeaderLinkRel.POSTFACH_MAILS, - ]); + const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([VorgangHeaderLinkRel.POSTFACH_MAILS]); beforeEach(() => { component.loadPendingSendPostfachMailCommand = jest.fn(); @@ -117,9 +103,7 @@ describe('PostfachMailButtonContainerComponent', () => { describe('loadPendingSendPostfachMailCommand', () => { beforeEach(() => { component.closeDialog = jest.fn(); - postfachService.getPendingSendPostfachMailCommand.mockReturnValue( - of(createStateResource(createCommandResource())), - ); + postfachService.getPendingSendPostfachMailCommand.mockReturnValue(of(createStateResource(createCommandResource()))); }); it('should call postfach service', () => { @@ -136,9 +120,7 @@ describe('PostfachMailButtonContainerComponent', () => { }); describe('loadPostfachMailListStateResource', () => { - const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([ - VorgangHeaderLinkRel.POSTFACH_MAILS, - ]); + const vorgang: VorgangWithEingangResource = createVorgangWithEingangResource([VorgangHeaderLinkRel.POSTFACH_MAILS]); beforeEach(() => { postfachService.getPostfachMailListByGivenVorgang.mockReturnValue(of({})); @@ -157,11 +139,21 @@ describe('PostfachMailButtonContainerComponent', () => { const postfachMailListStateResource: StateResource<PostfachMailListResource> = createStateResource(createPostfachMailListResource()); + beforeEach(() => { + dialogService.openFixed.mockReturnValue({ afterClosed: jest.fn().mockReturnValue(of(null)) }); + }); + it('should open new dialog with given data', () => { component.openPostfachMailDialog(postfachMailListStateResource); expect(dialogService.openFixed).toHaveBeenCalled(); }); + + it('should clear upload files after dialog was closed', () => { + component.openPostfachMailDialog(postfachMailListStateResource); + + expect(postfachService.clearUploadedFiles).toHaveBeenCalled(); + }); }); describe('closeDialog', () => { @@ -197,9 +189,7 @@ describe('PostfachMailButtonContainerComponent', () => { const empfanger: string = faker.person.firstName(); getEmpfaengerMock.mockReturnValue(empfanger); - const dialogData: PostfachMailFormDialogData = component.buildDialogData( - postfachMailListStateResource, - ); + const dialogData: PostfachMailFormDialogData = component.buildDialogData(postfachMailListStateResource); expect(dialogData.empfaenger).toEqual(empfanger); }); @@ -211,9 +201,7 @@ describe('PostfachMailButtonContainerComponent', () => { }); it('should set title', () => { - const dialogData: PostfachMailFormDialogData = component.buildDialogData( - postfachMailListStateResource, - ); + const dialogData: PostfachMailFormDialogData = component.buildDialogData(postfachMailListStateResource); expect(dialogData.title).toEqual(PostfachMailButtonContainerComponent.TITLE); }); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts index 8670a6d75fb62befcdc6d7a3e07c0ac2b677107f..5810ca247015c57bbed5ea36e94c45c05c287601 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-button-container/postfach-mail-button-container.component.ts @@ -22,20 +22,15 @@ * unter der Lizenz sind dem Lizenztext zu entnehmen. */ import { CommandResource } from '@alfa-client/command-shared'; -import { - PostfachMailFormDialogData, - PostfachMailListLinkRel, - PostfachMailListResource, - PostfachService, -} from '@alfa-client/postfach-shared'; -import { StateResource, hasStateResourceError, isNotNull, isNotUndefined } from '@alfa-client/tech-shared'; +import { PostfachMailFormDialogData, PostfachMailListLinkRel, PostfachMailListResource, PostfachService, } from '@alfa-client/postfach-shared'; +import { hasStateResourceError, isNotNull, isNotUndefined, StateResource } from '@alfa-client/tech-shared'; import { DialogService, FixedDialogComponent } from '@alfa-client/ui'; import { VorgangHeaderLinkRel, VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { getEmpfaenger } from '@alfa-client/vorgang-shared-ui'; import { Component, Input } from '@angular/core'; import { MatDialogRef } from '@angular/material/dialog'; import { hasLink } from '@ngxp/rest'; -import { Observable } from 'rxjs'; +import { first, Observable } from 'rxjs'; import { tap } from 'rxjs/operators'; import { PostfachMailFormComponent } from '../postfach-mail-form/postfach-mail-form.component'; @@ -51,6 +46,7 @@ export class PostfachMailButtonContainerComponent { public get vorgang(): VorgangWithEingangResource { return this._vorgang; } + @Input() public set vorgang(value: VorgangWithEingangResource) { this._vorgang = value; @@ -59,6 +55,7 @@ export class PostfachMailButtonContainerComponent { this.loadPendingSendPostfachMailCommand(); } } + @Input() showAsIconButton: boolean; @Input() text: string; @Input() toolTip: string; @@ -76,9 +73,7 @@ export class PostfachMailButtonContainerComponent { ) {} loadPostfachMailListStateResource(): void { - this.postfachMailListStateResource$ = this.postfachService.getPostfachMailListByGivenVorgang( - this.vorgang, - ); + this.postfachMailListStateResource$ = this.postfachService.getPostfachMailListByGivenVorgang(this.vorgang); } loadPendingSendPostfachMailCommand(): void { @@ -88,26 +83,20 @@ export class PostfachMailButtonContainerComponent { } closeDialog(commandStateResource: StateResource<CommandResource>): void { - if ( - !hasStateResourceError(commandStateResource) && - commandStateResource.loaded && - isNotUndefined(this.dialogRef) - ) { + if (!hasStateResourceError(commandStateResource) && commandStateResource.loaded && isNotUndefined(this.dialogRef)) { this.dialogService.closeAll(); } } - public openPostfachMailDialog( - postfachMailListStateResource: StateResource<PostfachMailListResource>, - ): void { - this.dialogRef = this.dialogService.openFixed( - this.buildDialogData(postfachMailListStateResource), - ); + public openPostfachMailDialog(postfachMailListStateResource: StateResource<PostfachMailListResource>): void { + this.dialogRef = this.dialogService.openFixed(this.buildDialogData(postfachMailListStateResource)); + this.dialogRef + .afterClosed() + .pipe(first()) + .subscribe(() => this.postfachService.clearUploadedFiles()); } - buildDialogData( - postfachMailListStateResource: StateResource<PostfachMailListResource>, - ): PostfachMailFormDialogData { + buildDialogData(postfachMailListStateResource: StateResource<PostfachMailListResource>): PostfachMailFormDialogData { return { component: PostfachMailFormComponent, title: PostfachMailButtonContainerComponent.TITLE, diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html index 187cd25d070f87a75faa3b08db3ce643671ac439..56e1c490b8b2e01e5644eda045e3f210d56eb1de 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.html @@ -45,9 +45,14 @@ > </ozgcloud-textarea-editor> - <alfa-postfach-nachricht-attachment-container - [postfachNachricht]="dialogData.postfachNachricht" - ></alfa-postfach-nachricht-attachment-container> + <ods-multi-file-upload + [filesFormFieldName]="formServiceClass.FIELD_ATTACHMENTS" + [fileUploadType]="POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS" + [uploadResource]="dialogData.postfachMailListStateResource.resource" + [uploadLinkRelation]="PostfachMailListLinkRel.UPLOAD_ATTACHMENT" + [filesResource]="dialogData.postfachNachricht" + [filesLinkRelation]="PostfachMailLinkRel.ATTACHMENTS" + ></ods-multi-file-upload> <div class="button-bar-bottom space-between"> <ozgcloud-stroked-button-with-spinner diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts index 5b5beec8bf365ee4a043970eb471f592faeb4ed7..6eac1a58938ad4d04061bc0d05a29d00dcd61d7d 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.spec.ts @@ -24,15 +24,7 @@ import { PostfachService } from '@alfa-client/postfach-shared'; import { createStateResource } from '@alfa-client/tech-shared'; import { Mock, mock, useFromMock } from '@alfa-client/test-utils'; -import { - DialogService, - FileUploadComponent, - IconButtonWithSpinnerComponent, - OzgcloudStrokedButtonWithSpinnerComponent, - OzgcloudTextEditorComponent, - SpinnerComponent, - TextAreaEditorComponent, -} from '@alfa-client/ui'; +import { DialogService, FileUploadComponent, IconButtonWithSpinnerComponent, OzgcloudStrokedButtonWithSpinnerComponent, OzgcloudTextEditorComponent, SpinnerComponent, TextAreaEditorComponent, } from '@alfa-client/ui'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { FormBuilder, ReactiveFormsModule } from '@angular/forms'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; @@ -40,14 +32,14 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatInputModule } from '@angular/material/input'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { createCommandResource } from 'libs/command-shared/test/command'; -import { PostfachTestFactory, createPostfachSettings } from 'libs/postfach-shared/test/postfach'; +import { createPostfachSettings, PostfachTestFactory } from 'libs/postfach-shared/test/postfach'; import { MockComponent } from 'ng-mocks'; import { of } from 'rxjs'; import { PostfachMailFormComponent } from './postfach-mail-form.component'; import { PostfachMailFormservice } from './postfach-mail.formservice'; -import { PostfachNachrichtAttachmentContainerComponent } from './postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component'; import { PostfachNachrichtReplyEditorContainerComponent } from './postfach-nachricht-reply-editor-container/postfach-nachricht-reply-editor-container.component'; +import { MultiFileUploadComponent } from '../../../../binary-file/src/lib/multi-file-upload/multi-file-upload.component'; import * as CommandUtil from '../../../../command-shared/src/lib/command.util'; describe('PostfachMailFormComponent', () => { @@ -72,7 +64,7 @@ describe('PostfachMailFormComponent', () => { MockComponent(PostfachNachrichtReplyEditorContainerComponent), MockComponent(SpinnerComponent), MockComponent(FileUploadComponent), - MockComponent(PostfachNachrichtAttachmentContainerComponent), + MockComponent(MultiFileUploadComponent), ], imports: [MatFormFieldModule, MatInputModule, ReactiveFormsModule, BrowserAnimationsModule], providers: [ diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts index ca025479a0a9cecc88383647a3864487d9db8017..e5c1c3514301810c4a832ac3b16952bc5e22515f 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-mail-form.component.ts @@ -21,16 +21,16 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { CommandResource } from '@alfa-client/command-shared'; -import { PostfachMailFormDialogData } from '@alfa-client/postfach-shared'; -import { StateResource, createEmptyStateResource, isNotNil } from '@alfa-client/tech-shared'; +import { CommandResource, isSuccessfulDone } from '@alfa-client/command-shared'; +import { PostfachMailFormDialogData, PostfachMailLinkRel, PostfachMailListLinkRel } from '@alfa-client/postfach-shared'; +import { createEmptyStateResource, isNotNil, StateResource } from '@alfa-client/tech-shared'; import { DialogService } from '@alfa-client/ui'; import { Component, Inject, OnInit } from '@angular/core'; import { MAT_DIALOG_DATA } from '@angular/material/dialog'; import { Observable, of, tap } from 'rxjs'; import { PostfachMailFormservice } from './postfach-mail.formservice'; -import * as CommandUtil from '../../../../command-shared/src/lib/command.util'; +import { POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS } from '@admin-client/postfach-shared'; @Component({ selector: 'alfa-postfach-mail-form', @@ -41,9 +41,11 @@ import * as CommandUtil from '../../../../command-shared/src/lib/command.util'; export class PostfachMailFormComponent implements OnInit { public readonly formServiceClass = PostfachMailFormservice; - public sendInProgress$: Observable<StateResource<CommandResource>> = of( - createEmptyStateResource<CommandResource>(), - ); + public sendInProgress$: Observable<StateResource<CommandResource>> = of(createEmptyStateResource<CommandResource>()); + + public readonly PostfachMailListLinkRel = PostfachMailListLinkRel; + public readonly PostfachMailLinkRel = PostfachMailLinkRel; + public readonly POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS = POSTFACH_NACHRICHT_UPLOADED_ATTACHMENTS; constructor( private dialogService: DialogService, @@ -65,14 +67,12 @@ export class PostfachMailFormComponent implements OnInit { this.sendInProgress$ = this.formService .submit() .pipe( - tap((commandStateResource: StateResource<CommandResource>) => - this.closeDialogsOnSuccessfulSubmit(commandStateResource), - ), + tap((commandStateResource: StateResource<CommandResource>) => this.closeDialogsOnSuccessfulSubmit(commandStateResource)), ); } closeDialogsOnSuccessfulSubmit(commandStateResource: StateResource<CommandResource>): void { - if (CommandUtil.isSuccessfulDone(commandStateResource.resource)) { + if (isSuccessfulDone(commandStateResource.resource)) { this.dialogService.closeAll(); } } diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.html deleted file mode 100644 index c907494c101d39d7b8e9e7cf6adf26eaced8363b..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.html +++ /dev/null @@ -1,32 +0,0 @@ -<!-- - - Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - Ministerpräsidenten des Landes Schleswig-Holstein - Staatskanzlei - Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - - Lizenziert unter der EUPL, Version 1.2 oder - sobald - diese von der Europäischen Kommission genehmigt wurden - - Folgeversionen der EUPL ("Lizenz"); - Sie dürfen dieses Werk ausschließlich gemäß - dieser Lizenz nutzen. - Eine Kopie der Lizenz finden Sie hier: - - https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - - Sofern nicht durch anwendbare Rechtsvorschriften - gefordert oder in schriftlicher Form vereinbart, wird - die unter der Lizenz verbreitete Software "so wie sie - ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - ausdrücklich oder stillschweigend - verbreitet. - Die sprachspezifischen Genehmigungen und Beschränkungen - unter der Lizenz sind dem Lizenztext zu entnehmen. - ---> -<alfa-binary-file-attachment-container - [formArrayName]="formServiceClass.FIELD_ATTACHMENTS" - [existFiles]="attachments$ | async" - [uploadStateResource]="postfachNachrichtListStateResource$ | async" - [linkRelUploadAttachment]="postfachMailListLinkRel.UPLOAD_ATTACHMENT" -> -</alfa-binary-file-attachment-container> diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.scss b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.scss deleted file mode 100644 index 54c4f3eb8c92af93694c03cdf577fed23cf9f86b..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.scss +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.spec.ts deleted file mode 100644 index 61948618124f3cb14813d3ba6a1cf365345e1d78..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.spec.ts +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BinaryFileAttachmentContainerComponent } from '@alfa-client/binary-file'; -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { - PostfachMailListLinkRel, - PostfachMailListResource, - PostfachService, -} from '@alfa-client/postfach-shared'; -import { StateResource, createStateResource } from '@alfa-client/tech-shared'; -import { Mock, getMockComponent, mock } from '@alfa-client/test-utils'; -import { createBinaryFileResource } from 'libs/binary-file-shared/test/binary-file'; -import { - PostfachTestFactory, - createPostfachMailListResource, -} from 'libs/postfach-shared/test/postfach'; -import { MockComponent } from 'ng-mocks'; -import { of } from 'rxjs'; -import { PostfachMailFormservice } from '../postfach-mail.formservice'; -import { PostfachNachrichtAttachmentContainerComponent } from './postfach-nachricht-attachment-container.component'; - -describe('PostfachNachrichtAttachmentContainerComponent', () => { - let component: PostfachNachrichtAttachmentContainerComponent; - let fixture: ComponentFixture<PostfachNachrichtAttachmentContainerComponent>; - - const service: Mock<PostfachService> = mock(PostfachService); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ - PostfachNachrichtAttachmentContainerComponent, - MockComponent(BinaryFileAttachmentContainerComponent), - ], - providers: [ - { - provide: PostfachService, - useValue: service, - }, - ], - }).compileComponents(); - - fixture = TestBed.createComponent(PostfachNachrichtAttachmentContainerComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - describe('ngOnInit', () => { - beforeEach(() => { - component.initAttachments = jest.fn(); - }); - - it('should get list stateResource', () => { - component.ngOnInit(); - - expect(service.getPostfachMailListByVorgang).toHaveBeenCalled(); - }); - - it('should initAttachments on existing postfachNachricht', () => { - component.postfachNachricht = PostfachTestFactory.POSTFACH_NACHRICHT_RESOURCE; - - component.ngOnInit(); - - expect(component.initAttachments).toHaveBeenCalled(); - }); - - it('should not init attachments on missing postfachNachricht', () => { - component.postfachNachricht = undefined; - - component.ngOnInit(); - - expect(component.initAttachments).not.toHaveBeenCalled(); - }); - }); - - describe('binary file attachment container', () => { - it('should be called with formArrayName', () => { - const binaryFileAttachmentContainer: BinaryFileAttachmentContainerComponent = - getMockComponent(fixture, BinaryFileAttachmentContainerComponent); - expect(binaryFileAttachmentContainer.formArrayName).toBe( - PostfachMailFormservice.FIELD_ATTACHMENTS, - ); - }); - - it('should be called with existFiles', () => { - const attachments: BinaryFileResource[] = [createBinaryFileResource()]; - component.attachments$ = of(attachments); - - fixture.detectChanges(); - - const binaryFileAttachmentContainer: BinaryFileAttachmentContainerComponent = - getMockComponent(fixture, BinaryFileAttachmentContainerComponent); - expect(binaryFileAttachmentContainer.existFiles).toBe(attachments); - }); - - it('should be called with upload stateResource', () => { - const listStateResource: StateResource<PostfachMailListResource> = createStateResource( - createPostfachMailListResource(), - ); - component.postfachNachrichtListStateResource$ = of(listStateResource); - - fixture.detectChanges(); - - const binaryFileAttachmentContainer: BinaryFileAttachmentContainerComponent = - getMockComponent(fixture, BinaryFileAttachmentContainerComponent); - expect(binaryFileAttachmentContainer.uploadStateResource).toBe(listStateResource); - }); - - it('should be called with linkRel upload attachment', () => { - const binaryFileAttachmentContainer: BinaryFileAttachmentContainerComponent = - getMockComponent(fixture, BinaryFileAttachmentContainerComponent); - expect(binaryFileAttachmentContainer.linkRelUploadAttachment).toBe( - PostfachMailListLinkRel.UPLOAD_ATTACHMENT, - ); - }); - }); - - describe('ngOnDestroy', () => { - it('should clear attachments', () => { - component.ngOnDestroy(); - - expect(service.clearAttachmentList).toHaveBeenCalled(); - }); - }); -}); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.ts deleted file mode 100644 index 0d3b7339b30a9ca15d03d791d60db92e7e42299b..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { BinaryFileResource } from '@alfa-client/binary-file-shared'; -import { - PostfachMailLinkRel, - PostfachMailListLinkRel, - PostfachMailListResource, - PostfachMailResource, - PostfachService, -} from '@alfa-client/postfach-shared'; -import { FormProvider, StateResource, isNotNil } from '@alfa-client/tech-shared'; -import { Component, Input, OnDestroy } from '@angular/core'; -import { hasLink } from '@ngxp/rest'; -import { Observable, of } from 'rxjs'; -import { PostfachMailFormservice } from '../postfach-mail.formservice'; - -@Component({ - selector: 'alfa-postfach-nachricht-attachment-container', - templateUrl: './postfach-nachricht-attachment-container.component.html', - styleUrls: ['./postfach-nachricht-attachment-container.component.scss'], - viewProviders: [FormProvider], -}) -export class PostfachNachrichtAttachmentContainerComponent implements OnDestroy { - @Input() postfachNachricht: PostfachMailResource; - - postfachNachrichtListStateResource$: Observable<StateResource<PostfachMailListResource>>; - attachments$: Observable<BinaryFileResource[]> = of<BinaryFileResource[]>([]); - - public readonly postfachMailListLinkRel = PostfachMailListLinkRel; - public readonly formServiceClass = PostfachMailFormservice; - - constructor(private postfachService: PostfachService) {} - - ngOnInit(): void { - this.postfachNachrichtListStateResource$ = this.postfachService.getPostfachMailListByVorgang(); - - if (isNotNil(this.postfachNachricht)) { - this.initAttachments(); - } - } - - initAttachments(): void { - if (hasLink(this.postfachNachricht, PostfachMailLinkRel.ATTACHMENTS)) { - this.attachments$ = this.postfachService.getAttachments(this.postfachNachricht); - } - } - - ngOnDestroy(): void { - this.postfachService.clearAttachmentList(); - } -} diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.html deleted file mode 100644 index 0c91966fbcdcafe6c47f4d31cfd9557b6fbdf7d3..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.html +++ /dev/null @@ -1,27 +0,0 @@ -<!-- - - Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - Ministerpräsidenten des Landes Schleswig-Holstein - Staatskanzlei - Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - - Lizenziert unter der EUPL, Version 1.2 oder - sobald - diese von der Europäischen Kommission genehmigt wurden - - Folgeversionen der EUPL ("Lizenz"); - Sie dürfen dieses Werk ausschließlich gemäß - dieser Lizenz nutzen. - Eine Kopie der Lizenz finden Sie hier: - - https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - - Sofern nicht durch anwendbare Rechtsvorschriften - gefordert oder in schriftlicher Form vereinbart, wird - die unter der Lizenz verbreitete Software "so wie sie - ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - ausdrücklich oder stillschweigend - verbreitet. - Die sprachspezifischen Genehmigungen und Beschränkungen - unter der Lizenz sind dem Lizenztext zu entnehmen. - ---> -<alfa-vertical-binary-file-list [binaryFileListStateResource]="attachments$ | async"> -</alfa-vertical-binary-file-list> diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.scss b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.scss deleted file mode 100644 index 87ec96c5bc70794e99e27966a5de96750909f80d..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.scss +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -.files { - display: flex; - flex-wrap: wrap; - margin: 4px -4px; - flex-direction: row; - max-width: 100%; - align-items: flex-start; -} diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.spec.ts deleted file mode 100644 index 8556f6a6ce7f3b8b95a34ec9a387e04817c367b1..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.spec.ts +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { registerLocaleData } from '@angular/common'; -import localeDe from '@angular/common/locales/de'; -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BinaryFileListResource } from '@alfa-client/binary-file-shared'; -import { PostfachMailResource, PostfachService } from '@alfa-client/postfach-shared'; -import { ConvertForDataTestPipe, createStateResource } from '@alfa-client/tech-shared'; -import { Mock, mock } from '@alfa-client/test-utils'; -import { SpinnerComponent } from '@alfa-client/ui'; -import { createBinaryFileListResource } from 'libs/binary-file-shared/test/binary-file'; -import { createPostfachMailResource } from 'libs/postfach-shared/test/postfach'; -import { MockComponent } from 'ng-mocks'; -import { of } from 'rxjs'; -import { PostfachMailAttachmentsComponent } from './postfach-mail-attachments.component'; -import { VerticalBinaryFileListComponent } from '@alfa-client/binary-file'; - -registerLocaleData(localeDe); - -describe('PostfachMailAttachmentsComponent', () => { - let component: PostfachMailAttachmentsComponent; - let fixture: ComponentFixture<PostfachMailAttachmentsComponent>; - - const postfachNachricht: PostfachMailResource = createPostfachMailResource(); - - const postfachService: Mock<PostfachService> = mock(PostfachService); - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ - PostfachMailAttachmentsComponent, - ConvertForDataTestPipe, - MockComponent(VerticalBinaryFileListComponent), - MockComponent(SpinnerComponent), - ], - providers: [ - { - provide: PostfachService, - useValue: postfachService, - }, - ], - }).compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(PostfachMailAttachmentsComponent); - component = fixture.componentInstance; - component.postfachNachricht = postfachNachricht; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); - - describe('ngOnChanges', () => { - const attachmentList: BinaryFileListResource = createBinaryFileListResource(); - - beforeEach(() => { - postfachService.loadAttachments.mockReturnValue(of(createStateResource(attachmentList))); - }); - - it('should call service', () => { - component.ngOnChanges(); - - expect(postfachService.loadAttachments).toHaveBeenCalledWith(postfachNachricht); - }); - }); -}); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.ts deleted file mode 100644 index b88457f2c228477973d769cbfa164f7da8f09b31..0000000000000000000000000000000000000000 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component.ts +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2023 Das Land Schleswig-Holstein vertreten durch den - * Ministerpräsidenten des Landes Schleswig-Holstein - * Staatskanzlei - * Abteilung Digitalisierung und zentrales IT-Management der Landesregierung - * - * Lizenziert unter der EUPL, Version 1.2 oder - sobald - * diese von der Europäischen Kommission genehmigt wurden - - * Folgeversionen der EUPL ("Lizenz"); - * Sie dürfen dieses Werk ausschließlich gemäß - * dieser Lizenz nutzen. - * Eine Kopie der Lizenz finden Sie hier: - * - * https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12 - * - * Sofern nicht durch anwendbare Rechtsvorschriften - * gefordert oder in schriftlicher Form vereinbart, wird - * die unter der Lizenz verbreitete Software "so wie sie - * ist", OHNE JEGLICHE GEWÄHRLEISTUNG ODER BEDINGUNGEN - - * ausdrücklich oder stillschweigend - verbreitet. - * Die sprachspezifischen Genehmigungen und Beschränkungen - * unter der Lizenz sind dem Lizenztext zu entnehmen. - */ -import { Component, Input, OnChanges } from '@angular/core'; -import { BinaryFileListResource } from '@alfa-client/binary-file-shared'; -import { PostfachMailResource, PostfachService } from '@alfa-client/postfach-shared'; -import { createEmptyStateResource, StateResource } from '@alfa-client/tech-shared'; -import { Observable, of } from 'rxjs'; - -@Component({ - selector: 'alfa-postfach-mail-attachments', - templateUrl: './postfach-mail-attachments.component.html', - styleUrls: ['./postfach-mail-attachments.component.scss'], -}) -export class PostfachMailAttachmentsComponent implements OnChanges { - @Input() postfachNachricht: PostfachMailResource; - - attachments$: Observable<StateResource<BinaryFileListResource>> = of( - createEmptyStateResource<BinaryFileListResource>(), - ); - - constructor(private postfachService: PostfachService) {} - - ngOnChanges(): void { - this.attachments$ = this.postfachService.loadAttachments(this.postfachNachricht); - } -} diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.html b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.html index b87d049868c0c54e15b1e20eb351dca3c483ad98..b9a11494ce9e63d735f2829904d138b8670a1eb3 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.html +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.html @@ -37,9 +37,11 @@ > </alfa-outgoing-mail> -<alfa-postfach-mail-attachments - *ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.ATTACHMENTS) && onPage" - data-test-id="postfach-mail-attachments-container" - [postfachNachricht]="postfachMail" -> -</alfa-postfach-mail-attachments> + +@if((postfachMail | hasLink: postfachNachrichtLinkRel.ATTACHMENTS) && onPage){ +<alfa-binary-file-list-container + [resource]="postfachMail" + [linkRel]="PostfachMailLinkRel.ATTACHMENTS" + [listOrientation]="BinaryFileListOrientation.VERTICAL" + data-test-id="postfach-mail-attachments-container"></alfa-binary-file-list-container> +} diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.spec.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.spec.ts index 02fedf3b44d53fe51c05ef688c6f638b831ced6c..24c3fe590a36fde09fb1acb5b0a5fa1bf214982f 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.spec.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.spec.ts @@ -21,27 +21,18 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { - Direction, - ON_PAGE, - PostfachMailLinkRel, - PostfachMailResource, -} from '@alfa-client/postfach-shared'; -import { HasLinkPipe, StateResource, createStateResource } from '@alfa-client/tech-shared'; -import { - existsAsHtmlElement, - getMockComponent, - notExistsAsHtmlElement, -} from '@alfa-client/test-utils'; +import { BinaryFileListContainerComponent } from '@alfa-client/binary-file'; +import { Direction, ON_PAGE, PostfachMailLinkRel, PostfachMailResource } from '@alfa-client/postfach-shared'; +import { createStateResource, HasLinkPipe, StateResource } from '@alfa-client/tech-shared'; +import { existsAsHtmlElement, getMockComponent, notExistsAsHtmlElement } from '@alfa-client/test-utils'; import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; +import { ComponentFixture, TestBed } from '@angular/core/testing'; import { createPostfachMailResource } from 'libs/postfach-shared/test/postfach'; import { getDataTestIdOf } from 'libs/tech-shared/test/data-test'; import { createVorgangWithEingangResource } from 'libs/vorgang-shared/test/vorgang'; import { MockComponent } from 'ng-mocks'; import { IncommingMailComponent } from './incomming-mail/incomming-mail.component'; import { OutgoingMailComponent } from './outgoing-mail/outgoing-mail.component'; -import { PostfachMailAttachmentsComponent } from './postfach-mail-attachments/postfach-mail-attachments.component'; import { PostfachMailComponent } from './postfach-mail.component'; describe('PostfachMailComponent', () => { @@ -50,9 +41,7 @@ describe('PostfachMailComponent', () => { const postfachIncomingNachricht: string = getDataTestIdOf('postfach-incoming-nachricht'); const postfachOutgoingNachricht: string = getDataTestIdOf('postfach-outgoing-nachricht'); - const postfachNachrichtAttachments: string = getDataTestIdOf( - 'postfach-mail-attachments-container', - ); + const postfachNachrichtAttachments: string = getDataTestIdOf('postfach-mail-attachments-container'); beforeEach(async () => { await TestBed.configureTestingModule({ @@ -61,7 +50,7 @@ describe('PostfachMailComponent', () => { PostfachMailComponent, MockComponent(IncommingMailComponent), MockComponent(OutgoingMailComponent), - MockComponent(PostfachMailAttachmentsComponent), + MockComponent(BinaryFileListContainerComponent), ], providers: [ { @@ -94,9 +83,7 @@ describe('PostfachMailComponent', () => { }); describe('on existing link and page', () => { - const postfachNachricht: PostfachMailResource = createPostfachMailResource([ - PostfachMailLinkRel.ATTACHMENTS, - ]); + const postfachNachricht: PostfachMailResource = createPostfachMailResource([PostfachMailLinkRel.ATTACHMENTS]); beforeEach(() => { component.onPage = true; @@ -108,17 +95,6 @@ describe('PostfachMailComponent', () => { existsAsHtmlElement(fixture, postfachNachrichtAttachments); }); - - it('should be called with postfachNachricht', () => { - fixture.detectChanges(); - - const postfachAttachmentsComponent: PostfachMailAttachmentsComponent = getMockComponent( - fixture, - PostfachMailAttachmentsComponent, - ); - - expect(postfachAttachmentsComponent.postfachNachricht).toBe(postfachNachricht); - }); }); }); @@ -140,19 +116,13 @@ describe('PostfachMailComponent', () => { describe('call', () => { it('should be with postfachNachricht', () => { - const outgoingMailComponent: OutgoingMailComponent = getMockComponent( - fixture, - OutgoingMailComponent, - ); + const outgoingMailComponent: OutgoingMailComponent = getMockComponent(fixture, OutgoingMailComponent); expect(outgoingMailComponent.postfachMail).toBe(outgoingPostfachNachricht); }); it('should be with vorgangStateResource', () => { - const outgoingMailComponent: OutgoingMailComponent = getMockComponent( - fixture, - OutgoingMailComponent, - ); + const outgoingMailComponent: OutgoingMailComponent = getMockComponent(fixture, OutgoingMailComponent); expect(outgoingMailComponent.vorgangStateResource).toBe(vorgangStateResource); }); @@ -194,10 +164,7 @@ describe('PostfachMailComponent', () => { describe('call', () => { it('should be with postfachNachricht', () => { - const incomingMailComponent: IncommingMailComponent = getMockComponent( - fixture, - IncommingMailComponent, - ); + const incomingMailComponent: IncommingMailComponent = getMockComponent(fixture, IncommingMailComponent); expect(incomingMailComponent.postfachMail).toBe(incomingPostfachNachricht); }); diff --git a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.ts b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.ts index 25bde83011fce2fe074aa2945a06894458bcb4e0..50cb1511c6d09b34bb4b19a65e1d1d5eb5508440 100644 --- a/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.ts +++ b/alfa-client/libs/postfach/src/lib/postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component.ts @@ -21,12 +21,8 @@ * Die sprachspezifischen Genehmigungen und Beschränkungen * unter der Lizenz sind dem Lizenztext zu entnehmen. */ -import { - ON_PAGE, - PostfachMailLinkRel, - PostfachMailResource, - isIncomingMail, -} from '@alfa-client/postfach-shared'; +import { BinaryFileListOrientation } from '@alfa-client/binary-file'; +import { isIncomingMail, ON_PAGE, PostfachMailLinkRel, PostfachMailResource } from '@alfa-client/postfach-shared'; import { StateResource } from '@alfa-client/tech-shared'; import { VorgangWithEingangResource } from '@alfa-client/vorgang-shared'; import { Component, Inject, Input } from '@angular/core'; @@ -47,4 +43,7 @@ export class PostfachMailComponent { public get isIncomingMail(): boolean { return isIncomingMail(this.postfachMail); } + + protected readonly BinaryFileListOrientation = BinaryFileListOrientation; + protected readonly PostfachMailLinkRel = PostfachMailLinkRel; } diff --git a/alfa-client/libs/postfach/src/lib/postfach.module.ts b/alfa-client/libs/postfach/src/lib/postfach.module.ts index 2a6fe82af2922461a8ed345f322b54e754f2ccec..88fd93b41fff801fb308bfc6a227483cc5042fc4 100644 --- a/alfa-client/libs/postfach/src/lib/postfach.module.ts +++ b/alfa-client/libs/postfach/src/lib/postfach.module.ts @@ -24,17 +24,7 @@ import { BinaryFileModule } from '@alfa-client/binary-file'; import { ON_PAGE, PostfachSharedModule } from '@alfa-client/postfach-shared'; import { ConvertForDataTestPipe, FormatDateWithTimePipe, HasLinkPipe, ToEmbeddedResourcesPipe } from '@alfa-client/tech-shared'; -import { - BackButtonComponent, - CheckboxEnumEditorComponent, - IconButtonWithSpinnerComponent, - OzgcloudIconComponent, - OzgcloudStrokedButtonWithSpinnerComponent, - OzgcloudTextEditorComponent, - SpinnerComponent, - SubnavigationComponent, - TextAreaEditorComponent, -} from '@alfa-client/ui'; +import { BackButtonComponent, CheckboxEnumEditorComponent, IconButtonWithSpinnerComponent, OzgcloudIconComponent, OzgcloudStrokedButtonWithSpinnerComponent, OzgcloudTextEditorComponent, SpinnerComponent, SubnavigationComponent, TextAreaEditorComponent, } from '@alfa-client/ui'; import { UserProfileModule } from '@alfa-client/user-profile'; import { VorgangSharedUiModule } from '@alfa-client/vorgang-shared-ui'; import { CommonModule } from '@angular/common'; @@ -43,10 +33,10 @@ import { ReactiveFormsModule } from '@angular/forms'; import { MatIcon } from '@angular/material/icon'; import { RouterModule, Routes } from '@angular/router'; import { ButtonComponent, MailboxIconComponent, PlusIconComponent, TooltipDirective } from '@ods/system'; +import { MultiFileUploadComponent } from '../../../binary-file/src/lib/multi-file-upload/multi-file-upload.component'; import { PostfachMailButtonContainerComponent } from './postfach-mail-button-container/postfach-mail-button-container.component'; import { PostfachMailButtonComponent } from './postfach-mail-button-container/postfach-mail-button/postfach-mail-button.component'; import { PostfachMailFormComponent } from './postfach-mail-form/postfach-mail-form.component'; -import { PostfachNachrichtAttachmentContainerComponent } from './postfach-mail-form/postfach-nachricht-attachment-container/postfach-nachricht-attachment-container.component'; import { PostfachNachrichtReplyEditorContainerComponent } from './postfach-mail-form/postfach-nachricht-reply-editor-container/postfach-nachricht-reply-editor-container.component'; import { PostfachMailListContainerComponent } from './postfach-mail-list-container/postfach-mail-list-container.component'; import { PostfachMailListComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail-list.component'; @@ -55,7 +45,6 @@ import { OutgoingMailErrorContainerComponent } from './postfach-mail-list-contai import { OutgoingMailErrorComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail-error-container/outgoing-mail-error/outgoing-mail-error.component'; import { OutgoingMailComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/outgoing-mail.component'; import { PostfachNachrichtEditButtonContainerComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/outgoing-mail/postfach-nachricht-edit-button-container/postfach-nachricht-edit-button-container.component'; -import { PostfachMailAttachmentsComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-attachments/postfach-mail-attachments.component'; import { PostfachMailDateComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail-date/postfach-mail-date.component'; import { PostfachMailComponent } from './postfach-mail-list-container/postfach-mail-list/postfach-mail/postfach-mail.component'; import { PostfachMailPdfButtonContainerComponent } from './postfach-mail-pdf-button-container/postfach-mail-pdf-button-container.component'; @@ -99,6 +88,7 @@ const routes: Routes = [ PlusIconComponent, MailboxIconComponent, TooltipDirective, + MultiFileUploadComponent, ], declarations: [ PostfachMailListContainerComponent, @@ -114,12 +104,10 @@ const routes: Routes = [ OutgoingMailErrorComponent, PostfachMailDateComponent, OutgoingMailErrorContainerComponent, - PostfachMailAttachmentsComponent, PostfachMailButtonComponent, PostfachMailPdfButtonContainerComponent, PostfachMailPdfButtonComponent, PostfachNachrichtEditButtonContainerComponent, - PostfachNachrichtAttachmentContainerComponent, PostfachNachrichtReplyEditorContainerComponent, ], exports: [PostfachMailListContainerComponent, PostfachMailButtonContainerComponent, PostfachMailFormComponent],