diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 19cc0ba2..8de6cb57 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -21,6 +21,9 @@ export default Ember.Component.extend({ },{ id: 'groups', name: I18n.t('admin.wizard.field.choices_preset.groups') + },{ + id: 'tags', + name: I18n.t('admin.wizard.field.choices_preset.tags') } ]; }, diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 7634dcc5..fdbe87b3 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -99,6 +99,7 @@ en: label: "Preset" categories: "Categories" groups: "Groups" + tags: "Tags" filter: "Preset Filter" choice: value: "Value" diff --git a/lib/builder.rb b/lib/builder.rb index 8533c4c3..9d0bfda7 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -1,3 +1,5 @@ +TagStruct = Struct.new(:id, :name) + class CustomWizard::Builder attr_accessor :wizard, :updater, :submissions @@ -237,7 +239,8 @@ class CustomWizard::Builder end elsif field_template['choices_preset'] && field_template['choices_preset'].length > 0 objects = [] - site = Site.new(Guardian.new(@wizard.user)) + guardian = Guardian.new(@wizard.user) + site = Site.new(guardian) if field_template['choices_preset'] === 'categories' objects = site.categories @@ -247,6 +250,10 @@ class CustomWizard::Builder objects = site.groups end + if field_template['choices_preset'] === 'tags' + objects = Tag.top_tags(guardian: guardian).map { |tag| TagStruct.new(tag,tag) } + end + if field_template['choices_filters'] && field_template['choices_filters'].length > 0 field_template['choices_filters'].each do |f| objects.reject! do |o| @@ -465,7 +472,7 @@ class CustomWizard::Builder ## add validation callback end end - + def add_to_group(user, action, data) if group_id = data[action['group_id']] if group = Group.find(group_id)