admin-wizard.js.es6 958 B

123456789101112131415161718192021222324252627282930313233343536
  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((error) => {
  22. this.set('saving', false);
  23. this.set('error', I18n.t(`admin.wizard.error.${error}`));
  24. Ember.run.later(() => this.set('error', null), 10000);
  25. });
  26. },
  27. remove() {
  28. this.get('model').remove().then(() => {
  29. this.send("refreshAllWizards");
  30. });
  31. }
  32. }
  33. });