discourse/app/assets/javascripts/admin/routes/admin-customize-themes-show.js.es6
2018-09-17 09:49:53 +10:00

52 lines
1.3 KiB
JavaScript

import { scrollTop } from "discourse/mixins/scroll-top";
import { THEMES, COMPONENTS } from "admin/models/theme";
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);
const parentController = this.controllerFor("adminCustomizeThemes");
parentController.setProperties({
editingTheme: false,
currentTab: model.get("component") ? COMPONENTS : THEMES
});
controller.setProperties({
model: model,
parentController: parentController,
allThemes: parentController.get("model"),
colorSchemeId: model.get("color_scheme_id"),
colorSchemes: parentController.get("model.extras.color_schemes")
});
this.handleHighlight(model);
},
deactivate() {
this.handleHighlight();
},
handleHighlight(theme) {
this.get("controller.allThemes").forEach(t => t.set("active", false));
if (theme) {
theme.set("active", true);
}
},
actions: {
didTransition() {
scrollTop();
}
}
});