From b8e02915125c7b6a3c54496789f5a8e99147e5b5 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Thu, 19 Oct 2017 10:17:36 +0800 Subject: [PATCH] Fix step component current objects --- .../discourse/components/wizard-custom-step.js.es6 | 14 +++++++++++++- .../templates/components/wizard-custom-field.hbs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 b/assets/javascripts/discourse/components/wizard-custom-step.js.es6 index b48dadea..f0d9c48f 100644 --- a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 +++ b/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 + }); + } }); diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs index 07e6a826..a3079644 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-field.hbs @@ -81,7 +81,7 @@
{{i18n 'admin.wizard.field.choices_preset.label'}}
- {{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'}} {{wizard-custom-input inputs=field.choices_filters}}