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";
|
|
|
|
|
2019-10-24 00:39:32 +08:00
|
|
|
export default Route.extend({
|
2021-01-19 01:53:45 +08:00
|
|
|
queryParams: {
|
|
|
|
locale: { replace: true },
|
|
|
|
},
|
|
|
|
|
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);
|
|
|
|
});
|
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
|
|
|
});
|
2014-09-25 02:45:35 +08:00
|
|
|
},
|
|
|
|
});
|