[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,6 +1,6 @@
<div class="container"> <div class="container">
<div class="adf-site-container-style" id="site-container"> <div class="adf-site-container-style" id="site-container">
<adf-sites-dropdown (change)="getSiteContent($event)"> <adf-sites-dropdown (change)="getSiteContent($event)" [hideMyFiles]="false">
</adf-sites-dropdown> </adf-sites-dropdown>
</div> </div>
<div class="document-list-container" fxLayout="row" fxLayoutAlign="start stretch" fxLayoutGap="16px"> <div class="document-list-container" fxLayout="row" fxLayoutAlign="start stretch" fxLayoutGap="16px">

View File

@ -9,6 +9,7 @@ Displays a dropdown menu to show and interact with the sites of the current user
<!-- toc --> <!-- toc -->
- [Basic Usage](#basic-usage) - [Basic Usage](#basic-usage)
* [Properties](#properties)
* [Events](#events) * [Events](#events)
<!-- tocstop --> <!-- tocstop -->
@ -23,6 +24,12 @@ Displays a dropdown menu to show and interact with the sites of the current user
</adf-sites-dropdown> </adf-sites-dropdown>
``` ```
### Properties
| Attribute | Type | Default | Description |
| --- | --- | --- | --- |
| hideMyFiles | boolean | false | Hide the "My Files" option added to the list by default |
### Events ### Events
| Name | Returned Type | Description | | Name | Returned Type | Description |

View File

@ -1,11 +1,14 @@
<div id="site-dropdown-container" class="adf-site-dropdown-container"> <div id="site-dropdown-container" class="adf-site-dropdown-container">
<mat-form-field> <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}}" placeholder="{{'DROPDOWN.PLACEHOLDER_LABEL' | translate}}"
floatPlaceholder="never" floatPlaceholder="never"
data-automation-id="site-my-files-select"
[(ngModel)]="siteSelected" [(ngModel)]="siteSelected"
(ngModelChange)="selectedSite()"> (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"> <mat-option *ngFor="let site of siteList" [value]="site.guid">
{{ site.title }} {{ site.title }}
</mat-option> </mat-option>

View File

@ -89,6 +89,11 @@ describe('DropdownSitesComponent', () => {
describe('Rendering tests', () => { 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(() => { beforeEach(() => {
jasmine.Ajax.install(); jasmine.Ajax.install();
}); });
@ -96,6 +101,7 @@ describe('DropdownSitesComponent', () => {
afterEach(() => { afterEach(() => {
jasmine.Ajax.uninstall(); jasmine.Ajax.uninstall();
fixture.destroy(); fixture.destroy();
TestBed.resetTestingModule();
}); });
it('Dropdown sites should be renedered', async(() => { 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 // todo: something wrong with the test itself
xit('should load sites on init', async(() => { xit('should load sites on init', async(() => {
fixture.detectChanges(); fixture.detectChanges();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -27,7 +27,7 @@
}, },
"DROPDOWN": { "DROPDOWN": {
"PLACEHOLDER_LABEL": "网站列表", "PLACEHOLDER_LABEL": "网站列表",
"DEFAULT_OPTION": "默认值" "MY_FILES_OPTION": ""
}, },
"NODE_SELECTOR": { "NODE_SELECTOR": {
"CANCEL": "取消", "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.translateService.get('FILE_UPLOAD.MESSAGES.EXCEED_MAX_FILE_SIZE', {fileName: file.name}).subscribe((message: string) => {
this.error.emit(message); this.error.emit(message);
}) });
} }
return acceptableSize; return acceptableSize;

View File

@ -145,6 +145,7 @@ The default behaviour of the ***npm-build-all.sh*** install node_modules and bui
| --- | --- | | --- | --- |
| -h or --help | show the help | | -h or --help | show the help |
| -t or --test | Run the tests, this parameter accepts also a wildcard to execute tests for example -t "ng2-alfresco-core" | | -t or --test | Run the tests, this parameter accepts also a wildcard to execute tests for example -t "ng2-alfresco-core" |
| -d or --debug | Run the tests **in browser**, this parameter accepts also a wildcard to execute tests for example -d "ng2-alfresco-core" |
| -c or --clean | clean the ng2_components folders before start from all the temp builds files as node_modules | | -c or --clean | clean the ng2_components folders before start from all the temp builds files as node_modules |
| -gitjsapi | start the demo shell using an alfresco-js-api referenced by commit-ish version of the JS-API | | -gitjsapi | start the demo shell using an alfresco-js-api referenced by commit-ish version of the JS-API |
| -si or --skipinstall | skip the installation of the node_modules | | -si or --skipinstall | skip the installation of the node_modules |
@ -160,7 +161,13 @@ The default behaviour of the ***npm-build-all.sh*** install node_modules and bui
* Build all your local components and run the tests: * Build all your local components and run the tests:
```sh ```sh
./npm-build-all.sh -t or -test ./npm-build-all.sh -t
```
* Build all your local components and run the tests **in BROWSER**:
```sh
./npm-build-all.sh -d
``` ```
* Clean the ng2-components folder node_modules before build * Clean the ng2-components folder node_modules before build

View File

@ -3,6 +3,7 @@ set -f
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
eval RUN_TEST=false eval RUN_TEST=false
eval RUN_TESTBROWSER=false
eval EXEC_FAST_TEST=false eval EXEC_FAST_TEST=false
eval EXEC_CLEAN=false eval EXEC_CLEAN=false
eval EXEC_BUILD=true eval EXEC_BUILD=true
@ -34,13 +35,14 @@ eval projects=( "ng2-alfresco-core"
show_help() { show_help() {
echo "Usage: npm-build-all.sh" echo "Usage: npm-build-all.sh"
echo "" echo ""
echo "-t or -test build all your local component and run also the test on them , this parameter accept also a wildecard to execute test for example -t "ng2-alfresco-core" " echo "-t or --test <pkg> Build your local components and run their tests, this parameter also accept a wildecard to execute test e.g: -t "ng2-alfresco-core"."
echo "-c or -clean the node_modules folder before to start the build" echo "-d or --debug <pkg> Build your local components and run their tests IN THE BROWSER, this parameter also accept a wildecard to execute test e.g: -t "ng2-alfresco-core"."
echo "-si or -skipinstall skip the install node_modules folder before to start the build" echo "-c or --clean Clean the node_modules before starting the build."
echo "-sb or skip build" echo "-si or --skipinstall Skip the install of node_modules before starting the build."
echo "-ft or -fast test build all your local component and run also the test in one single karma-test-shim (high memory consuming and less details)" echo "-sb or --skipbuild Skip the build of ng-components."
echo "-gitjsapi to build all the components against a commit-ish version of the JS-API" echo "-ft or --fasttest Build all your local component and run also the test in one single karma-test-shim (high memory consuming and less details)"
echo "-vjsapi install different version from npm of JS-API defined in the package.json" echo "-gitjsapi <commit-ish> Build all the components against a commit-ish version of the JS-API"
echo "-vjsapi <commit-ish> Install different version from npm of JS-API defined in the package.json"
} }
enable_test(){ enable_test(){
@ -53,11 +55,25 @@ enable_test(){
RUN_TEST=true RUN_TEST=true
} }
enable_testbrowser(){
if [[ ! -z $1 ]]; then
if [[ $1 != "-"* ]]; then
SINGLE_TEST=$1
fi
fi
RUN_TESTBROWSER=true
}
test_project() { test_project() {
echo "====== test project: $1 =====" echo "====== test project: $1 ====="
npm run test -- --component $1 || exit 1 npm run test -- --component $1 || exit 1
} }
debug_project() {
echo "====== debug project: $1 ====="
npm run test-browser -- --component $1 || exit 1
}
enable_fast_test() { enable_fast_test() {
EXEC_FAST_TEST=true EXEC_FAST_TEST=true
} }
@ -100,6 +116,7 @@ while [[ $1 == -* ]]; do
shift; shift;
fi fi
;; ;;
-d|--debug) enable_testbrowser $2; shift; shift;;
-ft|--fasttest) enable_fast_test; shift;; -ft|--fasttest) enable_fast_test; shift;;
-gitjsapi) enable_js_api_git_link $2; shift 2;; -gitjsapi) enable_js_api_git_link $2; shift 2;;
-vjsapi) version_js_api $2; shift 2;; -vjsapi) version_js_api $2; shift 2;;
@ -165,4 +182,14 @@ if $RUN_TEST == true; then
done done
fi fi
if $RUN_TESTBROWSER == true; then
for PACKAGE in ${projects[@]}
do
DESTDIR="$DIR/../ng2-components/"
cd $DESTDIR
if [[ $PACKAGE == $SINGLE_TEST ]]; then
debug_project $PACKAGE
fi
done
fi