correctly pick the selected theme based on what is loaded
This commit is contained in:
parent
e865a44b93
commit
f114d63de4
|
@ -1,6 +1,6 @@
|
||||||
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
|
import PreferencesTabController from "discourse/mixins/preferences-tab-controller";
|
||||||
import { default as computed, observes } from "ember-addons/ember-computed-decorators";
|
import { default as computed, observes } from "ember-addons/ember-computed-decorators";
|
||||||
import { listThemes, previewTheme, setLocalTheme } from 'discourse/lib/theme-selector';
|
import { currentThemeKey, listThemes, previewTheme, setLocalTheme } from 'discourse/lib/theme-selector';
|
||||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||||
|
|
||||||
export default Ember.Controller.extend(PreferencesTabController, {
|
export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
|
@ -31,6 +31,11 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
return this.siteSettings.available_locales.split('|').map(s => ({ name: s, value: s }));
|
return this.siteSettings.available_locales.split('|').map(s => ({ name: s, value: s }));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed()
|
||||||
|
themeKey() {
|
||||||
|
return currentThemeKey();
|
||||||
|
},
|
||||||
|
|
||||||
userSelectableThemes: function(){
|
userSelectableThemes: function(){
|
||||||
return listThemes(this.site);
|
return listThemes(this.site);
|
||||||
}.property(),
|
}.property(),
|
||||||
|
@ -40,9 +45,9 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
return themes && themes.length > 1;
|
return themes && themes.length > 1;
|
||||||
},
|
},
|
||||||
|
|
||||||
@observes("model.user_option.theme_key")
|
@observes("themeKey")
|
||||||
themeKeyChanged() {
|
themeKeyChanged() {
|
||||||
let key = this.get("model.user_option.theme_key");
|
let key = this.get("themeKey");
|
||||||
previewTheme(key);
|
previewTheme(key);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -50,12 +55,15 @@ export default Ember.Controller.extend(PreferencesTabController, {
|
||||||
save() {
|
save() {
|
||||||
this.set('saved', false);
|
this.set('saved', false);
|
||||||
const makeThemeDefault = this.get("makeThemeDefault");
|
const makeThemeDefault = this.get("makeThemeDefault");
|
||||||
|
if (makeThemeDefault) {
|
||||||
|
this.set('model.user_option.theme_key', this.get('themeKey'));
|
||||||
|
}
|
||||||
|
|
||||||
return this.get('model').save(this.get('saveAttrNames')).then(() => {
|
return this.get('model').save(this.get('saveAttrNames')).then(() => {
|
||||||
this.set('saved', true);
|
this.set('saved', true);
|
||||||
|
|
||||||
if (!makeThemeDefault) {
|
if (!makeThemeDefault) {
|
||||||
setLocalTheme(this.get('model.user_option.theme_key'), this.get('model.user_option.theme_key_seq'));
|
setLocalTheme(this.get('themeKey'), this.get('model.user_option.theme_key_seq'));
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch(popupAjaxError);
|
}).catch(popupAjaxError);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="control-group theme">
|
<div class="control-group theme">
|
||||||
<label class="control-label">{{i18n 'user.theme'}}</label>
|
<label class="control-label">{{i18n 'user.theme'}}</label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{combo-box content=userSelectableThemes value=model.user_option.theme_key}}
|
{{combo-box content=userSelectableThemes value=themeKey}}
|
||||||
</div>
|
</div>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
{{preference-checkbox labelKey="user.theme_default_on_all_devices" checked=makeThemeDefault}}
|
{{preference-checkbox labelKey="user.theme_default_on_all_devices" checked=makeThemeDefault}}
|
||||||
|
|
Loading…
Reference in New Issue