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

OZG-2966 OZG-3098 create export as pdf button; include button in vorgangdetail page

parent d90cc6e9
No related branches found
No related tags found
No related merge requests found
Showing
with 124 additions and 9 deletions
<h3 class="nachrichten">Nachrichten</h3> <h3 class="nachrichten">Nachrichten</h3>
<goofy-client-postfach-mail-pdf-button-container *ngIf="vorgang | hasLink: vorgangHeaderLinkRel.POSTFACH_MAILS" data-test-id="postfach-pdf-button"></goofy-client-postfach-mail-pdf-button-container>
<goofy-client-spinner [stateResource]="postfachMailListStateResource"> <goofy-client-spinner [stateResource]="postfachMailListStateResource">
<goofy-client-postfach-mail *ngFor="let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST" <goofy-client-postfach-mail *ngFor="let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST"
class="postfach" class="postfach"
......
...@@ -3,9 +3,13 @@ import { PostfachMailListLinkRel } from '@goofy-client/postfach-shared'; ...@@ -3,9 +3,13 @@ import { PostfachMailListLinkRel } from '@goofy-client/postfach-shared';
import { ConvertForDataTestPipe, createStateResource, HasLinkPipe, ToEmbeddedResourcesPipe } from '@goofy-client/tech-shared'; import { ConvertForDataTestPipe, createStateResource, HasLinkPipe, ToEmbeddedResourcesPipe } from '@goofy-client/tech-shared';
import { getElementFromFixture } from '@goofy-client/test-utils'; import { getElementFromFixture } from '@goofy-client/test-utils';
import { ExpansionPanelComponent, SpinnerComponent } from '@goofy-client/ui'; import { ExpansionPanelComponent, SpinnerComponent } from '@goofy-client/ui';
import { VorgangHeaderLinkRel } from '@goofy-client/vorgang-shared';
import { createPostfachMailListResource } from 'libs/postfach-shared/test/postfach'; import { createPostfachMailListResource } 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 { MockComponent } from 'ng-mocks';
import { PostfachMailButtonContainerComponent } from '../../postfach-mail-button-container/postfach-mail-button-container.component'; import { PostfachMailButtonContainerComponent } from '../../postfach-mail-button-container/postfach-mail-button-container.component';
import { PostfachMailPdfButtonContainerComponent } from '../../postfach-mail-pdf-button-container/postfach-mail-pdf-button-container.component';
import { PostfachMailListComponent } from './postfach-mail-list.component'; import { PostfachMailListComponent } from './postfach-mail-list.component';
import { PostfachMailComponent } from './postfach-mail/postfach-mail.component'; import { PostfachMailComponent } from './postfach-mail/postfach-mail.component';
...@@ -13,8 +17,9 @@ describe('PostfachMailListComponent', () => { ...@@ -13,8 +17,9 @@ describe('PostfachMailListComponent', () => {
let component: PostfachMailListComponent; let component: PostfachMailListComponent;
let fixture: ComponentFixture<PostfachMailListComponent>; let fixture: ComponentFixture<PostfachMailListComponent>;
const postfachMailButton: string = '[data-test-id="postfach-mail-button-container"]'; const postfachMailButton: string = getDataTestIdOf('postfach-mail-button-container');
const noPostfachText: string = '[data-test-id="no-postfach-text"]'; const noPostfachText: string = getDataTestIdOf('no-postfach-text');
const postfachPdfButton: string = getDataTestIdOf('postfach-pdf-button');
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
...@@ -26,7 +31,8 @@ describe('PostfachMailListComponent', () => { ...@@ -26,7 +31,8 @@ describe('PostfachMailListComponent', () => {
MockComponent(ExpansionPanelComponent), MockComponent(ExpansionPanelComponent),
MockComponent(PostfachMailComponent), MockComponent(PostfachMailComponent),
MockComponent(SpinnerComponent), MockComponent(SpinnerComponent),
MockComponent(PostfachMailButtonContainerComponent) MockComponent(PostfachMailButtonContainerComponent),
MockComponent(PostfachMailPdfButtonContainerComponent)
] ]
}) })
.compileComponents(); .compileComponents();
...@@ -82,4 +88,25 @@ describe('PostfachMailListComponent', () => { ...@@ -82,4 +88,25 @@ describe('PostfachMailListComponent', () => {
expect(button).toBeInstanceOf(HTMLElement); expect(button).toBeInstanceOf(HTMLElement);
}) })
}) })
describe('postfach pdf button', () => {
it('should show if link exist', () => {
component.vorgang = createVorgangWithEingangResource([VorgangHeaderLinkRel.POSTFACH_MAILS]);
fixture.detectChanges();
var pdfButtonElement = getElementFromFixture(fixture, postfachPdfButton);
expect(pdfButtonElement).toBeInTheDocument();
})
it('should hide if link is missing', () => {
component.vorgang = createVorgangWithEingangResource();
fixture.detectChanges();
var pdfButtonElement = getElementFromFixture(fixture, postfachPdfButton);
expect(pdfButtonElement).not.toBeInTheDocument();
})
})
}); });
\ No newline at end of file
import { Component, Input } from '@angular/core'; import { Component, Input } from '@angular/core';
import { PostfachMailListLinkRel, PostfachMailListResource } from '@goofy-client/postfach-shared'; import { PostfachMailListLinkRel, PostfachMailListResource } from '@goofy-client/postfach-shared';
import { StateResource } from '@goofy-client/tech-shared'; import { StateResource } from '@goofy-client/tech-shared';
import { VorgangWithEingangResource } from '@goofy-client/vorgang-shared'; import { VorgangHeaderLinkRel, VorgangWithEingangResource } from '@goofy-client/vorgang-shared';
@Component({ @Component({
selector: 'goofy-client-postfach-mail-list', selector: 'goofy-client-postfach-mail-list',
...@@ -14,4 +14,5 @@ export class PostfachMailListComponent { ...@@ -14,4 +14,5 @@ export class PostfachMailListComponent {
@Input() vorgang: VorgangWithEingangResource; @Input() vorgang: VorgangWithEingangResource;
readonly postfachMailListLinkRel = PostfachMailListLinkRel; readonly postfachMailListLinkRel = PostfachMailListLinkRel;
readonly vorgangHeaderLinkRel = VorgangHeaderLinkRel;
} }
<goofy-client-button-with-spinner data-test-id="send-mail-button"
[showSpinner]="isDownloadPdfInProgress | async"
text="download Pdf"
icon="add"
toolTip="Nachrichten als Pdf downloaden"
(clickEmitter)="downloadPdf()">
</goofy-client-button-with-spinner>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { PostfachService } from '@goofy-client/postfach-shared';
import { Mock, mock } from '@goofy-client/test-utils';
import { ButtonWithSpinnerComponent } from '@goofy-client/ui';
import { MockComponent } from 'ng-mocks';
import { PostfachMailPdfButtonContainerComponent } from './postfach-mail-pdf-button-container.component';
describe('PostfachMailPdfButtonContainerComponent', () => {
let component: PostfachMailPdfButtonContainerComponent;
let fixture: ComponentFixture<PostfachMailPdfButtonContainerComponent>;
const postfachService: Mock<PostfachService> = mock(PostfachService);
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [
PostfachMailPdfButtonContainerComponent,
MockComponent(ButtonWithSpinnerComponent)
],
providers: [
{
provide: PostfachService,
useValue: postfachService
}
]
}).compileComponents();
fixture = TestBed.createComponent(
PostfachMailPdfButtonContainerComponent
);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
describe('ngOnInit', () => {
it('should call postfachService', () => {
component.ngOnInit();
expect(postfachService.isDownloadPdfInProgress).toHaveBeenCalled();
})
})
describe('downloadPdf', () => {
it('should call service', () => {
component.downloadPdf();
expect(postfachService.downloadPdf).toHaveBeenCalled();
})
})
});
import { Component, OnInit } from '@angular/core';
import { PostfachService } from '@goofy-client/postfach-shared';
import { Observable } from 'rxjs';
@Component({
selector: 'goofy-client-postfach-mail-pdf-button-container',
templateUrl: './postfach-mail-pdf-button-container.component.html',
styleUrls: ['./postfach-mail-pdf-button-container.component.scss'],
})
export class PostfachMailPdfButtonContainerComponent implements OnInit {
isDownloadPdfInProgress: Observable<boolean>;
constructor(private postfachService: PostfachService) { }
ngOnInit(): void {
this.isDownloadPdfInProgress = this.postfachService.isDownloadPdfInProgress();
}
downloadPdf(): void {
this.postfachService.downloadPdf();
}
}
\ No newline at end of file
<goofy-client-spinner *ngIf="postfachMailListStateResource"> <goofy-client-spinner *ngIf="postfachMailListStateResource">
<goofy-client-postfach-mail <goofy-client-postfach-mail *ngFor="let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST" [attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'"
*ngFor="let postfachMail of postfachMailListStateResource.resource | toEmbeddedResources: postfachMailListLinkRel.POSTFACH_MAIL_LIST"
[postfachMail]="postfachMail"
class="postfach postfach-links-disabled" class="postfach postfach-links-disabled"
[attr.data-test-id]="(postfachMail.subject | convertForDataTest) + '-item'"> [postfachMail]="postfachMail">
</goofy-client-postfach-mail> </goofy-client-postfach-mail>
</goofy-client-spinner> </goofy-client-spinner>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment