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

OZG-1194 büroklammer bei nachrichten attachments ausrichten

parent 773989ce
No related branches found
No related tags found
No related merge requests found
Showing
with 75 additions and 65 deletions
...@@ -6,6 +6,12 @@ ...@@ -6,6 +6,12 @@
</div> </div>
<goofy-client-postfach-mail-date class="date" [postfachMail]="postfachMail"></goofy-client-postfach-mail-date> <goofy-client-postfach-mail-date class="date" [postfachMail]="postfachMail"></goofy-client-postfach-mail-date>
</div> </div>
<div class="second-row">
<div class="message overflow" data-test-id="mail-text">{{ postfachMail.mailBody }}</div> <div class="message overflow" data-test-id="mail-text">{{ postfachMail.mailBody }}</div>
<mat-icon *ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.ATTACHMENTS) && !onPage" data-test-id="postfach-nachricht-attachment-icon">attach_file</mat-icon>
</div>
</a> </a>
<goofy-client-postfach-nachricht-attachments *ngIf="(postfachMail | hasLink: postfachNachrichtLinkRel.ATTACHMENTS) && onPage" data-test-id="postfach-nachricht-attachments-container"
[postfachNachricht]="postfachMail">
</goofy-client-postfach-nachricht-attachments>
...@@ -37,3 +37,10 @@ a { ...@@ -37,3 +37,10 @@ a {
justify-content: space-between; justify-content: space-between;
width: 100%; width: 100%;
} }
.second-row {
display: flex;
white-space: nowrap;
justify-content: space-between;
width: 100%;
}
...@@ -2,11 +2,14 @@ import { registerLocaleData } from '@angular/common'; ...@@ -2,11 +2,14 @@ import { registerLocaleData } from '@angular/common';
import localeDe from '@angular/common/locales/de'; import localeDe from '@angular/common/locales/de';
import { ComponentFixture, TestBed } from '@angular/core/testing'; import { ComponentFixture, TestBed } from '@angular/core/testing';
import { MatIcon } from '@angular/material/icon'; import { MatIcon } from '@angular/material/icon';
import { FormatDateWithTimePipe } from '@goofy-client/tech-shared'; import { FormatDateWithTimePipe, HasLinkPipe } from '@goofy-client/tech-shared';
import { MockComponent } from 'ng-mocks'; import { MockComponent } from 'ng-mocks';
import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach'; import { createPostfachMailResource } from '../../../../../../../postfach-shared/test/postfach';
import { PostfachMailDateComponent } from '../postfach-mail-date/postfach-mail-date.component'; import { PostfachMailDateComponent } from '../postfach-mail-date/postfach-mail-date.component';
import { IncommingMailComponent } from './incomming-mail.component'; import { IncommingMailComponent } from './incomming-mail.component';
import { getElementFromFixture } from '@goofy-client/test-utils';
import { ON_PAGE, PostfachMailLinkRel } from '@goofy-client/postfach-shared';
import { PostfachNachrichtAttachmentsComponent } from '../postfach-nachricht-attachments/postfach-nachricht-attachments.component';
registerLocaleData(localeDe); registerLocaleData(localeDe);
...@@ -14,13 +17,25 @@ describe('IncommingMailComponent', () => { ...@@ -14,13 +17,25 @@ describe('IncommingMailComponent', () => {
let component: IncommingMailComponent; let component: IncommingMailComponent;
let fixture: ComponentFixture<IncommingMailComponent>; let fixture: ComponentFixture<IncommingMailComponent>;
const attachmentContainer: string = '[data-test-id="postfach-nachricht-attachments-container"]';
const attachmentIcon: string = '[data-test-id="postfach-nachricht-attachment-icon"]';
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ declarations: [
IncommingMailComponent, IncommingMailComponent,
MatIcon, MatIcon,
FormatDateWithTimePipe, FormatDateWithTimePipe,
MockComponent(PostfachMailDateComponent) MockComponent(PostfachMailDateComponent),
HasLinkPipe,
MatIcon,
MockComponent(PostfachNachrichtAttachmentsComponent)
],
providers: [
{
provide: ON_PAGE,
useValue: undefined
}
] ]
}).compileComponents(); }).compileComponents();
}); });
...@@ -35,4 +50,37 @@ describe('IncommingMailComponent', () => { ...@@ -35,4 +50,37 @@ describe('IncommingMailComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('attachments', () => {
it('should not show attachments loaded if exists', () => {
component.onPage = true;
component.postfachMail = createPostfachMailResource();
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentContainer);
expect(element).not.toBeInstanceOf(HTMLElement);
})
it('should be loaded if exists', () => {
component.onPage = true;
component.postfachMail = createPostfachMailResource([PostfachMailLinkRel.ATTACHMENTS]);
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentContainer);
expect(element).toBeInstanceOf(HTMLElement);
})
it('should only show attachment icon on detail', () => {
component.onPage = false;
component.postfachMail = createPostfachMailResource([PostfachMailLinkRel.ATTACHMENTS]);
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentIcon);
expect(element).toBeInstanceOf(HTMLElement);
})
})
}); });
import { Component, Input } from '@angular/core'; import { Component, Inject, Input } from '@angular/core';
import { PostfachMailResource } from '@goofy-client/postfach-shared'; import { ON_PAGE, PostfachMailLinkRel, PostfachMailResource } from '@goofy-client/postfach-shared';
@Component({ @Component({
selector: 'goofy-client-incomming-mail', selector: 'goofy-client-incomming-mail',
...@@ -8,5 +8,9 @@ import { PostfachMailResource } from '@goofy-client/postfach-shared'; ...@@ -8,5 +8,9 @@ import { PostfachMailResource } from '@goofy-client/postfach-shared';
}) })
export class IncommingMailComponent { export class IncommingMailComponent {
readonly postfachNachrichtLinkRel = PostfachMailLinkRel;
constructor(@Inject(ON_PAGE) public onPage: boolean) {}
@Input() postfachMail: PostfachMailResource; @Input() postfachMail: PostfachMailResource;
} }
<goofy-client-incomming-mail *ngIf="isIncomingMail" [postfachMail]="postfachMail"></goofy-client-incomming-mail> <goofy-client-incomming-mail *ngIf="isIncomingMail" [postfachMail]="postfachMail"></goofy-client-incomming-mail>
<goofy-client-outgoing-mail *ngIf="!isIncomingMail" [postfachMail]="postfachMail"></goofy-client-outgoing-mail> <goofy-client-outgoing-mail *ngIf="!isIncomingMail" [postfachMail]="postfachMail"></goofy-client-outgoing-mail>
<ng-container *ngIf="onPage; else icon">
<goofy-client-postfach-nachricht-attachments *ngIf="postfachMail | hasLink: postfachNachrichtLinkRel.ATTACHMENTS" data-test-id="postfach-nachricht-attachments-container"
[postfachNachricht]="postfachMail">
</goofy-client-postfach-nachricht-attachments>
</ng-container>
<ng-template #icon>
<mat-icon data-test-id="postfach-nachricht-attachment-icon">attach_file</mat-icon>
</ng-template>
\ No newline at end of file
...@@ -14,24 +14,12 @@ describe('PostfachMailComponent', () => { ...@@ -14,24 +14,12 @@ describe('PostfachMailComponent', () => {
let component: PostfachMailComponent; let component: PostfachMailComponent;
let fixture: ComponentFixture<PostfachMailComponent>; let fixture: ComponentFixture<PostfachMailComponent>;
const attachmentContainer: string = '[data-test-id="postfach-nachricht-attachments-container"]';
const attachmentIcon: string = '[data-test-id="postfach-nachricht-attachment-icon"]';
beforeEach(async () => { beforeEach(async () => {
await TestBed.configureTestingModule({ await TestBed.configureTestingModule({
declarations: [ declarations: [
PostfachMailComponent, PostfachMailComponent,
HasLinkPipe,
MatIcon,
MockComponent(IncommingMailComponent), MockComponent(IncommingMailComponent),
MockComponent(OutgoingMailComponent), MockComponent(OutgoingMailComponent)
MockComponent(PostfachNachrichtAttachmentsComponent)
],
providers: [
{
provide: ON_PAGE,
useValue: undefined
}
] ]
}).compileComponents(); }).compileComponents();
}); });
...@@ -46,36 +34,4 @@ describe('PostfachMailComponent', () => { ...@@ -46,36 +34,4 @@ describe('PostfachMailComponent', () => {
it('should create', () => { it('should create', () => {
expect(component).toBeTruthy(); expect(component).toBeTruthy();
}); });
describe('attachments', () => {
it('should not show attachments loaded if exists', () => {
component.onPage = true;
component.postfachMail = createPostfachMailResource();
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentContainer);
expect(element).not.toBeInstanceOf(HTMLElement);
})
it('should be loaded if exists', () => {
component.onPage = true;
component.postfachMail = createPostfachMailResource([PostfachMailLinkRel.ATTACHMENTS]);
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentContainer);
expect(element).toBeInstanceOf(HTMLElement);
})
it('should only show attachment icon on detail', () => {
component.onPage = false;
fixture.detectChanges();
const element = getElementFromFixture(fixture, attachmentIcon);
expect(element).toBeInstanceOf(HTMLElement);
})
})
}); });
...@@ -10,9 +10,7 @@ export class PostfachMailComponent { ...@@ -10,9 +10,7 @@ export class PostfachMailComponent {
@Input() postfachMail: PostfachMailResource; @Input() postfachMail: PostfachMailResource;
readonly postfachNachrichtLinkRel = PostfachMailLinkRel; constructor() { }
constructor(@Inject(ON_PAGE) public onPage: boolean) { }
get isIncomingMail(): boolean { get isIncomingMail(): boolean {
return isIncomingMail(this.postfachMail); return isIncomingMail(this.postfachMail);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment