mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-09 18:03:21 +00:00
[ADF-1772] fix for application name title translation (#2572)
* fix for ADF-1772 Enabling translation for application-list-component title * [ADF-1772] fix translation for default application name added unit tests for checking this fix
This commit is contained in:
committed by
Eugenio Romano
parent
aa634e6119
commit
b1d1976f18
@@ -2,7 +2,7 @@
|
|||||||
<mat-list *ngIf="isList()" class="adf-app-list">
|
<mat-list *ngIf="isList()" class="adf-app-list">
|
||||||
<mat-list-item class="adf-app-list-item" (click)="selectApp(app)" (keyup.enter)="selectApp(app)" *ngFor="let app of appList" tabindex="0" role="button" title="{{app.name}}">
|
<mat-list-item class="adf-app-list-item" (click)="selectApp(app)" (keyup.enter)="selectApp(app)" *ngFor="let app of appList" tabindex="0" role="button" title="{{app.name}}">
|
||||||
<mat-icon matListIcon>touch_app</mat-icon>
|
<mat-icon matListIcon>touch_app</mat-icon>
|
||||||
<span matLine>{{app.name}}</span>
|
<span matLine>{{getAppName(app) | async}}</span>
|
||||||
</mat-list-item>
|
</mat-list-item>
|
||||||
</mat-list>
|
</mat-list>
|
||||||
<div fxLayout="row wrap" *ngIf="isGrid()" class="adf-app-listgrid">
|
<div fxLayout="row wrap" *ngIf="isGrid()" class="adf-app-listgrid">
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
fxLayout="column"
|
fxLayout="column"
|
||||||
role="button"
|
role="button"
|
||||||
class="adf-app-listgrid-item-card"
|
class="adf-app-listgrid-item-card"
|
||||||
title="{{app.name}}"
|
title="{{getAppName(app) | async}}"
|
||||||
[ngClass]="[getTheme(app)]"
|
[ngClass]="[getTheme(app)]"
|
||||||
(click)="selectApp(app)"
|
(click)="selectApp(app)"
|
||||||
(keyup.enter)="selectApp(app)">
|
(keyup.enter)="selectApp(app)">
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
<mat-icon class="adf-app-listgrid-item-card-logo-icon">{{getBackgroundIcon(app)}}</mat-icon>
|
<mat-icon class="adf-app-listgrid-item-card-logo-icon">{{getBackgroundIcon(app)}}</mat-icon>
|
||||||
</div>
|
</div>
|
||||||
<div mat-card-title class="adf-app-listgrid-item-card-title">
|
<div mat-card-title class="adf-app-listgrid-item-card-title">
|
||||||
<h1>{{app.name | translate}}</h1>
|
<h1>{{getAppName(app) | async}}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div mat-card-subtitle class="adf-app-listgrid-item-card-subtitle" fxFlex="1 0 auto">
|
<div mat-card-subtitle class="adf-app-listgrid-item-card-subtitle" fxFlex="1 0 auto">
|
||||||
<p>{{app.description}}</p>
|
<p>{{app.description}}</p>
|
||||||
|
|||||||
@@ -129,6 +129,30 @@ describe('AppsListComponent', () => {
|
|||||||
expect(emitSpy).toHaveBeenCalled();
|
expect(emitSpy).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('intenationalization', () => {
|
||||||
|
|
||||||
|
fit('should provide a translation for the default application name, when app name is not provided', () => {
|
||||||
|
const appDataMock = {
|
||||||
|
defaultAppId: 'tasks',
|
||||||
|
name: null
|
||||||
|
};
|
||||||
|
component.getAppName(appDataMock).subscribe((name) => {
|
||||||
|
expect(name).toBe('ADF_TASK_LIST.APPS.TASK_APP_NAME');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
fit('should provide the application name, when it exists', () => {
|
||||||
|
const appDataMock = {
|
||||||
|
defaultAppId: 'uiu',
|
||||||
|
name: 'the-name'
|
||||||
|
};
|
||||||
|
|
||||||
|
component.getAppName(appDataMock).subscribe((name) => {
|
||||||
|
expect(name).toBe(appDataMock.name);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('layout', () => {
|
describe('layout', () => {
|
||||||
|
|
||||||
it('should display a grid by default', () => {
|
it('should display a grid by default', () => {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { AppsProcessService } from 'ng2-alfresco-core';
|
import { AppsProcessService, TranslationService } from 'ng2-alfresco-core';
|
||||||
import { Observable } from 'rxjs/Observable';
|
import { Observable } from 'rxjs/Observable';
|
||||||
import { Observer } from 'rxjs/Observer';
|
import { Observer } from 'rxjs/Observer';
|
||||||
import { AppDefinitionRepresentationModel } from '../models/filter.model';
|
import { AppDefinitionRepresentationModel } from '../models/filter.model';
|
||||||
@@ -60,7 +60,9 @@ export class AppsListComponent implements OnInit {
|
|||||||
|
|
||||||
private iconsMDL: IconModel;
|
private iconsMDL: IconModel;
|
||||||
|
|
||||||
constructor(private appsProcessService: AppsProcessService) {
|
constructor(
|
||||||
|
private appsProcessService: AppsProcessService,
|
||||||
|
private translationService: TranslationService) {
|
||||||
this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share();
|
this.apps$ = new Observable<AppDefinitionRepresentationModel>(observer => this.appsObserver = observer).share();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,11 +79,11 @@ export class AppsListComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private load() {
|
private load() {
|
||||||
this.appsProcessService.getDeployedApplications().subscribe(
|
this.appsProcessService.getDeployedApplications()
|
||||||
|
.subscribe(
|
||||||
(res: AppDefinitionRepresentationModel[]) => {
|
(res: AppDefinitionRepresentationModel[]) => {
|
||||||
this.filterApps(res).forEach((app: AppDefinitionRepresentationModel) => {
|
this.filterApps(res).forEach((app: AppDefinitionRepresentationModel) => {
|
||||||
if (app.defaultAppId === AppsListComponent.DEFAULT_TASKS_APP) {
|
if (this.isDefaultApp(app)) {
|
||||||
app.name = AppsListComponent.DEFAULT_TASKS_APP_NAME;
|
|
||||||
app.theme = AppsListComponent.DEFAULT_TASKS_APP_THEME;
|
app.theme = AppsListComponent.DEFAULT_TASKS_APP_THEME;
|
||||||
app.icon = AppsListComponent.DEFAULT_TASKS_APP_ICON;
|
app.icon = AppsListComponent.DEFAULT_TASKS_APP_ICON;
|
||||||
this.appsObserver.next(app);
|
this.appsObserver.next(app);
|
||||||
@@ -96,6 +98,16 @@ export class AppsListComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isDefaultApp(app) {
|
||||||
|
return app.defaultAppId === AppsListComponent.DEFAULT_TASKS_APP;
|
||||||
|
}
|
||||||
|
|
||||||
|
getAppName(app) {
|
||||||
|
return this.isDefaultApp(app)
|
||||||
|
? this.translationService.get(AppsListComponent.DEFAULT_TASKS_APP_NAME)
|
||||||
|
: Observable.of(app.name);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass the selected app as next
|
* Pass the selected app as next
|
||||||
* @param app
|
* @param app
|
||||||
|
|||||||
Reference in New Issue
Block a user