2017-04-12 22:52:52 +08:00
|
|
|
import RestAdapter from "discourse/adapters/rest";
|
|
|
|
|
2023-03-17 20:25:05 +08:00
|
|
|
export default class Theme extends RestAdapter {
|
|
|
|
jsonMode = true;
|
2024-04-03 13:10:47 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
basePath() {
|
|
|
|
return "/admin/";
|
2023-03-17 20:25:05 +08:00
|
|
|
}
|
2017-04-12 22:52:52 +08:00
|
|
|
|
|
|
|
afterFindAll(results) {
|
|
|
|
let map = {};
|
2024-03-11 08:42:12 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
results.forEach((theme) => {
|
|
|
|
map[theme.id] = theme;
|
|
|
|
});
|
2024-03-11 08:42:12 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
results.forEach((theme) => {
|
|
|
|
let mapped = theme.get("child_themes") || [];
|
|
|
|
mapped = mapped.map((t) => map[t.id]);
|
|
|
|
theme.set("childThemes", mapped);
|
2019-01-23 17:20:13 +08:00
|
|
|
|
|
|
|
let mappedParents = theme.get("parent_themes") || [];
|
|
|
|
mappedParents = mappedParents.map((t) => map[t.id]);
|
|
|
|
theme.set("parentThemes", mappedParents);
|
2017-04-12 22:52:52 +08:00
|
|
|
});
|
2024-03-11 08:42:12 +08:00
|
|
|
|
2017-04-12 22:52:52 +08:00
|
|
|
return results;
|
2023-03-17 20:25:05 +08:00
|
|
|
}
|
|
|
|
}
|