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 0.5.9-dev
+++++++++ +++++++++
- user group support for issue auto assign
- optimize deface overwrite path - optimize deface overwrite path
0.5.8 0.5.8

View File

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