Complete new group category actions
Dieser Commit ist enthalten in:
Ursprung
aa380e2d6c
Commit
1e4348b67a
6 geänderte Dateien mit 98 neuen und 25 gelöschten Zeilen
|
@ -171,6 +171,8 @@ const action = {
|
|||
full_name: null,
|
||||
title: null,
|
||||
bio_raw: null,
|
||||
owner_usernames: null,
|
||||
usernames: null,
|
||||
grant_trust_level: null,
|
||||
mentionable_level: null,
|
||||
messageable_level: null,
|
||||
|
@ -195,7 +197,16 @@ const action = {
|
|||
'color',
|
||||
'text_color',
|
||||
'parent_category_id',
|
||||
'permittions'
|
||||
'permissions',
|
||||
'full_name',
|
||||
'bio_raw',
|
||||
'owner_usernames',
|
||||
'usernames',
|
||||
'grant_trust_level',
|
||||
'mentionable_level',
|
||||
'messageable_level',
|
||||
'visibility_level',
|
||||
'members_visibility_level'
|
||||
],
|
||||
advanced: [
|
||||
'code',
|
||||
|
|
|
@ -413,6 +413,44 @@
|
|||
)}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.action.create_group.owner_usernames"}}</label>
|
||||
</div>
|
||||
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=action.owner_usernames
|
||||
property='owner_usernames'
|
||||
onUpdate=(action 'mappedFieldUpdated')
|
||||
options=(hash
|
||||
textSelection=true
|
||||
wizardFieldSelection=true
|
||||
userFieldSelection=true
|
||||
userSelection='output'
|
||||
context='action'
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.action.create_group.usernames"}}</label>
|
||||
</div>
|
||||
|
||||
<div class="setting-value">
|
||||
{{wizard-mapper
|
||||
inputs=action.usernames
|
||||
property='usernames'
|
||||
onUpdate=(action 'mappedFieldUpdated')
|
||||
options=(hash
|
||||
textSelection=true
|
||||
wizardFieldSelection=true
|
||||
userFieldSelection=true
|
||||
userSelection='output'
|
||||
context='action'
|
||||
)}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="setting full field-mapper-setting">
|
||||
<div class="setting-label">
|
||||
<label>{{i18n "admin.wizard.action.create_group.grant_trust_level"}}</label>
|
||||
|
|
|
@ -255,6 +255,8 @@ en:
|
|||
full_name: Full Name
|
||||
title: Title
|
||||
bio_raw: About
|
||||
owner_usernames: Owners
|
||||
usernames: Members
|
||||
grant_trust_level: Automatic Trust Level
|
||||
mentionable_level: Mentionable Level
|
||||
messageable_level: Messageable Level
|
||||
|
|
|
@ -138,9 +138,10 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
|||
parent_category_id: mapped_params,
|
||||
permissions: mapped_params,
|
||||
full_name: mapped_params,
|
||||
bio_raw: mapped_params,
|
||||
title: mapped_params,
|
||||
bio_raw: mapped_params,
|
||||
usernames: mapped_params,
|
||||
owner_usernames: mapped_params,
|
||||
grant_trust_level: mapped_params,
|
||||
mentionable_level: mapped_params,
|
||||
messageable_level: mapped_params,
|
||||
|
|
|
@ -281,12 +281,12 @@ class CustomWizard::Action
|
|||
|
||||
group =
|
||||
begin
|
||||
Group.new(new_group_params.merge(user: user))
|
||||
Group.new(new_group_params)
|
||||
rescue ArgumentError => e
|
||||
raise Discourse::InvalidParameters, "Invalid group params"
|
||||
end
|
||||
|
||||
if group.update(new_group_params)
|
||||
|
||||
if group.save
|
||||
GroupActionLogger.new(user, group).log_change_group_settings
|
||||
log_success("Group created", group.name)
|
||||
else
|
||||
|
@ -395,18 +395,26 @@ class CustomWizard::Action
|
|||
name
|
||||
full_name
|
||||
title
|
||||
bio_raw
|
||||
owner_usernames
|
||||
usernames
|
||||
mentionable_level
|
||||
messageable_level
|
||||
visibility_level
|
||||
members_visibility_level
|
||||
grant_trust_level
|
||||
).each do |attr|
|
||||
if action["group_#{attr}"].present?
|
||||
params[attr.to_sym] = CustomWizard::Mapper.new(
|
||||
inputs: action["group_#{attr}"],
|
||||
if action[attr].present?
|
||||
value = CustomWizard::Mapper.new(
|
||||
inputs: action[attr],
|
||||
data: data,
|
||||
user: user
|
||||
).perform
|
||||
|
||||
value = value.parameterize(separator: '_') if attr === "name"
|
||||
value = value.to_i if attr.include?("_level")
|
||||
|
||||
params[attr.to_sym] = value
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -424,27 +432,38 @@ class CustomWizard::Action
|
|||
parent_category_id
|
||||
permissions
|
||||
).each do |attr|
|
||||
if action[attr].present?
|
||||
params[attr.to_sym] = CustomWizard::Mapper.new(
|
||||
if action[attr].present?
|
||||
value = CustomWizard::Mapper.new(
|
||||
inputs: action[attr],
|
||||
data: data,
|
||||
user: user
|
||||
).perform
|
||||
end
|
||||
end
|
||||
|
||||
if params[:parent_category_id].present?
|
||||
params[:parent_category_id] = params[:parent_category_id][0]
|
||||
end
|
||||
|
||||
if params[:permissions].present?
|
||||
permissions = {}
|
||||
params[:permissions].each do |p|
|
||||
if group = Group.find_by(id: p[:key][0])
|
||||
permissions[group.name] = p[:value].to_i
|
||||
|
||||
if attr === "parent_category_id" && value.is_a?(Array)
|
||||
value = value[0]
|
||||
end
|
||||
|
||||
if attr === "permissions" && value.is_a?(Array)
|
||||
permissions = value
|
||||
value = {}
|
||||
|
||||
permissions.each do |p|
|
||||
k = p[:key]
|
||||
v = p[:value].to_i
|
||||
|
||||
if k.is_a?(Array)
|
||||
group = Group.find_by(id: k[0])
|
||||
k = group.name
|
||||
else
|
||||
k = k.parameterize(separator: '_')
|
||||
end
|
||||
|
||||
value[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
params[attr.to_sym] = value
|
||||
end
|
||||
params[:permissions] = permissions
|
||||
end
|
||||
|
||||
add_custom_fields(params)
|
||||
|
|
|
@ -2,10 +2,12 @@ class CustomWizard::Field
|
|||
def self.types
|
||||
@types ||= {
|
||||
text: {
|
||||
min_length: nil
|
||||
min_length: nil,
|
||||
prefill: nil
|
||||
},
|
||||
textarea: {
|
||||
min_length: nil
|
||||
min_length: nil,
|
||||
prefill: nil
|
||||
},
|
||||
composer: {
|
||||
min_length: nil
|
||||
|
|
Laden …
In neuem Issue referenzieren