From 16e9ffce0d0e803f02e3660450120602bca8aff5 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 20 Jan 2008 13:07:19 +0000 Subject: [PATCH] Added a 'New issue' link in the main menu (accesskey 7). The drop-down lists to add an issue on the project overview and the issue list are removed. git-svn-id: http://redmine.rubyforge.org/svn/trunk@1081 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/issues_controller.rb | 2 ++ app/helpers/application_helper.rb | 8 +------ app/helpers/projects_helper.rb | 8 ------- app/views/issues/_sidebar.rhtml | 5 ----- app/views/projects/show.rhtml | 5 ----- lib/redmine.rb | 2 ++ lib/redmine/access_keys.rb | 31 ++++++++++++++++++++++++++++ lib/redmine/menu_manager.rb | 10 +++++++-- public/stylesheets/application.css | 2 +- 9 files changed, 45 insertions(+), 28 deletions(-) create mode 100644 lib/redmine/access_keys.rb diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7a48282c9..643a4e0ef 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -17,6 +17,8 @@ class IssuesController < ApplicationController layout 'base' + menu_item :new_issue, :only => :new + before_filter :find_issue, :except => [:index, :changes, :preview, :new, :update_form] before_filter :find_project, :only => [:new, :update_form] before_filter :authorize, :except => [:index, :changes, :preview, :update_form] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f0455f3e4..1dfb57ff8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -162,15 +162,9 @@ module ApplicationHelper @html_title += args end end - - ACCESSKEYS = {:edit => 'e', - :preview => 'r', - :quick_search => 'f', - :search => '4', - }.freeze unless const_defined?(:ACCESSKEYS) def accesskey(s) - ACCESSKEYS[s] + Redmine::AccessKeys.key_for s end # Formats text according to system settings. diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index ee61d88dd..883be0ead 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -188,12 +188,4 @@ module ProjectsHelper gc.draw(imgl) imgl end if Object.const_defined?(:Magick) - - def new_issue_selector - trackers = @project.trackers - # can't use form tag inside helper - content_tag('form', - select_tag('tracker_id', '' + options_from_collection_for_select(trackers, 'id', 'name'), :onchange => "if (this.value != '') {this.form.submit()}"), - :action => url_for(:controller => 'issues', :action => 'new', :project_id => @project), :method => 'get') - end end diff --git a/app/views/issues/_sidebar.rhtml b/app/views/issues/_sidebar.rhtml index 1e1fc87d0..4a1b7e9bc 100644 --- a/app/views/issues/_sidebar.rhtml +++ b/app/views/issues/_sidebar.rhtml @@ -1,8 +1,3 @@ -<% if authorize_for('issues', 'new') && @project.trackers.any? %> -

<%= l(:label_issue_new) %>

-<%= l(:label_tracker) %>: <%= new_issue_selector %> -<% end %> -

<%= l(:label_issue_plural) %>

<%= link_to l(:label_issue_view_all), { :controller => 'issues', :action => 'index', :project_id => @project, :set_filter => 1 } %>
<%= link_to l(:field_summary), :controller => 'reports', :action => 'issue_report', :id => @project %>
diff --git a/app/views/projects/show.rhtml b/app/views/projects/show.rhtml index ecaa9750a..eb80bf9fa 100644 --- a/app/views/projects/show.rhtml +++ b/app/views/projects/show.rhtml @@ -56,11 +56,6 @@ <% content_for :sidebar do %> - <% if authorize_for('issues', 'new') && @project.trackers.any? %> -

<%= l(:label_issue_new) %>

- <%= l(:label_tracker) %>: <%= new_issue_selector %> - <% end %> - <% planning_links = [] planning_links << link_to_if_authorized(l(:label_calendar), :action => 'calendar', :id => @project) planning_links << link_to_if_authorized(l(:label_gantt), :action => 'gantt', :id => @project) diff --git a/lib/redmine.rb b/lib/redmine.rb index ea05d6e80..1aee1767c 100644 --- a/lib/redmine.rb +++ b/lib/redmine.rb @@ -95,6 +95,8 @@ Redmine::MenuManager.map :project_menu do |menu| menu.push :activity, { :controller => 'projects', :action => 'activity' }, :caption => :label_activity menu.push :roadmap, { :controller => 'projects', :action => 'roadmap' }, :caption => :label_roadmap menu.push :issues, { :controller => 'issues', :action => 'index' }, :param => :project_id, :caption => :label_issue_plural + menu.push :new_issue, { :controller => 'issues', :action => 'new' }, :param => :project_id, :caption => :label_issue_new, + :html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) } menu.push :news, { :controller => 'news', :action => 'index' }, :param => :project_id, :caption => :label_news_plural menu.push :documents, { :controller => 'documents', :action => 'index' }, :param => :project_id, :caption => :label_document_plural menu.push :wiki, { :controller => 'wiki', :action => 'index', :page => nil }, diff --git a/lib/redmine/access_keys.rb b/lib/redmine/access_keys.rb new file mode 100644 index 000000000..96029a6fc --- /dev/null +++ b/lib/redmine/access_keys.rb @@ -0,0 +1,31 @@ +# redMine - project management software +# Copyright (C) 2006-2008 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. + +module Redmine + module AccessKeys + ACCESSKEYS = {:edit => 'e', + :preview => 'r', + :quick_search => 'f', + :search => '4', + :new_issue => '7' + }.freeze unless const_defined?(:ACCESSKEYS) + + def self.key_for(action) + ACCESSKEYS[action] + end + end +end diff --git a/lib/redmine/menu_manager.rb b/lib/redmine/menu_manager.rb index c801cb383..379028ebc 100644 --- a/lib/redmine/menu_manager.rb +++ b/lib/redmine/menu_manager.rb @@ -68,7 +68,7 @@ module Redmine unless item.condition && !item.condition.call(project) links << content_tag('li', link_to(l(item.caption), {item.param => project}.merge(item.url), - :class => (current_menu_item == item.name ? 'selected' : nil))) + (current_menu_item == item.name ? item.html_options.merge(:class => 'selected') : item.html_options))) end end if project && !project.new_record? links.empty? ? nil : content_tag('ul', links.join("\n")) @@ -94,6 +94,11 @@ module Redmine end class Mapper + # Adds an item at the end of the menu. Available options: + # * param: the parameter name that is used for the project id (default is :id) + # * condition: a proc that is called before rendering the item, the item is displayed only if it returns true + # * caption: the localized string key that is used as the item label + # * html_options: a hash of html options that are passed to link_to def push(name, url, options={}) @items ||= [] @items << MenuItem.new(name, url, options) @@ -105,7 +110,7 @@ module Redmine end class MenuItem - attr_reader :name, :url, :param, :condition, :caption + attr_reader :name, :url, :param, :condition, :caption, :html_options def initialize(name, url, options) @name = name @@ -113,6 +118,7 @@ module Redmine @condition = options[:if] @param = options[:param] || :id @caption = options[:caption] || name.to_s.humanize + @html_options = options[:html] || {} end end end diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css index d370f1b42..5bada6e06 100644 --- a/public/stylesheets/application.css +++ b/public/stylesheets/application.css @@ -17,7 +17,7 @@ h4, .wiki h3 {font-size: 12px;padding: 2px 10px 1px 0px;margin-bottom: 5px; bord #header a {color:#f8f8f8;} #quick-search {float:right;} -#main-menu {position: absolute; bottom: 0px; left:6px;} +#main-menu {position: absolute; bottom: 0px; left:6px; margin-right: -500px;} #main-menu ul {margin: 0; padding: 0;} #main-menu li { float:left; -- 2.39.5