ADF InfoDrawer the title and tabs label must be localized (#2454)

This commit is contained in:
Maurizio Vitale
2017-10-11 10:10:25 +01:00
committed by Eugenio Romano
parent 6f69f545ec
commit 2e0a6936aa
5 changed files with 61 additions and 6 deletions

View File

@@ -51,13 +51,12 @@
</button>
</div>
<div class="adf-task-details-core-sidebar">
<adf-info-drawer *ngIf="showHeaderContent" title="Activities" class="adf-task-details-core-sidebar-drawer">
<adf-info-drawer *ngIf="showHeaderContent" title="{{ 'TASK_DETAILS.LABELS.INFO_DRAWER_TITLE' | translate }}" class="adf-task-details-core-sidebar-drawer">
<div info-drawer-buttons>
<md-icon (click)="toggleHeaderContent()">clear</md-icon>
</div>
<adf-info-drawer-tab label="Activity">
<adf-info-drawer-tab label="{{ 'TASK_DETAILS.LABELS.INFO_DRAWER_TAB_DETAILS_TITLE' | translate }}">
<div class="assignment-container" *ngIf="showAssignee">
<adf-people-search
(searchPeople)="searchUser($event)"
@@ -85,7 +84,7 @@
</adf-people>
</adf-info-drawer-tab>
<adf-info-drawer-tab label="Details">
<adf-info-drawer-tab label="{{ 'TASK_DETAILS.LABELS.INFO_DRAWER_TAB_ACTIVITY_TITLE' | translate }}">
<md-card *ngIf="showComments">
<md-card-content>
<adf-comments #activiticomments

View File

@@ -9,6 +9,9 @@
},
"TASK_DETAILS": {
"LABELS": {
"INFO_DRAWER_TITLE": "Activities",
"INFO_DRAWER_TAB_ACTIVITY_TITLE": "Activity",
"INFO_DRAWER_TAB_DETAILS_TITLE": "Details",
"ASSIGNEE": "Assignee",
"DUE": "Due",
"FORM": "Form",

View File

@@ -9,6 +9,9 @@
},
"TASK_DETAILS": {
"LABELS": {
"INFO_DRAWER_TITLE": "pippo",
"INFO_DRAWER_TAB_ACTIVITY_TITLE": "Attivita",
"INFO_DRAWER_TAB_DETAILS_TITLE": "Dettagli",
"ASSIGNEE": "Assegnatario",
"DUE": "Scadenza",
"FORM": "Form",

View File

@@ -1,5 +1,5 @@
<adf-info-drawer-layout>
<div *ngIf="title" info-drawer-title>Activities</div>
<div *ngIf="title" info-drawer-title>{{title}}</div>
<ng-content *ngIf="!title" info-drawer-title select="[info-drawer-title]"></ng-content>
<ng-content info-drawer-buttons select="[info-drawer-buttons]"></ng-content>

View File

@@ -15,8 +15,9 @@
* limitations under the License.
*/
import { DebugElement } from '@angular/core';
import { Component, DebugElement } from '@angular/core';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { MaterialModule } from '../../material.module';
import { InfoDrawerLayoutComponent } from './info-drawer-layout.component';
import { InfoDrawerComponent } from './info-drawer.component';
@@ -70,4 +71,53 @@ describe('InfoDrawerComponent', () => {
expect(tabEmitSpy).toHaveBeenCalled();
expect(tabEmitSpy).toHaveBeenCalledWith('DETAILS');
});
it('should render the title', () => {
component.title = 'FakeTitle';
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('FakeTitle');
});
});
@Component({
template: `
<adf-info-drawer>
<div info-drawer-title>Fake Title Custom</div>
</adf-info-drawer>
`
})
class CustomInfoDrawerComponent {
}
describe('Custom InfoDrawer', () => {
let fixture: ComponentFixture<CustomInfoDrawerComponent>;
let component: CustomInfoDrawerComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
InfoDrawerComponent,
InfoDrawerLayoutComponent,
CustomInfoDrawerComponent
],
imports: [
MaterialModule
]
}).compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CustomInfoDrawerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should render the title', () => {
fixture.detectChanges();
let title: any = fixture.debugElement.queryAll(By.css('[info-drawer-title]'));
expect(title.length).toBe(1);
expect(title[0].nativeElement.innerText).toBe('Fake Title Custom');
});
});