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
|
|
|
|
2015-08-08 02:05:08 +08:00
|
|
|
model(params) {
|
2021-01-19 01:53:45 +08:00
|
|
|
return ajax(
|
|
|
|
`/admin/customize/site_texts/${params.id}?locale=${params.locale}`
|
|
|
|
).then((result) => {
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|