0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-15 22:32:54 +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";
2021-02-24 08:43:35 +01:00
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();
},
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
setupController(controller, model) {
2021-02-24 08:43:35 +01:00
const showParams = this.paramsFor("adminWizardsApiShow");
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,
2021-02-24 08:43:35 +01:00
name: api.title,
};
2020-04-22 15:03:18 +02:00
});
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
controller.setProperties({
apiName,
2021-02-24 08:43:35 +01:00
apiList,
});
2020-04-22 15:03:18 +02:00
},
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
actions: {
changeApi(apiName) {
2021-02-24 08:43:35 +01:00
this.controllerFor("adminWizardsApi").set("apiName", apiName);
this.transitionTo("adminWizardsApiShow", apiName);
2020-04-22 15:03:18 +02:00
},
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
afterDestroy() {
2021-02-24 08:43:35 +01:00
this.transitionTo("adminWizardsApi").then(() => this.refresh());
2020-04-22 15:03:18 +02:00
},
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
afterSave(apiName) {
2021-02-24 08:43:35 +01:00
this.refresh().then(() => this.send("changeApi", apiName));
2020-04-22 15:03:18 +02:00
},
2021-02-24 08:43:35 +01:00
2020-04-22 15:03:18 +02:00
createApi() {
2021-02-24 08:43:35 +01:00
this.controllerFor("adminWizardsApi").set("apiName", "create");
this.transitionTo("adminWizardsApiShow", "create");
},
},
});