Browse Source

Fix step component current objects

Angus McLeod 7 years ago
parent
commit
b8e0291512

+ 13 - 1
assets/javascripts/discourse/components/wizard-custom-step.js.es6

@@ -1,6 +1,18 @@
+import { observes } from 'ember-addons/ember-computed-decorators';
+
 export default Ember.Component.extend({
   classNames: 'wizard-custom-step',
   currentField: null,
   currentAction: null,
-  disableId: Ember.computed.not('step.isNew')
+  disableId: Ember.computed.not('step.isNew'),
+
+  @observes('step')
+  resetCurrentObjects() {
+    const fields = this.get('step.fields');
+    const actions = this.get('step.actions');
+    this.setProperties({
+      currentField: fields.length ? fields[0] : null,
+      currentAction: actions.length ? actions[0] : null
+    });
+  }
 });

+ 1 - 1
assets/javascripts/discourse/templates/components/wizard-custom-field.hbs

@@ -81,7 +81,7 @@
       <div class="wizard-header small">
         {{i18n 'admin.wizard.field.choices_preset.label'}}
       </div>
-      {{combo-box value=field.choices_preset content=presetChoices none='admin.wizard.field.choices_preset.none'}}
+      {{combo-box value=field.choices_preset content=presetChoices none='admin.wizard.none'}}
       <label>{{i18n 'admin.wizard.field.choices_preset.filter'}}</label>
       {{wizard-custom-input inputs=field.choices_filters}}
     </div>