[ADF-1356] Single configuration of i18n service per project (#2199)

* rework i18n layer init

* fix unit tests

* fix tests

* test fixes

* remove obsolete tests
This commit is contained in:
Denys Vuika
2017-08-11 10:55:52 +01:00
committed by Mario Romano
parent bb53844f92
commit 003b0c133b
85 changed files with 333 additions and 431 deletions

View File

@@ -16,7 +16,7 @@
*/
import { ModuleWithProviders, NgModule } from '@angular/core';
import { CoreModule } from 'ng2-alfresco-core';
import { CoreModule, TRANSLATION_PROVIDER } from 'ng2-alfresco-core';
import { MaterialModule } from './src/material.module';
export * from './src/data/index';
@@ -49,6 +49,16 @@ export function directives() {
MaterialModule
],
declarations: directives(),
providers: [
{
provide: TRANSLATION_PROVIDER,
multi: true,
useValue: {
name: 'ng2-alfresco-datatable',
source: 'assets/ng2-alfresco-datatable'
}
}
],
exports: [
...directives(),
MaterialModule

View File

@@ -207,14 +207,14 @@ describe('DataTable', () => {
});
it('should initialize default adapter', () => {
let table = new DataTableComponent(null, null, null);
let table = new DataTableComponent(null, null);
expect(table.data).toBeUndefined();
table.ngOnChanges({'data': new SimpleChange('123', {}, true)});
expect(table.data).toEqual(jasmine.any(ObjectDataTableAdapter));
});
it('should load data table on onChange', () => {
let table = new DataTableComponent(null, null, null);
let table = new DataTableComponent(null, null);
let data = new ObjectDataTableAdapter([], []);
expect(table.data).toBeUndefined();

View File

@@ -20,7 +20,7 @@ import {
IterableDiffers, OnChanges, Output, SimpleChange, SimpleChanges, TemplateRef
} from '@angular/core';
import { MdCheckboxChange } from '@angular/material';
import { AlfrescoTranslationService, DataColumnListComponent } from 'ng2-alfresco-core';
import { DataColumnListComponent } from 'ng2-alfresco-core';
import { Observable, Observer, Subscription } from 'rxjs/Rx';
import { DataColumn, DataRow, DataRowEvent, DataSorting, DataTableAdapter } from '../../data/datatable-adapter';
import { ObjectDataRow, ObjectDataTableAdapter } from '../../data/object-datatable-adapter';
@@ -106,17 +106,11 @@ export class DataTableComponent implements AfterContentInit, OnChanges, DoCheck
private singleClickStreamSub: Subscription;
private multiClickStreamSub: Subscription;
constructor(translateService: AlfrescoTranslationService,
private elementRef: ElementRef,
differs: IterableDiffers) {
constructor(private elementRef: ElementRef, differs: IterableDiffers) {
if (differs) {
this.differ = differs.find([]).create(null);
}
this.click$ = new Observable<DataRowEvent>(observer => this.clickObserver = observer).share();
if (translateService) {
translateService.addTranslationFolder('ng2-alfresco-datatable', 'assets/ng2-alfresco-datatable');
}
}
ngAfterContentInit() {