2018-08-24 09:30:00 +08:00
|
|
|
import { scrollTop } from "discourse/mixins/scroll-top";
|
2018-08-31 03:23:15 +08:00
|
|
|
import { THEMES, COMPONENTS } from "admin/models/theme";
|
2018-08-24 09:30:00 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
export default Ember.Route.extend({
|
|
|
|
serialize(model) {
|
2018-06-15 23:03:24 +08:00
|
|
|
return { theme_id: model.get("id") };
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
model(params) {
|
2018-06-15 23:03:24 +08:00
|
|
|
const all = this.modelFor("adminCustomizeThemes");
|
|
|
|
const model = all.findBy("id", parseInt(params.theme_id));
|
|
|
|
return model ? model : this.replaceWith("adminCustomizeTheme.index");
|
2017-04-12 22:52:52 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2018-08-24 09:30:00 +08:00
|
|
|
this._super(...arguments);
|
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
const parentController = this.controllerFor("adminCustomizeThemes");
|
2018-08-31 03:23:15 +08:00
|
|
|
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")
|
|
|
|
});
|
2018-08-24 09:30:00 +08:00
|
|
|
|
|
|
|
this.handleHighlight(model);
|
|
|
|
},
|
|
|
|
|
|
|
|
deactivate() {
|
|
|
|
this.handleHighlight();
|
|
|
|
},
|
|
|
|
|
|
|
|
handleHighlight(theme) {
|
2018-09-07 02:56:00 +08:00
|
|
|
this.get("controller.allThemes")
|
|
|
|
.filter(t => t.get("selected"))
|
|
|
|
.forEach(t => t.set("selected", false));
|
2018-08-24 09:30:00 +08:00
|
|
|
if (theme) {
|
2018-09-07 02:56:00 +08:00
|
|
|
theme.set("selected", true);
|
2018-08-24 09:30:00 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
didTransition() {
|
|
|
|
scrollTop();
|
|
|
|
}
|
2017-04-12 22:52:52 +08:00
|
|
|
}
|
|
|
|
});
|