admin-wizard.js.es6 994 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import { default as computed } from 'ember-addons/ember-computed-decorators';
  2. export default Ember.Controller.extend({
  3. @computed('model.id', 'model.name')
  4. wizardUrl(wizardId) {
  5. return window.location.origin + '/w/' + Ember.String.dasherize(wizardId);
  6. },
  7. actions: {
  8. save() {
  9. this.setProperties({
  10. saving: true,
  11. error: null
  12. });
  13. const wizard = this.get('model');
  14. wizard.save().then(() => {
  15. this.set('saving', false);
  16. if (this.get('newWizard')) {
  17. this.send("refreshAllWizards");
  18. } else {
  19. this.send("refreshWizard");
  20. }
  21. }).catch((result) => {
  22. console.log(result)
  23. this.set('saving', false);
  24. this.set('error', I18n.t(`admin.wizard.error.${result.error}`));
  25. Ember.run.later(() => this.set('error', null), 10000);
  26. });
  27. },
  28. remove() {
  29. this.get('model').remove().then(() => {
  30. this.send("refreshAllWizards");
  31. });
  32. }
  33. }
  34. });