2019-10-23 12:39:32 -04:00
|
|
|
import Route from "@ember/routing/route";
|
2021-01-18 12:53:45 -05:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
2019-10-23 12:39:32 -04:00
|
|
|
export default Route.extend({
|
2021-01-18 12:53:45 -05:00
|
|
|
queryParams: {
|
|
|
|
locale: { replace: true },
|
|
|
|
},
|
|
|
|
|
2015-08-07 14:05:08 -04:00
|
|
|
model(params) {
|
2021-01-18 12:53:45 -05: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-23 16:45:05 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, siteText) {
|
2021-01-18 12:53:45 -05: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-09 18:31:41 -05:00
|
|
|
localeFullName,
|
2021-01-18 12:53:45 -05:00
|
|
|
});
|
2014-09-24 14:45:35 -04:00
|
|
|
},
|
|
|
|
});
|