mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-19 17:14:57 +00:00
parent
866c3f91a1
commit
2a257f7b62
@ -29,6 +29,7 @@
|
|||||||
class="center mdl-textfield mdl-js-textfield mdl-textfield--floating-label ">
|
class="center mdl-textfield mdl-js-textfield mdl-textfield--floating-label ">
|
||||||
<label for="username" class="mdl-textfield__label">{{'LOGIN.LABEL.USERNAME' | translate }}</label>
|
<label for="username" class="mdl-textfield__label">{{'LOGIN.LABEL.USERNAME' | translate }}</label>
|
||||||
<input
|
<input
|
||||||
|
(blur)="trimUsername($event)"
|
||||||
type="text"
|
type="text"
|
||||||
class="mdl-textfield__input"
|
class="mdl-textfield__input"
|
||||||
id="username"
|
id="username"
|
||||||
|
@ -139,6 +139,16 @@ describe('AlfrescoLogin', () => {
|
|||||||
expect(element.querySelector('#password-required').innerText).toEqual('LOGIN.MESSAGES.PASSWORD-REQUIRED');
|
expect(element.querySelector('#password-required').innerText).toEqual('LOGIN.MESSAGES.PASSWORD-REQUIRED');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should trim the username value', () => {
|
||||||
|
usernameInput.value = 'username ';
|
||||||
|
component.form.controls.password.markAsDirty();
|
||||||
|
usernameInput.dispatchEvent(new Event('blur'));
|
||||||
|
|
||||||
|
fixture.detectChanges();
|
||||||
|
|
||||||
|
expect(usernameInput.value).toEqual('username');
|
||||||
|
});
|
||||||
|
|
||||||
it('should render no validation errors when the username and password are filled', () => {
|
it('should render no validation errors when the username and password are filled', () => {
|
||||||
usernameInput.value = 'fake-username';
|
usernameInput.value = 'fake-username';
|
||||||
passwordInput.value = 'fake-password';
|
passwordInput.value = 'fake-password';
|
||||||
|
@ -26,7 +26,8 @@ declare let componentHandler: any;
|
|||||||
selector: 'alfresco-login',
|
selector: 'alfresco-login',
|
||||||
moduleId: module.id,
|
moduleId: module.id,
|
||||||
templateUrl: './alfresco-login.component.html',
|
templateUrl: './alfresco-login.component.html',
|
||||||
styleUrls: ['./alfresco-login.component.css']
|
styleUrls: ['./alfresco-login.component.css'],
|
||||||
|
host: {'(blur)': 'onBlur($event)'}
|
||||||
})
|
})
|
||||||
export class AlfrescoLoginComponent implements OnInit {
|
export class AlfrescoLoginComponent implements OnInit {
|
||||||
|
|
||||||
@ -130,7 +131,7 @@ export class AlfrescoLoginComponent implements OnInit {
|
|||||||
if (args.defaultPrevented) {
|
if (args.defaultPrevented) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this.performeLogin(values);
|
this.performLogin(values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +162,7 @@ export class AlfrescoLoginComponent implements OnInit {
|
|||||||
* Performe the login service
|
* Performe the login service
|
||||||
* @param values
|
* @param values
|
||||||
*/
|
*/
|
||||||
private performeLogin(values: any) {
|
private performLogin(values: any) {
|
||||||
this.authService.login(values.username, values.password)
|
this.authService.login(values.username, values.password)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
(token: any) => {
|
(token: any) => {
|
||||||
@ -266,6 +267,13 @@ export class AlfrescoLoginComponent implements OnInit {
|
|||||||
return !field.valid && field.dirty && !field.pristine;
|
return !field.valid && field.dirty && !field.pristine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim username
|
||||||
|
*/
|
||||||
|
trimUsername(event: any) {
|
||||||
|
event.target.value = event.target.value.trim();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default formError values
|
* Default formError values
|
||||||
*/
|
*/
|
||||||
@ -299,7 +307,7 @@ export class AlfrescoLoginComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.translateService.get('LOGIN.MESSAGES.USERNAME-MIN', {minLength: this.minLength}).subscribe((res: string) => {
|
this.translateService.get('LOGIN.MESSAGES.USERNAME-MIN', {minLength: this.minLength}).subscribe((res: string) => {
|
||||||
this._message['username']['minlength'] = res;
|
this._message['username']['minlength'] = res;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user