mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 17:45:13 +08:00
e0cc29d658
* FEATURE: themes and components split * two seperate methods to switch theme type * use strict equality operator
49 lines
1.1 KiB
JavaScript
49 lines
1.1 KiB
JavaScript
import { scrollTop } from "discourse/mixins/scroll-top";
|
|
|
|
export default Ember.Route.extend({
|
|
serialize(model) {
|
|
return { theme_id: model.get("id") };
|
|
},
|
|
|
|
model(params) {
|
|
const all = this.modelFor("adminCustomizeThemes");
|
|
const model = all.findBy("id", parseInt(params.theme_id));
|
|
return model ? model : this.replaceWith("adminCustomizeTheme.index");
|
|
},
|
|
|
|
setupController(controller, model) {
|
|
this._super(...arguments);
|
|
|
|
controller.set("model", model);
|
|
|
|
const parentController = this.controllerFor("adminCustomizeThemes");
|
|
parentController.set("editingTheme", false);
|
|
controller.set("allThemes", parentController.get("model"));
|
|
|
|
this.handleHighlight(model);
|
|
|
|
controller.set(
|
|
"colorSchemes",
|
|
parentController.get("model.extras.color_schemes")
|
|
);
|
|
controller.set("colorSchemeId", model.get("color_scheme_id"));
|
|
},
|
|
|
|
deactivate() {
|
|
this.handleHighlight();
|
|
},
|
|
|
|
handleHighlight(theme) {
|
|
this.get("controller.allThemes").forEach(t => t.set("active", false));
|
|
if (theme) {
|
|
theme.set("active", true);
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
didTransition() {
|
|
scrollTop();
|
|
}
|
|
}
|
|
});
|