Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Language Selector #21

Open
wants to merge 1 commit into
base: 1.0.11
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/app/pcdc-header/pcdc-header.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
<span class="daily-chk"> {{ appNameSuffix | uppercase }} </span>
</ion-label>
<ion-buttons slot="end">
<ion-select [(ngModel)]="selectedLanguage" (ionChange)="onLanguageChange()">
<ion-select [(ngModel)]="selectedLanguage" (ionChange)="onLanguageChange()" class="custom-select">
<ion-select-option *ngFor="let language of languages" [value]="language.code">
{{ language.name }}
{{ language.label }}
</ion-select-option>
</ion-select>
<ion-label class="selected-label" onclick="document.querySelector('ion-select').open()"
onmouseover="this.style.cursor='pointer'">
{{ selectedLanguageName }}
</ion-label>
</ion-buttons>
<ion-buttons slot="end">
<ion-menu-button color="light"></ion-menu-button>
Expand Down
3 changes: 3 additions & 0 deletions src/app/pcdc-header/pcdc-header.component.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@

.header-toolbar {
text-align: end;
}
.custom-select{
width: 0;
}
7 changes: 7 additions & 0 deletions src/app/pcdc-header/pcdc-header.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { SettingsService } from '../services/settings.service';
export class PcdcHeaderComponent implements OnInit {
languages = env.languages;
selectedLanguage: string;
selectedLanguageName: string;
test = false;
appName = env.appName;
appNameSuffix = env.appNameSuffix;
Expand All @@ -22,6 +23,9 @@ export class PcdcHeaderComponent implements OnInit {
this.selectedLanguage =
this.settingsService.get('applicationLanguage')?.code ||
translate.defaultLang;
this.selectedLanguageName = this.languages.find(
(l) => l.code === this.selectedLanguage
).name;
translate.use(this.selectedLanguage);
this.test = env.mode === 'dev';
}
Expand All @@ -32,6 +36,9 @@ export class PcdcHeaderComponent implements OnInit {
'applicationLanguage',
this.languages.find((l) => l.code === this.selectedLanguage)
);
this.selectedLanguageName = this.languages.find(
(l) => l.code === this.selectedLanguage
).name;
window.location.reload();
}
closeApp() {
Expand Down