mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 07:57:02 +03:00
Bugfix: language selector didn't show current language in green
This commit is contained in:
parent
d1823af111
commit
0b8ec5c664
2 changed files with 9 additions and 37 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
import ko from 'ko';
|
import ko from 'ko';
|
||||||
import { koComputable } from 'External/ko';
|
|
||||||
|
|
||||||
import { convertLangName } from 'Common/Translator';
|
import { convertLangName } from 'Common/Translator';
|
||||||
|
|
||||||
|
|
@ -8,46 +7,19 @@ import { AbstractViewPopup } from 'Knoin/AbstractViews';
|
||||||
export class LanguagesPopupView extends AbstractViewPopup {
|
export class LanguagesPopupView extends AbstractViewPopup {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('Languages');
|
super('Languages');
|
||||||
|
|
||||||
this.fLang = null;
|
this.fLang = null;
|
||||||
this.userLanguage = ko.observable('');
|
this.languages = ko.observableArray();
|
||||||
|
|
||||||
this.langs = ko.observableArray();
|
|
||||||
|
|
||||||
this.languages = koComputable(() => {
|
|
||||||
const userLanguage = this.userLanguage();
|
|
||||||
return this.langs.map(language => ({
|
|
||||||
key: language,
|
|
||||||
user: language === userLanguage,
|
|
||||||
selected: ko.observable(false),
|
|
||||||
fullName: convertLangName(language)
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
|
|
||||||
this.langs.subscribe(() => this.setLanguageSelection());
|
|
||||||
}
|
|
||||||
|
|
||||||
languageTooltipName(language) {
|
|
||||||
return convertLangName(language, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
setLanguageSelection() {
|
|
||||||
const currentLang = this.fLang ? ko.unwrap(this.fLang) : '';
|
|
||||||
this.languages().forEach(item => item.selected(item.key === currentLang));
|
|
||||||
}
|
|
||||||
|
|
||||||
beforeShow() {
|
|
||||||
this.fLang = null;
|
|
||||||
this.userLanguage('');
|
|
||||||
|
|
||||||
this.langs([]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onShow(fLanguage, langs, userLanguage) {
|
onShow(fLanguage, langs, userLanguage) {
|
||||||
this.fLang = fLanguage;
|
this.fLang = fLanguage;
|
||||||
this.userLanguage(userLanguage || '');
|
this.languages(langs.map(language => ({
|
||||||
|
key: language,
|
||||||
this.langs(langs);
|
user: userLanguage === language,
|
||||||
|
selected: fLanguage?.() === language,
|
||||||
|
fullName: convertLangName(language),
|
||||||
|
title: convertLangName(language, true)
|
||||||
|
})));
|
||||||
}
|
}
|
||||||
|
|
||||||
changeLanguage(lang) {
|
changeLanguage(lang) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
</header>
|
</header>
|
||||||
<div class="modal-body" style="min-height: 150px;" data-bind="foreach: languages">
|
<div class="modal-body" style="min-height: 150px;" data-bind="foreach: languages">
|
||||||
<label data-bind="click: function () { $root.changeLanguage(key); }, css: {'selected': selected, 'user': user},
|
<label data-bind="click: function () { $root.changeLanguage(key); }, css: {'selected': selected, 'user': user},
|
||||||
attr: { title: $root.languageTooltipName(key) },
|
attr: { title: title },
|
||||||
text: fullName">
|
text: fullName">
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue