Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Add preset dropdown for tags
Dieser Commit ist enthalten in:
Ursprung
e414e651cc
Commit
c9b7296640
3 geänderte Dateien mit 13 neuen und 2 gelöschten Zeilen
|
@ -21,6 +21,9 @@ export default Ember.Component.extend({
|
||||||
},{
|
},{
|
||||||
id: 'groups',
|
id: 'groups',
|
||||||
name: I18n.t('admin.wizard.field.choices_preset.groups')
|
name: I18n.t('admin.wizard.field.choices_preset.groups')
|
||||||
|
},{
|
||||||
|
id: 'tags',
|
||||||
|
name: I18n.t('admin.wizard.field.choices_preset.tags')
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
|
@ -99,6 +99,7 @@ en:
|
||||||
label: "Preset"
|
label: "Preset"
|
||||||
categories: "Categories"
|
categories: "Categories"
|
||||||
groups: "Groups"
|
groups: "Groups"
|
||||||
|
tags: "Tags"
|
||||||
filter: "Preset Filter"
|
filter: "Preset Filter"
|
||||||
choice:
|
choice:
|
||||||
value: "Value"
|
value: "Value"
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
TagStruct = Struct.new(:id, :name)
|
||||||
|
|
||||||
class CustomWizard::Builder
|
class CustomWizard::Builder
|
||||||
|
|
||||||
attr_accessor :wizard, :updater, :submissions
|
attr_accessor :wizard, :updater, :submissions
|
||||||
|
@ -237,7 +239,8 @@ class CustomWizard::Builder
|
||||||
end
|
end
|
||||||
elsif field_template['choices_preset'] && field_template['choices_preset'].length > 0
|
elsif field_template['choices_preset'] && field_template['choices_preset'].length > 0
|
||||||
objects = []
|
objects = []
|
||||||
site = Site.new(Guardian.new(@wizard.user))
|
guardian = Guardian.new(@wizard.user)
|
||||||
|
site = Site.new(guardian)
|
||||||
|
|
||||||
if field_template['choices_preset'] === 'categories'
|
if field_template['choices_preset'] === 'categories'
|
||||||
objects = site.categories
|
objects = site.categories
|
||||||
|
@ -247,6 +250,10 @@ class CustomWizard::Builder
|
||||||
objects = site.groups
|
objects = site.groups
|
||||||
end
|
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
|
if field_template['choices_filters'] && field_template['choices_filters'].length > 0
|
||||||
field_template['choices_filters'].each do |f|
|
field_template['choices_filters'].each do |f|
|
||||||
objects.reject! do |o|
|
objects.reject! do |o|
|
||||||
|
@ -465,7 +472,7 @@ class CustomWizard::Builder
|
||||||
## add validation callback
|
## add validation callback
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_to_group(user, action, data)
|
def add_to_group(user, action, data)
|
||||||
if group_id = data[action['group_id']]
|
if group_id = data[action['group_id']]
|
||||||
if group = Group.find(group_id)
|
if group = Group.find(group_id)
|
||||||
|
|
Laden …
In neuem Issue referenzieren