[ADF-1600] Change translation (#2574)

* Change translation

* Add browser test runner to scripts

* Adding option to hide the My Files option

* Add documentation and fix property's name
This commit is contained in:
Popovics András
2017-11-01 09:38:51 +00:00
committed by Eugenio Romano
parent b67ed7e545
commit 092e07c545
19 changed files with 105 additions and 28 deletions

View File

@@ -1,11 +1,14 @@
<div id="site-dropdown-container" class="adf-site-dropdown-container">
<mat-form-field>
<mat-select class="adf-site-dropdown-list-element" id="site-dropdown"
<mat-select
class="adf-site-dropdown-list-element"
id="site-dropdown"
placeholder="{{'DROPDOWN.PLACEHOLDER_LABEL' | translate}}"
floatPlaceholder="never"
data-automation-id="site-my-files-select"
[(ngModel)]="siteSelected"
(ngModelChange)="selectedSite()">
<mat-option id="default_site_option" [value]="DEFAULT_VALUE">{{'DROPDOWN.DEFAULT_OPTION' | translate}}</mat-option>
<mat-option *ngIf="!hideMyFiles" data-automation-id="site-my-files-option" id="default_site_option" [value]="MY_FILES_VALUE">{{'DROPDOWN.MY_FILES_OPTION' | translate}}</mat-option>
<mat-option *ngFor="let site of siteList" [value]="site.guid">
{{ site.title }}
</mat-option>

View File

@@ -89,6 +89,11 @@ describe('DropdownSitesComponent', () => {
describe('Rendering tests', () => {
function openSelectbox() {
const selectBox = debug.query(By.css(('[data-automation-id="site-my-files-select"] .mat-select-trigger')));
selectBox.triggerEventHandler('click', null);
}
beforeEach(() => {
jasmine.Ajax.install();
});
@@ -96,6 +101,7 @@ describe('DropdownSitesComponent', () => {
afterEach(() => {
jasmine.Ajax.uninstall();
fixture.destroy();
TestBed.resetTestingModule();
});
it('Dropdown sites should be renedered', async(() => {
@@ -115,6 +121,31 @@ describe('DropdownSitesComponent', () => {
});
}));
it('should show the "My files" option by default', async(() => {
fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json', responseText: sitesList });
openSelectbox();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(window.document.querySelector('[data-automation-id="site-my-files-option"]')).not.toBeNull();
});
}));
it('should hide the "My files" option if the developer desires that way', async(() => {
component.hideMyFiles = true;
fixture.detectChanges();
jasmine.Ajax.requests.mostRecent().respondWith({ status: 200, contentType: 'json', responseText: sitesList });
openSelectbox();
fixture.whenStable().then(() => {
fixture.detectChanges();
expect(window.document.querySelector('[data-automation-id="site-my-files-option"]')).toBeNull();
});
}));
// todo: something wrong with the test itself
xit('should load sites on init', async(() => {
fixture.detectChanges();

View File

@@ -15,7 +15,7 @@
* limitations under the License.
*/
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { SiteModel, SitesApiService } from 'ng2-alfresco-core';
@Component({
@@ -25,17 +25,19 @@ import { SiteModel, SitesApiService } from 'ng2-alfresco-core';
})
export class DropdownSitesComponent implements OnInit {
@Input()
hideMyFiles: boolean = false;
@Output()
change: EventEmitter<SiteModel> = new EventEmitter();
public DEFAULT_VALUE = 'default';
public MY_FILES_VALUE = 'default';
siteList = [];
public siteSelected: string;
constructor(private sitesService: SitesApiService) {
}
constructor(private sitesService: SitesApiService) {}
ngOnInit() {
this.sitesService.getSites().subscribe((result) => {
@@ -45,7 +47,7 @@ export class DropdownSitesComponent implements OnInit {
selectedSite() {
let siteFound;
if (this.siteSelected === this.DEFAULT_VALUE) {
if (this.siteSelected === this.MY_FILES_VALUE) {
siteFound = new SiteModel();
}else {
siteFound = this.siteList.find( site => site.guid === this.siteSelected);

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Site-Liste",
"DEFAULT_OPTION": "Standard"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Abbrechen",

View File

@@ -33,7 +33,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Site List",
"DEFAULT_OPTION": "Default"
"MY_FILES_OPTION": "My files"
},
"NODE_SELECTOR": {
"CANCEL": "Cancel",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Lista de sitios",
"DEFAULT_OPTION": "Predeterminada"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Cancelar",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Liste des Sites",
"DEFAULT_OPTION": "Par défaut"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Annuler",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Elenco sito",
"DEFAULT_OPTION": "Predefinito"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Annulla",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "サイトリスト",
"DEFAULT_OPTION": "デフォルト"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "キャンセル",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Områdeliste",
"DEFAULT_OPTION": "Standard"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Avbryt",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Lijst met sites",
"DEFAULT_OPTION": "Standaard"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Annuleren",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Lista do Site",
"DEFAULT_OPTION": "Padrão"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Cancelar",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "Список сайтов",
"DEFAULT_OPTION": "По умолчанию"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "Отмена",

View File

@@ -27,7 +27,7 @@
},
"DROPDOWN": {
"PLACEHOLDER_LABEL": "网站列表",
"DEFAULT_OPTION": "默认值"
"MY_FILES_OPTION": ""
},
"NODE_SELECTOR": {
"CANCEL": "取消",

View File

@@ -230,7 +230,7 @@ export class UploadButtonComponent implements OnInit, OnChanges, NodePermissionS
this.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => {
this.error.emit(message);
})
});
}
return acceptableSize;