2019-10-24 00:39:32 +08:00
|
|
|
import Route from "@ember/routing/route";
|
2021-01-19 01:53:45 +08:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
2023-03-15 21:17:51 +08:00
|
|
|
export default class AdminSiteTextEditRoute extends Route {
|
|
|
|
queryParams = {
|
2021-01-19 01:53:45 +08:00
|
|
|
locale: { replace: true },
|
2023-03-15 21:17:51 +08:00
|
|
|
};
|
2021-01-19 01:53:45 +08:00
|
|
|
|
2024-07-06 04:25:42 +08:00
|
|
|
async model(params) {
|
|
|
|
const result = await ajax(
|
2021-01-19 01:53:45 +08:00
|
|
|
`/admin/customize/site_texts/${params.id}?locale=${params.locale}`
|
2024-07-06 04:25:42 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
return this.store.createRecord("site-text", result.site_text);
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
2015-11-24 05:45:05 +08:00
|
|
|
|
|
|
|
setupController(controller, siteText) {
|
2021-01-19 01:53:45 +08:00
|
|
|
const locales = JSON.parse(this.siteSettings.available_locales);
|
|
|
|
|
|
|
|
const localeFullName = locales.find((locale) => {
|
|
|
|
return locale.value === controller.locale;
|
|
|
|
}).name;
|
|
|
|
|
|
|
|
controller.setProperties({
|
|
|
|
siteText,
|
|
|
|
saved: false,
|
2021-11-10 07:31:41 +08:00
|
|
|
localeFullName,
|
2021-01-19 01:53:45 +08:00
|
|
|
});
|
2023-03-15 21:17:51 +08:00
|
|
|
}
|
|
|
|
}
|