invert show default properties (#1858)

* invert show default properties

* fix test
This commit is contained in:
Eugenio Romano 2017-05-05 09:28:07 +02:00 committed by Eugenio Romano
parent fc728676c0
commit b5ebe5bc47
5 changed files with 28 additions and 13 deletions

View File

@ -166,8 +166,8 @@ platformBrowserDynamic().bootstrapModule(AppModule);
| `logoImageUrl` | string | Alfresco logo image | To change the logo image with a customised image |
| `backgroundImageUrl` | string | Alfresco background image | To change the background image with a customised image |
| `fieldsValidation` | { [key: string]: any; }, extra?: { [key: string]: any; } | | Use it to customise the validation rules of the login form |
| `showRememberMe` | boolean | false | Toggle `Remember me` checkbox visibility |
| `showLoginActions` | boolean | false | Toggle extra actions visibility (`Need Help`, `Register`, etc.) |
| `showRememberMe` | boolean | true | Toggle `Remember me` checkbox visibility |
| `showLoginActions` | boolean | true | Toggle extra actions visibility (`Need Help`, `Register`, etc.) |
#### Events

View File

@ -10,7 +10,7 @@
"tslint": "../node_modules/tslint/bin/tslint -c ../config/assets/tslint.json 'src/{,**/}**.ts' 'index.ts' -e '{,**/}**.d.ts'",
"tsc": "../node_modules/typescript/bin/tsc",
"test": "../node_modules/karma/bin/karma start ../config/karma.conf.js --reporters mocha,coverage --single-run --component ng2-alfresco-login",
"test-browser": "concurrently \"../node_modules/karma/bin/karma start ../config/karma.conf.js --reporters kjhtml --component ng2-alfresco-login\"",
"test-browser": "../node_modules/karma/bin/karma start ../config/karma.conf.js --reporters kjhtml --component ng2-alfresco-login",
"coverage": "npm run test && ../node_modules/wsrv/bin/wsrv -o -p 9875 ./coverage/report",
"publish:prod": "npm run test && npm publish"
},

View File

@ -63,18 +63,18 @@
<button type="submit" id="login-button" tabindex="3"
class="center mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored"
data-automation-id="login-button" [disabled]="!form.valid">{{'LOGIN.BUTTON.LOGIN' | translate }}</button>
<div *ngIf="showRememberMe" class="adf-login__remember-me">
<div *ngIf="showRememberMe" class="adf-login__remember-me" id ="login-remember">
<md-checkbox>{{'LOGIN.LABEL.REMEMBER' | translate }}</md-checkbox>
</div>
</div>
<div *ngIf="showLoginActions" class="mdl-card__actions mdl-card--border mdl-card__link">
<div class="mdl-card__actions mdl-card--border mdl-card__link">
<!--FOOTER TEMPLATE-->
<template *ngIf="footerTemplate"
ngFor [ngForOf]="[data]"
[ngForTemplate]="footerTemplate">
</template>
<div class="login-action" *ngIf="!footerTemplate">
<div class="login-action" *ngIf="!footerTemplate && showLoginActions">
<div id="login-action-help" class="login-action-left">
<a href="{{needHelpLink}}">{{'LOGIN.ACTION.HELP' | translate }}</a>
</div>

View File

@ -63,17 +63,15 @@ describe('AlfrescoLogin', () => {
expect(element.querySelector('[for="username"]')).toBeDefined();
expect(element.querySelector('[for="username"]').innerText).toEqual('LOGIN.LABEL.USERNAME');
expect(element.querySelector('#login-remember')).toBeDefined();
expect(element.querySelector('#login-remember').innerText).toContain('LOGIN.LABEL.REMEMBER');
expect(element.querySelector('[for="password"]')).toBeDefined();
expect(element.querySelector('[for="password"]').innerText).toEqual('LOGIN.LABEL.PASSWORD');
expect(element.querySelector('#login-button')).toBeDefined();
expect(element.querySelector('#login-button').innerText).toEqual('LOGIN.BUTTON.LOGIN');
/*
expect(element.querySelector('#login-remember')).toBeDefined();
expect(element.querySelector('#login-remember').innerText).toEqual('LOGIN.LABEL.REMEMBER');
*/
expect(element.querySelector('#login-action-help')).toBeDefined();
expect(element.querySelector('#login-action-help').innerText).toEqual('LOGIN.ACTION.HELP');
@ -89,6 +87,23 @@ describe('AlfrescoLogin', () => {
expect(element.querySelector('input[type="text"]').value).toEqual('');
});
it('should hide remember me if showRememberMe is false', () => {
component.showRememberMe = false;
fixture.detectChanges();
expect(element.querySelector('#login-remember')).toBe(null);
});
it('should hide login actions if showLoginActions is false', () => {
component.showLoginActions = false;
fixture.detectChanges();
expect(element.querySelector('#login-action-help')).toBe(null);
expect(element.querySelector('#login-action-register')).toBe(null);
});
it('should render validation min-length error when the username is just 1 character', () => {
usernameInput.value = '1';
usernameInput.dispatchEvent(new Event('input'));

View File

@ -33,10 +33,10 @@ export class AlfrescoLoginComponent implements OnInit {
isPasswordShow: boolean = false;
@Input()
showRememberMe: boolean = false;
showRememberMe: boolean = true;
@Input()
showLoginActions: boolean = false;
showLoginActions: boolean = true;
@Input()
needHelpLink: string = '';