Feature #6984 » 6984-enable-to-reorder-project-and-application-menu.patch
| app/assets/stylesheets/application.css | ||
|---|---|---|
|
.query-columns select {
|
||
|
min-width:150px;
|
||
|
}
|
||
|
.menu-items label {
|
||
|
display:block;
|
||
|
}
|
||
|
.menu-items select {
|
||
|
min-width: 200px;
|
||
|
}
|
||
|
.query-totals {text-align:right; margin-top:-2.3em;}
|
||
|
.query-totals>span:not(:first-child) {margin-left:0.6em;}
|
||
| app/views/settings/_projects.html.erb | ||
|---|---|---|
|
</p>
|
||
|
</fieldset>
|
||
|
<fieldset class="box">
|
||
|
<legend><%= l(:setting_project_menu_order) %></legend>
|
||
|
<div id="list-definition">
|
||
|
<% menu_order_tag_id = "project_menu_order" %>
|
||
|
<% project_menu_items = menu_items(:project_menu) %>
|
||
|
<div>
|
||
|
<div class="menu-items">
|
||
|
<%= label_tag menu_order_tag_id, l(:label_menu_order) %>
|
||
|
<%= select_tag "settings[#{menu_order_tag_id}]",
|
||
|
options_for_select(project_menu_items.map {|m| [m.caption, m.name]}),
|
||
|
:id => menu_order_tag_id,
|
||
|
:multiple => true, :size => project_menu_items.count %>
|
||
|
</div>
|
||
|
<div class="buttons">
|
||
|
<input type="button" value="⇈" onclick="moveOptionTop(this.form.<%= menu_order_tag_id %>);" />
|
||
|
<input type="button" value="↑" onclick="moveOptionUp(this.form.<%= menu_order_tag_id %>);" />
|
||
|
<input type="button" value="↓" onclick="moveOptionDown(this.form.<%= menu_order_tag_id %>);" />
|
||
|
<input type="button" value="⇊" onclick="moveOptionBottom(this.form.<%= menu_order_tag_id %>);" />
|
||
|
</div>
|
||
|
<%= javascript_tag do %>
|
||
|
$(document).ready(function(){
|
||
|
$('.menu-items').closest('form').submit(function(){
|
||
|
$('#<%= menu_order_tag_id %> option:not(:disabled)').prop('selected', true);
|
||
|
});
|
||
|
});
|
||
|
<% end %>
|
||
|
</div>
|
||
|
</div>
|
||
|
</fieldset>
|
||
|
<%= submit_tag l(:button_save) %>
|
||
|
<% end %>
|
||
| config/locales/en.yml | ||
|---|---|---|
|
setting_timelog_accept_future_dates: Accept time logs on future dates
|
||
|
setting_show_status_changes_in_mail_subject: Show status changes in issue mail notifications subject
|
||
|
setting_project_list_defaults: Projects list defaults
|
||
|
setting_project_menu_order: Project menu order
|
||
|
label_menu_order: order
|
||
|
setting_twofa: Two-factor authentication
|
||
|
permission_add_project: Create project
|
||
| config/locales/ja.yml | ||
|---|---|---|
|
label_display_type: 表示形式
|
||
|
label_display_type_list: リスト
|
||
|
label_display_type_board: ボード
|
||
|
setting_project_menu_order: プロジェクトメニューの並び順
|
||
|
label_menu_order: 順序
|
||
|
label_my_bookmarks: My bookmarks
|
||
|
label_import_time_entries: 作業時間のインポート
|
||
|
field_toolbar_language_options: ツールバーのコードハイライトボタンで使用する言語
|
||
| config/settings.yml | ||
|---|---|---|
|
default: 1
|
||
|
show_status_changes_in_mail_subject:
|
||
|
default: 1
|
||
|
project_menu_order:
|
||
|
serialized: true
|
||
|
default:
|
||
|
- new_object
|
||
|
- overview
|
||
|
- activity
|
||
|
- roadmap
|
||
|
- issues
|
||
|
- new_issue
|
||
|
- time_entries
|
||
|
- gantt
|
||
|
- calendar
|
||
|
- news
|
||
|
- documents
|
||
|
- wiki
|
||
|
- boards
|
||
|
- files
|
||
|
- repository
|
||
|
- settings
|
||
| lib/redmine/menu_manager.rb | ||
|---|---|---|
|
def menu_items_for(menu, project=nil)
|
||
|
items = []
|
||
|
Redmine::MenuManager.items(menu).root.children.each do |node|
|
||
|
menu_items(menu).each do |node|
|
||
|
if node.allowed?(User.current, project)
|
||
|
if block_given?
|
||
|
yield node
|
||
| ... | ... | |
|
return block_given? ? nil : items
|
||
|
end
|
||
|
def menu_items(menu)
|
||
|
items = Redmine::MenuManager.items(menu).root.children
|
||
|
if menu.to_sym == :project_menu || menu.to_sym == :application_menu
|
||
|
menu_order = Setting.project_menu_order
|
||
|
menu_order.unshift([:projects]) if menu.to_sym == :application_menu # Projects menu should always be first
|
||
|
items.sort_by.with_index do |menu_item, i|
|
||
|
menu_order.index { |menu_name| menu_item.name.to_s == menu_name.to_s } || i
|
||
|
end
|
||
|
else
|
||
|
items
|
||
|
end
|
||
|
end
|
||
|
def extract_node_details(node, project=nil)
|
||
|
item = node
|
||
|
url =
|
||
| test/unit/lib/redmine/menu_manager/menu_helper_test.rb | ||
|---|---|---|
|
items = menu_items_for(menu_name, Project.find(1))
|
||
|
assert_equal 1, items.size
|
||
|
end
|
||
|
def test_menu_items_should_return_orderd_items_for_project_menu
|
||
|
Redmine::MenuManager.items(:project_menu).root.children.clear
|
||
|
Redmine::MenuManager.map :project_menu do |menu|
|
||
|
menu.push(:menu_1, '/', {})
|
||
|
menu.push(:menu_2, '/', {})
|
||
|
menu.push(:menu_3, '/', {})
|
||
|
end
|
||
|
with_settings :project_menu_order => [:menu_3, :menu_1, :menu_2] do
|
||
|
project_menu_items = menu_items(:project_menu)
|
||
|
assert_equal 3, project_menu_items.size
|
||
|
assert_equal [:menu_3, :menu_1, :menu_2], project_menu_items.map(&:name)
|
||
|
end
|
||
|
end
|
||
|
def test_menu_items_should_return_orderd_items_for_application_menu
|
||
|
Redmine::MenuManager.items(:application_menu).root.children.clear
|
||
|
Redmine::MenuManager.map :application_menu do |menu|
|
||
|
menu.push(:projects, '/projects', {})
|
||
|
menu.push(:menu_1, '/', {})
|
||
|
menu.push(:menu_2, '/', {})
|
||
|
menu.push(:menu_3, '/', {})
|
||
|
end
|
||
|
with_settings :project_menu_order => [:menu_3, :menu_1, :menu_2] do
|
||
|
application_menu_items = menu_items(:application_menu)
|
||
|
assert_equal 4, application_menu_items.size
|
||
|
assert_equal [:projects, :menu_3, :menu_1, :menu_2], application_menu_items.map(&:name)
|
||
|
end
|
||
|
end
|
||
|
def test_menu_items_should_not_change_order_for_other_menu
|
||
|
Redmine::MenuManager.map :other_menu do |menu|
|
||
|
menu.push(:menu_1, '/', {})
|
||
|
menu.push(:menu_2, '/', {})
|
||
|
menu.push(:menu_3, '/', {})
|
||
|
end
|
||
|
with_settings :project_menu_order => [:menu_3, :menu_1, :menu_2] do
|
||
|
other_menu_items = menu_items(:other_menu)
|
||
|
assert_equal 3, other_menu_items.size
|
||
|
assert_equal [:menu_1, :menu_2, :menu_3], other_menu_items.map(&:name)
|
||
|
end
|
||
|
end
|
||
|
end
|
||
| test/unit/setting_test.rb | ||
|---|---|---|
|
def test_default_text_formatting_for_new_installations_is_common_mark
|
||
|
assert_equal 'common_mark', Setting.text_formatting
|
||
|
end
|
||
|
def test_project_menu_order_should_return_project_menu_names
|
||
|
assert_equal %w(new_object overview activity roadmap issues new_issue time_entries gantt calendar news documents wiki boards files repository settings), Setting.project_menu_order
|
||
|
end
|
||
|
end
|
||