Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 10:40:28 +01:00
Add add_to_group action
Dieser Commit ist enthalten in:
Ursprung
20f605b899
Commit
f693a2d25a
5 geänderte Dateien mit 55 neuen und 3 gelöschten Zeilen
|
@ -3,7 +3,8 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor
|
|||
const ACTION_TYPES = [
|
||||
{ id: 'create_topic', name: 'Create Topic' },
|
||||
{ id: 'update_profile', name: 'Update Profile' },
|
||||
{ id: 'send_message', name: 'Send Message' }
|
||||
{ id: 'send_message', name: 'Send Message' },
|
||||
{ id: 'add_to_group', name: 'Add to Group' }
|
||||
];
|
||||
|
||||
const PROFILE_FIELDS = [
|
||||
|
@ -26,6 +27,7 @@ export default Ember.Component.extend({
|
|||
createTopic: Ember.computed.equal('action.type', 'create_topic'),
|
||||
updateProfile: Ember.computed.equal('action.type', 'update_profile'),
|
||||
sendMessage: Ember.computed.equal('action.type', 'send_message'),
|
||||
addToGroup: Ember.computed.equal('action.type', 'add_to_group'),
|
||||
disableId: Ember.computed.not('action.isNew'),
|
||||
|
||||
@computed('currentStepId', 'wizard.save_submissions')
|
||||
|
|
|
@ -15,7 +15,13 @@ export default Ember.Component.extend({
|
|||
@computed()
|
||||
presetChoices() {
|
||||
return [
|
||||
{ id: 'categories', name: I18n.t('admin.wizard.field.choices_preset.categories') }
|
||||
{
|
||||
id: 'categories',
|
||||
name: I18n.t('admin.wizard.field.choices_preset.categories')
|
||||
},{
|
||||
id: 'groups',
|
||||
name: I18n.t('admin.wizard.field.choices_preset.groups')
|
||||
}
|
||||
];
|
||||
},
|
||||
});
|
||||
|
|
|
@ -204,3 +204,25 @@
|
|||
allowUserField=true}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{#if addToGroup}}
|
||||
<div class="setting">
|
||||
<div class="setting-label">
|
||||
<h3>{{i18n "admin.wizard.action.add_to_group.group_selection"}}</h3>
|
||||
</div>
|
||||
<div class="setting-value">
|
||||
{{combo-box value=action.group_id
|
||||
content=availableFields
|
||||
nameProperty="label"
|
||||
none='admin.wizard.select_field'
|
||||
isDisabled=action.custom_group_enabled}}
|
||||
<div class="setting-gutter">
|
||||
{{input type='checkbox' checked=action.custom_group_enabled}}
|
||||
<span>{{i18n 'admin.wizard.action.add_to_group.custom_group'}}</span>
|
||||
{{#if action.custom_group_enabled}}
|
||||
{{input value=action.group_id}}
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -87,6 +87,7 @@ en:
|
|||
choices_preset:
|
||||
label: "Preset"
|
||||
categories: "Categories"
|
||||
groups: "Groups"
|
||||
filter: "Preset Filter"
|
||||
choice:
|
||||
value: "Value"
|
||||
|
@ -121,6 +122,11 @@ en:
|
|||
user_fields: "User Fields: "
|
||||
wizard_fields: "Wizard Fields: "
|
||||
placeholder: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}."
|
||||
add_to_group:
|
||||
label: "Add to Group"
|
||||
group: "Group"
|
||||
group_selection: "Group Selection"
|
||||
custom_group: "Custom Group"
|
||||
custom_title: "Custom Title"
|
||||
custom_category:
|
||||
label: "Custom Category"
|
||||
|
|
|
@ -202,9 +202,14 @@ class CustomWizard::Builder
|
|||
end
|
||||
elsif field_template['choices_preset'] && field_template['choices_preset'].length > 0
|
||||
objects = []
|
||||
site = Site.new(Guardian.new(@wizard.user))
|
||||
|
||||
if field_template['choices_preset'] === 'categories'
|
||||
objects = Site.new(Guardian.new(@wizard.user)).categories
|
||||
objects = site.categories
|
||||
end
|
||||
|
||||
if field_template['choices_preset'] === 'groups'
|
||||
objects = site.groups
|
||||
end
|
||||
|
||||
if field_template['choices_filters'] && field_template['choices_filters'].length > 0
|
||||
|
@ -404,6 +409,17 @@ class CustomWizard::Builder
|
|||
end
|
||||
end
|
||||
|
||||
def add_to_group(user, action, data)
|
||||
puts "GROUP NAME: #{data[action['group_id']]}"
|
||||
if group_id = data[action['group_id']]
|
||||
puts "GROUP: #{Group.find(group_id)}"
|
||||
if group = Group.find(group_id)
|
||||
puts "HERE IS THE GROUP: #{group.inspect}"
|
||||
group.add(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def save_submissions(data, final_step)
|
||||
if final_step
|
||||
data['submitted_at'] = Time.now.iso8601
|
||||
|
|
Laden …
In neuem Issue referenzieren