From b81685e1d1d33ca379b846cc477d8fa2c3c29dd5 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Tue, 24 Mar 2020 21:14:42 +1100 Subject: [PATCH] Bugfixes --- .../components/wizard-custom-input-selector.js.es6 | 2 -- .../discourse/components/wizard-custom-input.js.es6 | 6 +++--- .../discourse/templates/components/wizard-custom-action.hbs | 2 +- lib/custom_wizard/builder.rb | 5 +---- 4 files changed, 5 insertions(+), 10 deletions(-) diff --git a/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 b/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 index 7c1067aa..abcef1fa 100644 --- a/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-input-selector.js.es6 @@ -51,8 +51,6 @@ export default Ember.Component.extend({ const types = [this.selectorType, this.inputType]; - console.log('running', types, option) - return option.split(',').filter(o => types.indexOf(o) !== -1).length }, diff --git a/assets/javascripts/discourse/components/wizard-custom-input.js.es6 b/assets/javascripts/discourse/components/wizard-custom-input.js.es6 index 0858fb7c..1dc54a8e 100644 --- a/assets/javascripts/discourse/components/wizard-custom-input.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-input.js.es6 @@ -7,7 +7,7 @@ import { default as discourseComputed, on } from 'discourse-common/utils/decorators'; -import { computed } from "@ember/object"; +import { computed, set } from "@ember/object"; import { alias } from "@ember/object/computed"; export default Ember.Component.extend({ @@ -48,7 +48,7 @@ export default Ember.Component.extend({ const pairs = this.get('input.pairs'); const pairCount = pairs.length + 1; - pairs.forEach(p => (p.set('pairCount', pairCount))); + pairs.forEach(p => (set(p, 'pairCount', pairCount))); pairs.pushObject( newPair(Object.assign( @@ -65,7 +65,7 @@ export default Ember.Component.extend({ removePair(pair) { const pairs = this.get('input.pairs'); const pairCount = pairs.length - 1; - pairs.forEach(p => (p.set('pairCount', pairCount))); + pairs.forEach(p => (set(p, 'pairCount', pairCount))); pairs.removeObject(pair); } } diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs index 7f6085de..958a53c0 100644 --- a/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-custom-action.hbs @@ -279,7 +279,7 @@ {{/if}} {{#if addToGroup}} -
+

{{i18n "admin.wizard.action.add_to_group.group"}}

diff --git a/lib/custom_wizard/builder.rb b/lib/custom_wizard/builder.rb index 4f972e83..4c746166 100644 --- a/lib/custom_wizard/builder.rb +++ b/lib/custom_wizard/builder.rb @@ -339,7 +339,6 @@ class CustomWizard::Builder end def get_user_field(value, opts = {}) - puts "GETTING USER FIELD: #{value.inspect}" if value.include?('user_field_') UserCustomField.where(user_id: @wizard.user.id, name: value).pluck(:value).first elsif UserProfile.column_names.include? value @@ -617,9 +616,7 @@ class CustomWizard::Builder def add_to_group(user, action, data) groups = get_output(action['inputs'], multiple: true, data: data) - groups = groups.reduce([]) do |result, g| - g = g.first if g.is_a?(Array) - + groups = groups.flatten.reduce([]) do |result, g| begin result.push(Integer(g)) rescue ArgumentError