mirror of
https://github.com/discourse/discourse.git
synced 2024-12-16 10:58:23 +08:00
ca28548762
* fill blank space when no theme is selected * animate row's height in themes/components list when selecting, and hide children list * show warning when you move to a different page and have unsaved changes * refactor `adminCustomizeThemes.show` controller * allow collapsing/expanding children lists * fix a bug when adding components to a theme (changed the way it works slightly) * a bunch of other minor things
54 lines
1.3 KiB
JavaScript
54 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")
|
|
.filter(t => t.get("selected"))
|
|
.forEach(t => t.set("selected", false));
|
|
if (theme) {
|
|
theme.set("selected", true);
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
didTransition() {
|
|
scrollTop();
|
|
}
|
|
}
|
|
});
|