refractor: login module (#283)
* Refractor components. * Shift language and footer component to shared module. * Replace mat-icons by font-awesome icons. * Add comments. Fixes #284
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
<mat-form-field id="language-selector">
|
||||
<mat-label>Language</mat-label>
|
||||
<mat-select [formControl]="languageSelector">
|
||||
<mat-option *ngFor="let language of languages" [value]="language">
|
||||
{{ language }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
@@ -0,0 +1,3 @@
|
||||
#language-selector {
|
||||
max-width: 4rem;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LanguageSelectorComponent } from './language-selector.component';
|
||||
|
||||
describe('LanguageSelectorComponent', () => {
|
||||
let component: LanguageSelectorComponent;
|
||||
let fixture: ComponentFixture<LanguageSelectorComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [ LanguageSelectorComponent ]
|
||||
})
|
||||
.compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(LanguageSelectorComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
/** Custom Services */
|
||||
import { I18nService } from 'app/core';
|
||||
|
||||
/**
|
||||
* Language selector component.
|
||||
*
|
||||
* TODO: Decision to be taken on using ngx-translate or angular-internationalization
|
||||
* to provide language support in the application.
|
||||
*/
|
||||
@Component({
|
||||
selector: 'mifosx-language-selector',
|
||||
templateUrl: './language-selector.component.html',
|
||||
styleUrls: ['./language-selector.component.scss']
|
||||
})
|
||||
export class LanguageSelectorComponent implements OnInit {
|
||||
|
||||
/** Language selector form control. */
|
||||
languageSelector = new FormControl();
|
||||
|
||||
/**
|
||||
* Sets the language of the application in the selector on initial setup.
|
||||
* @param {I18nService} i18nService Internationalization Service.
|
||||
*/
|
||||
constructor(private i18nService: I18nService) {
|
||||
this.languageSelector.setValue(this.currentLanguage);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a new language to be used by the application.
|
||||
* @param {string} language New language.
|
||||
*/
|
||||
setLanguage(language: string) {
|
||||
this.i18nService.language = language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current language used by the application.
|
||||
* @returns {string} Current language.
|
||||
*/
|
||||
get currentLanguage(): string {
|
||||
return this.i18nService.language;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the languages supported by the application.
|
||||
* @return {string[]} Supported languages.
|
||||
*/
|
||||
get languages(): string[] {
|
||||
return this.i18nService.supportedLanguages;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user