0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-api.js.es6

45 Zeilen
1,1 KiB
Text

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