admin-wizard.js.es6 743 B

123456789101112131415161718192021222324252627
  1. import CustomWizard from '../models/custom-wizard';
  2. import { ajax } from 'discourse/lib/ajax';
  3. export default Discourse.Route.extend({
  4. model(params) {
  5. if (params.wizard_id === 'new') {
  6. this.set('new', true);
  7. return CustomWizard.create();
  8. }
  9. this.set('new', false);
  10. const wizard = this.modelFor('admin-wizards-custom').findBy('id', params.wizard_id);
  11. if (!wizard) return this.transitionTo('adminWizardsCustom.index');
  12. return wizard;
  13. },
  14. afterModel(model) {
  15. return ajax('/admin/wizards/field-types')
  16. .then((result) => model.set('fieldTypes', result.types));
  17. },
  18. setupController(controller, model) {
  19. controller.set("new", this.get('new'));
  20. controller.set("model", model);
  21. }
  22. });