[ADF-3126] i18n support for info drawer tabs (#4698)

* [ADF-3126] i18n support for info drawer tabs

* fix tests

* code fixes
This commit is contained in:
Denys Vuika
2019-05-07 17:31:22 +01:00
committed by Eugenio Romano
parent 58f7a2d0ee
commit 0e2e5e35a0
8 changed files with 27 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
<adf-info-drawer-layout>
<div *ngIf="title" info-drawer-title>{{title}}</div>
<div *ngIf="title" info-drawer-title>{{ title | translate }}</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>
@@ -9,12 +9,12 @@
<ng-template #tabLayout>
<mat-tab-group [(selectedIndex)]="selectedIndex" class="adf-info-drawer-tabs" (selectedTabChange)="onTabChange($event)">
<mat-tab *ngFor="let contentBlock of contentBlocks"
[label]="contentBlock.label"
[label]="contentBlock.label | translate"
class="adf-info-drawer-tab">
<ng-template mat-tab-label>
<mat-icon *ngIf="contentBlock.icon">{{ contentBlock.icon }}</mat-icon>
<span *ngIf="contentBlock.label">{{ contentBlock.label }}</span>
<span *ngIf="contentBlock.label">{{ contentBlock.label | translate }}</span>
</ng-template>
<ng-container *ngTemplateOutlet="contentBlock.content"></ng-container>

View File

@@ -23,11 +23,14 @@ import { InfoDrawerComponent } from './info-drawer.component';
import { setupTestBed } from '../testing/setupTestBed';
import { CoreModule } from '../core.module';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { of } from 'rxjs';
import { TranslateService } from '@ngx-translate/core';
describe('InfoDrawerComponent', () => {
let element: HTMLElement;
let component: InfoDrawerComponent;
let fixture: ComponentFixture<InfoDrawerComponent>;
let translateService: TranslateService;
setupTestBed({
imports: [
@@ -37,6 +40,9 @@ describe('InfoDrawerComponent', () => {
});
beforeEach(() => {
translateService = TestBed.get(TranslateService);
spyOn(translateService, 'get').and.callFake((key) => of(key));
fixture = TestBed.createComponent(InfoDrawerComponent);
element = fixture.nativeElement;
component = fixture.componentInstance;
@@ -87,6 +93,7 @@ class CustomInfoDrawerComponent extends InfoDrawerComponent {
describe('Custom InfoDrawer', () => {
let fixture: ComponentFixture<CustomInfoDrawerComponent>;
let component: CustomInfoDrawerComponent;
let translateService: TranslateService;
setupTestBed({
imports: [
@@ -99,6 +106,9 @@ describe('Custom InfoDrawer', () => {
});
beforeEach(() => {
translateService = TestBed.get(TranslateService);
spyOn(translateService, 'get').and.callFake((key) => of(key));
fixture = TestBed.createComponent(CustomInfoDrawerComponent);
fixture.detectChanges();
component = fixture.componentInstance;

View File

@@ -21,6 +21,7 @@ import { MaterialModule } from '../material.module';
import { InfoDrawerLayoutComponent, InfoDrawerTitleDirective, InfoDrawerButtonsDirective, InfoDrawerContentDirective } from './info-drawer-layout.component';
import { InfoDrawerComponent, InfoDrawerTabComponent } from './info-drawer.component';
import { TranslateModule } from '@ngx-translate/core';
export function declarations() {
return [
@@ -36,7 +37,8 @@ export function declarations() {
@NgModule({
imports: [
CommonModule,
MaterialModule
MaterialModule,
TranslateModule.forChild()
],
declarations: declarations(),
exports: declarations()