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";
|
|
|
|
|
2023-03-15 09:17:51 -04:00
|
|
|
export default class AdminSiteTextEditRoute extends Route {
|
|
|
|
queryParams = {
|
2021-01-18 12:53:45 -05:00
|
|
|
locale: { replace: true },
|
2023-03-15 09:17:51 -04:00
|
|
|
};
|
2021-01-18 12:53:45 -05:00
|
|
|
|
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);
|
|
|
|
});
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
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
|
|
|
});
|
2023-03-15 09:17:51 -04:00
|
|
|
}
|
|
|
|
}
|