discourse/app/assets/javascripts/admin/adapters/theme.js.es6

27 lines
630 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import RestAdapter from "discourse/adapters/rest";
export default RestAdapter.extend({
basePath() {
return "/admin/";
},
afterFindAll(results) {
let map = {};
2018-06-15 23:03:24 +08:00
results.forEach(theme => {
map[theme.id] = theme;
});
results.forEach(theme => {
let mapped = theme.get("child_themes") || [];
mapped = mapped.map(t => map[t.id]);
theme.set("childThemes", mapped);
let mappedParents = theme.get("parent_themes") || [];
mappedParents = mappedParents.map(t => map[t.id]);
theme.set("parentThemes", mappedParents);
});
return results;
},
jsonMode: true
});