2020-03-21 18:30:11 +01:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2020-04-22 15:03:18 +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({
|
2020-04-22 15:03:18 +02:00
|
|
|
model() {
|
|
|
|
return CustomWizardApi.list();
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
const showParams = this.paramsFor('adminWizardsApiShow');
|
|
|
|
const apiName = showParams.name == 'create' ? null : showParams.name;
|
|
|
|
const apiList = (model || []).map(api => {
|
|
|
|
return {
|
|
|
|
id: api.name,
|
|
|
|
name: api.title
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
controller.setProperties({
|
|
|
|
apiName,
|
|
|
|
apiList
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
changeApi(apiName) {
|
|
|
|
this.controllerFor('adminWizardsApi').set('apiName', apiName);
|
|
|
|
this.transitionTo('adminWizardsApiShow', apiName);
|
|
|
|
},
|
|
|
|
|
|
|
|
afterDestroy() {
|
|
|
|
this.transitionTo('adminWizardsApi').then(() => this.refresh());
|
|
|
|
},
|
|
|
|
|
|
|
|
afterSave(apiName) {
|
|
|
|
this.refresh().then(() => this.send('changeApi', apiName));
|
|
|
|
},
|
|
|
|
|
|
|
|
createApi() {
|
|
|
|
this.controllerFor('adminWizardsApi').set('apiName', 'create');
|
|
|
|
this.transitionTo('adminWizardsApiShow', 'create');
|
|
|
|
}
|
2019-05-30 07:04:34 +02:00
|
|
|
}
|
2020-04-22 15:03:18 +02:00
|
|
|
|
2020-04-13 14:17:22 +02:00
|
|
|
});
|