2024-11-22 17:11:51 +01:00
|
|
|
import { service } from "@ember/service";
|
2020-03-21 18:30:11 +01:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2021-03-28 11:06:49 +02:00
|
|
|
import CustomWizardApi from "../models/custom-wizard-api";
|
2019-05-30 07:04:34 +02:00
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
export default DiscourseRoute.extend({
|
2023-09-14 15:42:12 +02:00
|
|
|
router: service(),
|
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
model() {
|
|
|
|
return CustomWizardApi.list();
|
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
setupController(controller, model) {
|
2021-03-28 11:06:49 +02:00
|
|
|
const showParams = this.paramsFor("adminWizardsApiShow");
|
2021-04-12 07:44:47 +02:00
|
|
|
const apiName = showParams.name === "create" ? null : showParams.name;
|
2021-03-28 11:06:49 +02:00
|
|
|
const apiList = (model || []).map((api) => {
|
2020-04-22 15:03:18 +02:00
|
|
|
return {
|
|
|
|
id: api.name,
|
2021-03-28 11:06:49 +02:00
|
|
|
name: api.title,
|
|
|
|
};
|
2020-04-22 15:03:18 +02:00
|
|
|
});
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
controller.setProperties({
|
|
|
|
apiName,
|
2021-03-28 11:06:49 +02:00
|
|
|
apiList,
|
|
|
|
});
|
2020-04-22 15:03:18 +02:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
actions: {
|
|
|
|
changeApi(apiName) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.controllerFor("adminWizardsApi").set("apiName", apiName);
|
2023-09-14 15:42:12 +02:00
|
|
|
this.router.transitionTo("adminWizardsApiShow", apiName);
|
2020-04-22 15:03:18 +02:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
afterDestroy() {
|
2023-09-14 15:42:12 +02:00
|
|
|
this.router.transitionTo("adminWizardsApi").then(() => this.refresh());
|
2020-04-22 15:03:18 +02:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
afterSave(apiName) {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.refresh().then(() => this.send("changeApi", apiName));
|
2020-04-22 15:03:18 +02:00
|
|
|
},
|
2021-03-28 11:06:49 +02:00
|
|
|
|
2020-04-22 15:03:18 +02:00
|
|
|
createApi() {
|
2021-03-28 11:06:49 +02:00
|
|
|
this.controllerFor("adminWizardsApi").set("apiName", "create");
|
2023-09-14 15:42:12 +02:00
|
|
|
this.router.transitionTo("adminWizardsApiShow", "create");
|
2021-03-28 11:06:49 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|