Merged r23224 to r23226 from trunk to 6.0-stable (#23980).

git-svn-id: https://svn.redmine.org/redmine/branches/6.0-stable@23233 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu
2024-11-10 15:49:58 +00:00
4 changed files with 55 additions and 7 deletions

View File

@@ -48,11 +48,12 @@
#context-menu li a.submenu { padding-right:16px; background:url("/arrow_right.png") right no-repeat; padding-left: 28px;}
#context-menu li:hover { border:1px solid #628db6; background-color:#eef5fd; border-radius:3px; }
#context-menu a:hover {color:#2A5685;}
#context-menu li.folder ul li a {padding-left: 20px;}
#context-menu li.folder ul li a:not(.icon) {
padding-left: 28px;
}
#context-menu li.folder:hover { z-index:40; }
#context-menu ul ul, #context-menu li:hover ul ul { display:none; }
#context-menu li:hover ul, #context-menu li:hover li:hover ul { display:block; }
#context-menu a.icon-checked {background-position: 3px 40%;}
/* selected element */
.context-menu-selection { background-color:#507AAA !important; color:#f8f8f8 !important; }

View File

@@ -19,19 +19,25 @@
module ContextMenusHelper
def context_menu_link(name, url, options={})
options[:class] ||= ''
label = name
css_classes = [options[:class]]
if options.delete(:selected)
options[:class] += ' icon icon-checked disabled'
css_classes << 'icon disabled'
options[:disabled] = true
label = sprite_icon('checked', name)
end
if options.delete(:disabled)
options.delete(:method)
options.delete(:data)
options[:onclick] = 'return false;'
options[:class] += ' disabled'
css_classes << 'disabled'
url = '#'
end
link_to h(name), url, options
options[:class] = class_names(css_classes)
link_to label, url, options
end
def bulk_update_custom_field_context_menu_link(field, text, value)

View File

@@ -221,7 +221,7 @@ class ContextMenusControllerTest < Redmine::ControllerTest
assert_select 'a[href="#"]', :text => 'List'
assert_select 'ul' do
assert_select 'a', 3
assert_select 'a.icon.icon-checked', :text => 'Bar'
assert_select 'a.icon', :text => 'Bar'
end
end
end

View File

@@ -0,0 +1,41 @@
# frozen_string_literal: true
# Redmine - project management software
# Copyright (C) 2006- Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
require_relative '../test_helper'
class ContextMenusHelperTest < Redmine::HelperTest
include ContextMenusHelper
test '#context_menu_link' do
html = context_menu_link('name', 'url', class: 'class-a')
assert_select_in html, 'a.class-a[href=?]', 'url'
# When :selected is true
html = context_menu_link('name', 'url', selected: true, class: 'class-a class-b')
assert_select_in html, 'a.class-a.class-b.icon.disabled[href=?]', '#' do
assert_select 'svg.icon-svg'
end
# When :disabled is true
html = context_menu_link('name', 'url', disabled: true, method: 'patch', data: { key: 'value' })
assert_select_in html,
'a.disabled[href=?][onclick=?]:not([method]):not([data-key])',
'#', 'return false;'
end
end