Commit 465ff699 authored by jplang's avatar jplang

Add a description for trackers (#442).

Patch by Marius BALTEANU.

git-svn-id: https://svn.redmine.org/redmine/trunk@17970 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent ac98af42
......@@ -35,6 +35,7 @@ class ProjectsController < ApplicationController
helper :queries
helper :repositories
helper :members
helper :trackers
# Lists visible projects
def index
......
......@@ -188,13 +188,18 @@ module IssuesHelper
end
def trackers_options_for_select(issue)
trackers = trackers_for_select(issue)
trackers.collect {|t| [t.name, t.id]}
end
def trackers_for_select(issue)
trackers = issue.allowed_target_trackers
if issue.new_record? && issue.parent_issue_id.present?
trackers = trackers.reject do |tracker|
issue.tracker_id != tracker.id && tracker.disabled_core_fields.include?('parent_issue_id')
end
end
trackers.collect {|t| [t.name, t.id]}
trackers
end
class IssueFieldsRows
......
......@@ -20,4 +20,10 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
module TrackersHelper
def tracker_name_tag(tracker)
title = tracker.description.presence
css = title ? "field-description" : nil
content_tag 'span', tracker.name, :class => css, :title => title
end
end
......@@ -38,6 +38,7 @@ class Tracker < ActiveRecord::Base
validates_presence_of :name
validates_uniqueness_of :name
validates_length_of :name, :maximum => 30
validates_length_of :description, :maximum => 255
scope :sorted, lambda { order(:position) }
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)}
......@@ -71,7 +72,8 @@ class Tracker < ActiveRecord::Base
'core_fields',
'position',
'custom_field_ids',
'project_ids'
'project_ids',
'description'
def to_s; name end
......
......@@ -16,8 +16,13 @@
<% end %>
<% if @issue.safe_attribute?('tracker_id') || (@issue.persisted? && @issue.tracker_id_changed?) %>
<p><%= f.select :tracker_id, trackers_options_for_select(@issue), {:required => true},
:onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p>
<p>
<%= f.select :tracker_id, trackers_options_for_select(@issue), {:required => true},
:onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)",
:title => @issue.tracker.description %>
<%= content_tag 'a', l(:label_open_trackers_description), :class => 'icon-only icon-help', :title => l(:label_open_trackers_description), :onclick => "showModal('trackers_description', '500px'); return false;", :href => '#' if trackers_for_select(@issue).any? {|t| t.description.present? } %>
</p>
<%= render partial: 'issues/trackers_description', locals: {trackers: trackers_for_select(@issue)} %>
<% end %>
<% if @issue.safe_attribute? 'subject' %>
......
<% if trackers.any? {|t| t.description.present? } %>
<div class="modal" id="trackers_description">
<h3 class="title"><%= l(:label_trackers_description) %></h3>
<dl>
<% trackers.each do |tracker| %>
<% if tracker.description.present? %>
<dt><%= tracker.name %></dt>
<dd><%= tracker.description %></dd>
<% end %>
<% end %>
</dl>
</div>
<% end %>
......@@ -6,7 +6,7 @@
<% @trackers.each do |tracker| %>
<label class="floating">
<%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.to_a.include?(tracker), :id => nil %>
<%= tracker %>
<%= tracker_name_tag tracker %>
</label>
<% end %>
<%= hidden_field_tag 'project[tracker_ids][]', '' %>
......
......@@ -52,7 +52,7 @@
<% @trackers.each do |tracker| %>
<tr>
<td class="name">
<%= link_to tracker.name, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %>
<%= link_to tracker.name, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id), :title => tracker.description %>
</td>
<td>
<%= link_to @open_issues_by_tracker[tracker].to_i, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %>
......
......@@ -11,6 +11,7 @@
:required => true %>
</p>
<p><%= f.check_box :is_in_roadmap %></p>
<p><%= f.text_area :description, :rows => 4 %></p>
<p>
<label><%= l(:field_core_fields) %></label>
<% Tracker::CORE_FIELDS.each do |field| %>
......
......@@ -4,6 +4,7 @@ api.array :trackers do
api.id tracker.id
api.name tracker.name
api.default_status(:id => tracker.default_status.id, :name => tracker.default_status.name) unless tracker.default_status.nil?
api.description tracker.description
end
end
end
......@@ -9,6 +9,7 @@
<thead><tr>
<th><%=l(:label_tracker)%></th>
<th><%=l(:field_default_status)%></th>
<th><%=l(:field_description)%></th>
<th></th>
<th></th>
</tr></thead>
......@@ -17,6 +18,7 @@
<tr>
<td class="name"><%= link_to tracker.name, edit_tracker_path(tracker) %></td>
<td><%= tracker.default_status.name %></td>
<td class="description"><%= tracker.description %></td>
<td>
<% unless tracker.workflow_rules.exists? %>
<span class="icon icon-warning">
......
......@@ -1043,6 +1043,8 @@ en:
label_nothing_to_preview: Nothing to preview
label_inherited_from_parent_project: "Inherited from parent project"
label_inherited_from_group: "Inherited from group %{name}"
label_trackers_description: Trackers description
label_open_trackers_description: View all trackers description
button_login: Login
button_submit: Submit
......
class AddTrackersDescription < ActiveRecord::Migration[5.2]
def change
add_column :trackers, :description, :string, :after => :name
end
end
......@@ -489,6 +489,10 @@ div.issue.overdue .due-date .value { color: #c22; }
#issue_tree td.checkbox, #relations td.checkbox {display:none;}
#relations td.buttons, #issue_tree td.buttons {padding:0;}
#trackers_description {display:none;}
#trackers_description dt {font-weight: bold; text-decoration: underline;}
#trackers_description dd {margin: 0; padding: 0 0 1em 0;}
fieldset.collapsible {border-width: 1px 0 0 0;}
fieldset.collapsible>legend { padding-left: 18px; background: url(../images/arrow_down.png) no-repeat 4px 40%; cursor:pointer; }
fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_right.png); }
......@@ -1545,6 +1549,7 @@ img.filecontent.image {background-image: url(../images/transparent.png);}
overflow:hidden;
}
img {
image-orientation: from-image;
}
......
......@@ -755,6 +755,10 @@
float: none !important;
}
#all_attributes #issue_tracker_id {
width: 90%;
}
#issue_is_private_label {
display: inline;
}
......
......@@ -5,12 +5,14 @@ trackers_001:
is_in_chlog: true
default_status_id: 1
position: 1
description: Description for Bug tracker
trackers_002:
name: Feature request
id: 2
is_in_chlog: true
default_status_id: 1
position: 2
description: Description for Feature request tracker
trackers_003:
name: Support request
id: 3
......
......@@ -2969,6 +2969,49 @@ class IssuesControllerTest < Redmine::ControllerTest
assert_select 'option', text: /#{t.name}/, count: 0
end
def test_get_new_should_show_trackers_description
@request.session[:user_id] = 2
get :new, :params => {
:project_id => 1,
:issue => {
:tracker_id => 1
}
}
assert_response :success
assert_select 'form#issue-form' do
assert_select 'a[title=?]', 'View all trackers description', :text => 'View all trackers description'
assert_select 'select[name=?][title=?]', 'issue[tracker_id]', 'Description for Bug tracker'
end
assert_select 'div#trackers_description' do
assert_select 'h3', 1, :text => 'Trackers description'
# only Bug and Feature have descriptions
assert_select 'dt', 2, :text => 'Bug'
assert_select 'dd', 2, :text => 'Description for Bug tracker'
end
end
def test_get_new_should_not_show_trackers_description_for_trackers_without_description
Tracker.update_all(:description => '')
@request.session[:user_id] = 2
get :new, :params => {
:project_id => 1,
:issue => {
:tracker_id => 1
}
}
assert_response :success
assert_select 'form#issue-form' do
assert_select 'a[title=?]', 'View all trackers description', 0
assert_select 'select[name=?][title=?]', 'issue[tracker_id]', ''
end
assert_select 'div#trackers_description', 0
end
def test_update_form_for_new_issue
@request.session[:user_id] = 2
post :new, :params => {
......
......@@ -30,6 +30,7 @@ class Redmine::ApiTest::TrackersTest < Redmine::ApiTest::Base
assert_select 'trackers[type=array] tracker id', :text => '2' do
assert_select '~ name', :text => 'Feature request'
assert_select '~ description', :text => 'Description for Feature request tracker'
end
end
end
......@@ -134,4 +134,10 @@ class TrackerTest < ActiveSupport::TestCase
end
end
end
def test_tracker_should_have_description
tracker = Tracker.find(1)
assert tracker.respond_to?(:description)
assert_equal tracker.description, "Description for Bug tracker"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment