Actualizar plugin Additionals a 3.0.0
This commit is contained in:
parent
3d976f1b3b
commit
a26f5567af
399 changed files with 70374 additions and 4093 deletions
|
@ -1,12 +1,12 @@
|
|||
class AdditionalsFontAwesome
|
||||
include Redmine::I18n
|
||||
|
||||
FORMAT_REGEXP = /\Afa[rsb]_[a-zA-Z0-9]+[a-zA-Z0-9\-]*\z/.freeze
|
||||
SEARCH_LIMIT = 50
|
||||
|
||||
class << self
|
||||
def load_icons(type)
|
||||
data = YAML.safe_load(ERB.new(IO.read(Rails.root.join('plugins',
|
||||
'additionals',
|
||||
'config',
|
||||
'fontawesome_icons.yml'))).result) || {}
|
||||
data = YAML.safe_load(ERB.new(IO.read(Rails.root.join('plugins/additionals/config/fontawesome_icons.yml'))).result) || {}
|
||||
icons = {}
|
||||
data.each do |key, values|
|
||||
icons[key] = { unicode: values['unicode'], label: values['label'] } if values['styles'].include?(convert_type2style(type))
|
||||
|
@ -62,12 +62,6 @@ class AdditionalsFontAwesome
|
|||
FONTAWESOME_ICONS[type].collect { |fa_symbol, values| [values[:label], key2value(fa_symbol, type[-1])] }
|
||||
end
|
||||
|
||||
def json_for_select
|
||||
[{ text: l(:label_fontawesome_regular), children: json_values(:far) },
|
||||
{ text: l(:label_fontawesome_solid), children: json_values(:fas) },
|
||||
{ text: l(:label_fontawesome_brands), children: json_values(:fab) }].to_json
|
||||
end
|
||||
|
||||
# show only one value as current selected
|
||||
# (all other options are retrieved by select2
|
||||
def active_option_for_select(selected)
|
||||
|
@ -77,12 +71,6 @@ class AdditionalsFontAwesome
|
|||
[[info[:label], selected]]
|
||||
end
|
||||
|
||||
def options_for_select
|
||||
[[l(:label_fontawesome_regular), select_values(:far)],
|
||||
[l(:label_fontawesome_solid), select_values(:fas)],
|
||||
[l(:label_fontawesome_brands), select_values(:fab)]]
|
||||
end
|
||||
|
||||
def value_info(value, options = {})
|
||||
return {} if value.blank?
|
||||
|
||||
|
@ -104,8 +92,60 @@ class AdditionalsFontAwesome
|
|||
info
|
||||
end
|
||||
|
||||
def search_for_select(search, selected = nil)
|
||||
# could be more then one
|
||||
selected_store = selected.to_s.split(',')
|
||||
icons = search_in_type(:far, search, selected_store)
|
||||
cnt = icons.count
|
||||
return icons if cnt >= SEARCH_LIMIT
|
||||
|
||||
icons += search_in_type(:fas, search, selected_store, cnt)
|
||||
cnt = icons.count
|
||||
return icons if cnt >= SEARCH_LIMIT
|
||||
|
||||
icons + search_in_type(:fab, search, selected_store, cnt)
|
||||
end
|
||||
|
||||
def convert2mermaid(icon)
|
||||
return if icon.blank?
|
||||
|
||||
parts = icon.split('_')
|
||||
return unless parts.count == 2
|
||||
|
||||
"#{parts.first}:fa-#{parts.last}"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def search_in_type(type, search, selected_store, cnt = 0)
|
||||
icons = []
|
||||
|
||||
search_length = search.to_s.length
|
||||
first_letter_search = if search_length == 1
|
||||
search[0].downcase
|
||||
elsif search_length.zero? && selected_store.any?
|
||||
selected = selected_store.first
|
||||
fa = selected.split('_')
|
||||
search = fa[1][0] if fa.count > 1
|
||||
search
|
||||
end
|
||||
|
||||
FONTAWESOME_ICONS[type].each do |fa_symbol, values|
|
||||
break if SEARCH_LIMIT == cnt
|
||||
|
||||
id = key2value(fa_symbol, type[-1])
|
||||
next if selected_store.exclude?(id) &&
|
||||
search.present? &&
|
||||
(first_letter_search.present? && !values[:label].downcase.start_with?(first_letter_search) ||
|
||||
first_letter_search.blank? && values[:label] !~ /#{search}/i)
|
||||
|
||||
icons << { id: id, text: values[:label] }
|
||||
cnt += 1
|
||||
end
|
||||
|
||||
icons
|
||||
end
|
||||
|
||||
def load_details(type, name)
|
||||
return {} unless FONTAWESOME_ICONS.key?(type)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue