Work on coding standards

This commit is contained in:
Alexander Meindl 2016-10-04 06:43:48 +02:00
parent 2468bf8ab7
commit 0d95e1e336
2 changed files with 30 additions and 32 deletions

View File

@ -3,7 +3,7 @@ Changelog
0.5.9-dev
+++++++++
- user group support for issue auto assign
- optimize deface overwrite path
0.5.8

View File

@ -61,47 +61,45 @@ module RedmineTweaks
title: Setting.plugin_redmine_tweaks[menu_name + '_title'],
roles: Setting.plugin_redmine_tweaks[menu_name + '_roles']
}
return if item[:name].blank? || item[:url].blank? || item[:roles].nil?
unless item[:name].blank? || item[:url].blank? || item[:roles].nil?
show_entry = false
item[:roles].each do |role|
if user_roles.empty? && role.to_i == Role::BUILTIN_ANONYMOUS
show_entry = true
break
elsif User.current.logged? && role.to_i == Role::BUILTIN_NON_MEMBER
# if user is logged in and non_member is active in item,
# always show it
show_entry = true
break
end
user_roles.each do |user_role|
if role.to_i == user_role.id.to_i
show_entry = true
break
end
end
break if show_entry == true
show_entry = false
item[:roles].each do |role|
if user_roles.empty? && role.to_i == Role::BUILTIN_ANONYMOUS
show_entry = true
break
elsif User.current.logged? && role.to_i == Role::BUILTIN_NON_MEMBER
# if user is logged in and non_member is active in item,
# always show it
show_entry = true
break
end
handle_top_menu_item(menu_name, item, show_entry)
user_roles.each do |user_role|
if role.to_i == user_role.id.to_i
show_entry = true
break
end
end
break if show_entry == true
end
handle_top_menu_item(menu_name, item, show_entry)
end
def handle_top_menu_item(menu_name, item, show_entry = false)
if Redmine::MenuManager.map(:top_menu).exists?(menu_name.to_sym)
Redmine::MenuManager.map(:top_menu).delete(menu_name.to_sym)
end
return unless show_entry
if show_entry
html_options = {}
html_options[:class] = 'external' if item[:url].include? '://'
html_options[:title] = item[:title] unless item[:title].blank?
Redmine::MenuManager.map(:top_menu).push menu_name,
item[:url],
caption: item[:name].to_s,
html: html_options,
before: :help
end
html_options = {}
html_options[:class] = 'external' if item[:url].include? '://'
html_options[:title] = item[:title] unless item[:title].blank?
Redmine::MenuManager.map(:top_menu).push menu_name,
item[:url],
caption: item[:name].to_s,
html: html_options,
before: :help
end
def bootstrap_datepicker_locale