mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
add site_setting choices
- add site_setting choices lists to list entries - allows for handy autocompletion using the new select2.js UI - automatically merges plugin choices into existing list, allowing for easy extension
This commit is contained in:
parent
eb884f9928
commit
572ee3b94d
2 changed files with 38 additions and 2 deletions
|
@ -55,14 +55,37 @@ basic:
|
|||
refresh: true
|
||||
list: true
|
||||
default: 'latest|new|unread|starred|top|categories'
|
||||
choices:
|
||||
- latest
|
||||
- new
|
||||
- unread
|
||||
- starred
|
||||
- top
|
||||
- categories
|
||||
- read
|
||||
- posted
|
||||
post_menu:
|
||||
client: true
|
||||
list: true
|
||||
default: 'like|edit|flag|delete|share|bookmark|admin|reply'
|
||||
choices:
|
||||
- like
|
||||
- edit
|
||||
- flag
|
||||
- delete
|
||||
- share
|
||||
- bookmark
|
||||
- admin
|
||||
- reply
|
||||
share_links:
|
||||
client: true
|
||||
list: true
|
||||
default: 'twitter|facebook|google+|email'
|
||||
choices:
|
||||
- twitter
|
||||
- facebook
|
||||
- google+
|
||||
- email
|
||||
category_colors:
|
||||
client: true
|
||||
list: true
|
||||
|
|
|
@ -42,6 +42,10 @@ module SiteSettingExtension
|
|||
@lists ||= []
|
||||
end
|
||||
|
||||
def choices
|
||||
@choices ||= {}
|
||||
end
|
||||
|
||||
def hidden_settings
|
||||
@hidden_settings ||= []
|
||||
end
|
||||
|
@ -60,6 +64,11 @@ module SiteSettingExtension
|
|||
enum = opts[:enum]
|
||||
enums[name] = enum.is_a?(String) ? enum.constantize : enum
|
||||
end
|
||||
if opts[:choices]
|
||||
choices.has_key?(name) ?
|
||||
choices[name].concat(opts[:choices]) :
|
||||
choices[name] = opts[:choices]
|
||||
end
|
||||
if opts[:list]
|
||||
lists << name
|
||||
end
|
||||
|
@ -111,12 +120,16 @@ module SiteSettingExtension
|
|||
.map do |s, v|
|
||||
value = send(s)
|
||||
type = types[get_data_type(s, value)]
|
||||
{setting: s,
|
||||
opts = {setting: s,
|
||||
description: description(s),
|
||||
default: v,
|
||||
type: type.to_s,
|
||||
value: value.to_s,
|
||||
category: categories[s]}.merge( type == :enum ? {valid_values: enum_class(s).values, translate_names: enum_class(s).translate_names?} : {})
|
||||
category: categories[s]
|
||||
}
|
||||
opts.merge({valid_values: enum_class(s).values, translate_names: enum_class(s).translate_names?}) if type == :enum
|
||||
opts[:choices] = choices[s] if choices.has_key? s
|
||||
opts
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue