Feature #442 » 01-add-description-to-trackers_r1785.patch
app/controllers/projects_controller.rb | ||
---|---|---|
33 | 33 |
helper :queries |
34 | 34 |
helper :repositories |
35 | 35 |
helper :members |
36 |
helper :trackers |
|
36 | 37 | |
37 | 38 |
# Lists visible projects |
38 | 39 |
def index |
app/helpers/issues_helper.rb | ||
---|---|---|
188 | 188 |
end |
189 | 189 | |
190 | 190 |
def trackers_options_for_select(issue) |
191 |
trackers = trackers_for_select(issue) |
|
192 |
trackers.collect {|t| [t.name, t.id]} |
|
193 |
end |
|
194 | ||
195 |
def trackers_for_select(issue) |
|
191 | 196 |
trackers = issue.allowed_target_trackers |
192 | 197 |
if issue.new_record? && issue.parent_issue_id.present? |
193 | 198 |
trackers = trackers.reject do |tracker| |
194 | 199 |
issue.tracker_id != tracker.id && tracker.disabled_core_fields.include?('parent_issue_id') |
195 | 200 |
end |
196 | 201 |
end |
197 |
trackers.collect {|t| [t.name, t.id]}
|
|
202 |
trackers |
|
198 | 203 |
end |
199 | 204 | |
200 | 205 |
class IssueFieldsRows |
app/helpers/trackers_helper.rb | ||
---|---|---|
18 | 18 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
19 | 19 | |
20 | 20 |
module TrackersHelper |
21 | ||
22 |
def tracker_name_tag(tracker) |
|
23 |
title = tracker.description.presence |
|
24 |
css = title ? "field-description" : nil |
|
25 |
content_tag 'span', tracker.name, :class => css, :title => title |
|
26 |
end |
|
21 | 27 |
end |
app/models/tracker.rb | ||
---|---|---|
36 | 36 |
validates_presence_of :name |
37 | 37 |
validates_uniqueness_of :name |
38 | 38 |
validates_length_of :name, :maximum => 30 |
39 |
validates_length_of :description, :maximum => 255 |
|
39 | 40 | |
40 | 41 |
scope :sorted, lambda { order(:position) } |
41 | 42 |
scope :named, lambda {|arg| where("LOWER(#{table_name}.name) = LOWER(?)", arg.to_s.strip)} |
... | ... | |
69 | 70 |
'core_fields', |
70 | 71 |
'position', |
71 | 72 |
'custom_field_ids', |
72 |
'project_ids' |
|
73 |
'project_ids', |
|
74 |
'description' |
|
73 | 75 | |
74 | 76 |
def to_s; name end |
75 | 77 |
app/views/issues/_form.html.erb | ||
---|---|---|
15 | 15 |
<% end %> |
16 | 16 | |
17 | 17 |
<% if @issue.safe_attribute?('tracker_id') || (@issue.persisted? && @issue.tracker_id_changed?) %> |
18 |
<p><%= f.select :tracker_id, trackers_options_for_select(@issue), {:required => true}, |
|
19 |
:onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)" %></p> |
|
18 |
<p> |
|
19 |
<%= f.select :tracker_id, trackers_options_for_select(@issue), {:required => true}, |
|
20 |
:onchange => "updateIssueFrom('#{escape_javascript update_issue_form_path(@project, @issue)}', this)", |
|
21 |
:title => @issue.tracker.description %> |
|
22 |
<%= 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? } %> |
|
23 |
</p> |
|
24 |
<%= render partial: 'issues/trackers_description', locals: {trackers: trackers_for_select(@issue)} %> |
|
20 | 25 |
<% end %> |
21 | 26 | |
22 | 27 |
<% if @issue.safe_attribute? 'subject' %> |
app/views/issues/_trackers_description.html.erb | ||
---|---|---|
1 |
<% if trackers.any? {|t| t.description.present? } %> |
|
2 |
<div class="modal" id="trackers_description"> |
|
3 |
<h3 class="title"><%= l(:label_trackers_description) %></h3> |
|
4 |
<dl> |
|
5 |
<% trackers.each do |tracker| %> |
|
6 |
<% if tracker.description.present? %> |
|
7 |
<dt><%= tracker.name %></dt> |
|
8 |
<dd><%= tracker.description %></dd> |
|
9 |
<% end %> |
|
10 |
<% end %> |
|
11 |
</dl> |
|
12 |
</div> |
|
13 |
<% end %> |
app/views/projects/settings/_issues.html.erb | ||
---|---|---|
6 | 6 |
<% @trackers.each do |tracker| %> |
7 | 7 |
<label class="floating"> |
8 | 8 |
<%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.to_a.include?(tracker), :id => nil %> |
9 |
<%= tracker %> |
|
9 |
<%= tracker_name_tag tracker %>
|
|
10 | 10 |
</label> |
11 | 11 |
<% end %> |
12 | 12 |
<%= hidden_field_tag 'project[tracker_ids][]', '' %> |
app/views/projects/show.html.erb | ||
---|---|---|
51 | 51 |
<% @trackers.each do |tracker| %> |
52 | 52 |
<tr> |
53 | 53 |
<td class="name"> |
54 |
<%= link_to tracker.name, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %> |
|
54 |
<%= link_to tracker.name, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id), :title => tracker.description %>
|
|
55 | 55 |
</td> |
56 | 56 |
<td> |
57 | 57 |
<%= link_to @open_issues_by_tracker[tracker].to_i, project_issues_path(@project, :set_filter => 1, :tracker_id => tracker.id) %> |
app/views/trackers/_form.html.erb | ||
---|---|---|
10 | 10 |
:required => true %> |
11 | 11 |
</p> |
12 | 12 |
<p><%= f.check_box :is_in_roadmap %></p> |
13 |
<p><%= f.text_area :description, :rows => 4 %></p> |
|
13 | 14 |
<p> |
14 | 15 |
<label><%= l(:field_core_fields) %></label> |
15 | 16 |
<% Tracker::CORE_FIELDS.each do |field| %> |
app/views/trackers/index.api.rsb | ||
---|---|---|
4 | 4 |
api.id tracker.id |
5 | 5 |
api.name tracker.name |
6 | 6 |
api.default_status(:id => tracker.default_status.id, :name => tracker.default_status.name) unless tracker.default_status.nil? |
7 |
api.description tracker.description |
|
7 | 8 |
end |
8 | 9 |
end |
9 | 10 |
end |
app/views/trackers/index.html.erb | ||
---|---|---|
9 | 9 |
<thead><tr> |
10 | 10 |
<th><%=l(:label_tracker)%></th> |
11 | 11 |
<th><%=l(:field_default_status)%></th> |
12 |
<th><%=l(:field_description)%></th> |
|
12 | 13 |
<th></th> |
13 | 14 |
<th></th> |
14 | 15 |
</tr></thead> |
... | ... | |
17 | 18 |
<tr> |
18 | 19 |
<td class="name"><%= link_to tracker.name, edit_tracker_path(tracker) %></td> |
19 | 20 |
<td><%= tracker.default_status.name %></td> |
21 |
<td class="description"><%= tracker.description %></td> |
|
20 | 22 |
<td> |
21 | 23 |
<% unless tracker.workflow_rules.exists? %> |
22 | 24 |
<span class="icon icon-warning"> |
config/locales/en.yml | ||
---|---|---|
1025 | 1025 |
label_font_monospace: Monospaced font |
1026 | 1026 |
label_font_proportional: Proportional font |
1027 | 1027 |
label_last_notes: Last notes |
1028 |
label_trackers_description: Trackers description |
|
1029 |
label_open_trackers_description: View all trackers description |
|
1028 | 1030 | |
1029 | 1031 |
button_login: Login |
1030 | 1032 |
button_submit: Submit |
db/migrate/20170503103500_add_trackers_description.rb | ||
---|---|---|
1 |
class AddTrackersDescription < ActiveRecord::Migration[5.1] |
|
2 |
def self.up |
|
3 |
add_column :trackers, :description, :string, :after => :name |
|
4 |
end |
|
5 |
def self.down |
|
6 |
remove_column :trackers, :description |
|
7 |
end |
|
8 |
end |
public/stylesheets/application.css | ||
---|---|---|
477 | 477 |
#issue_tree td.checkbox, #relations td.checkbox {display:none;} |
478 | 478 |
#relations td.buttons {padding:0;} |
479 | 479 | |
480 |
#trackers_description {display:none;} |
|
481 |
#trackers_description dt {font-weight: bold; text-decoration: underline;} |
|
482 |
#trackers_description dd {margin: 0; padding: 0 0 1em 0;} |
|
483 | ||
480 | 484 |
fieldset.collapsible {border-width: 1px 0 0 0;} |
481 | 485 |
fieldset.collapsible>legend { padding-left: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; } |
482 | 486 |
fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_collapsed.png); } |
... | ... | |
1497 | 1501 |
height:1px; |
1498 | 1502 |
overflow:hidden; |
1499 | 1503 |
} |
1504 |
public/stylesheets/responsive.css | ||
---|---|---|
747 | 747 |
float: none !important; |
748 | 748 |
} |
749 | 749 | |
750 |
#all_attributes #issue_tracker_id { |
|
751 |
width: 90%; |
|
752 |
} |
|
753 | ||
750 | 754 |
#issue_is_private_label { |
751 | 755 |
display: inline; |
752 | 756 |
} |
test/fixtures/trackers.yml | ||
---|---|---|
5 | 5 |
is_in_chlog: true |
6 | 6 |
default_status_id: 1 |
7 | 7 |
position: 1 |
8 |
description: Description for Bug tracker |
|
8 | 9 |
trackers_002: |
9 | 10 |
name: Feature request |
10 | 11 |
id: 2 |
11 | 12 |
is_in_chlog: true |
12 | 13 |
default_status_id: 1 |
13 | 14 |
position: 2 |
15 |
description: Description for Feature request tracker |
|
14 | 16 |
trackers_003: |
15 | 17 |
name: Support request |
16 | 18 |
id: 3 |
test/functional/issues_controller_test.rb | ||
---|---|---|
2774 | 2774 |
assert_select 'option', text: /#{t.name}/, count: 0 |
2775 | 2775 |
end |
2776 | 2776 | |
2777 |
def test_get_new_should_show_trackers_description |
|
2778 |
@request.session[:user_id] = 2 |
|
2779 |
get :new, :params => { |
|
2780 |
:project_id => 1, |
|
2781 |
:issue => { |
|
2782 |
:tracker_id => 1 |
|
2783 |
} |
|
2784 |
} |
|
2785 |
assert_response :success |
|
2786 | ||
2787 |
assert_select 'form#issue-form' do |
|
2788 |
assert_select 'a[title=?]', 'View all trackers description', :text => 'View all trackers description' |
|
2789 |
assert_select 'select[name=?][title=?]', 'issue[tracker_id]', 'Description for Bug tracker' |
|
2790 |
end |
|
2791 | ||
2792 |
assert_select 'div#trackers_description' do |
|
2793 |
assert_select 'h3', 1, :text => 'Trackers description' |
|
2794 |
# only Bug and Feature have descriptions |
|
2795 |
assert_select 'dt', 2, :text => 'Bug' |
|
2796 |
assert_select 'dd', 2, :text => 'Description for Bug tracker' |
|
2797 |
end |
|
2798 |
end |
|
2799 | ||
2800 |
def test_get_new_should_not_show_trackers_description_for_trackers_without_description |
|
2801 |
Tracker.update_all(:description => '') |
|
2802 | ||
2803 |
@request.session[:user_id] = 2 |
|
2804 |
get :new, :params => { |
|
2805 |
:project_id => 1, |
|
2806 |
:issue => { |
|
2807 |
:tracker_id => 1 |
|
2808 |
} |
|
2809 |
} |
|
2810 |
assert_response :success |
|
2811 | ||
2812 |
assert_select 'form#issue-form' do |
|
2813 |
assert_select 'a[title=?]', 'View all trackers description', 0 |
|
2814 |
assert_select 'select[name=?][title=?]', 'issue[tracker_id]', '' |
|
2815 |
end |
|
2816 | ||
2817 |
assert_select 'div#trackers_description', 0 |
|
2818 |
end |
|
2819 | ||
2777 | 2820 |
def test_update_form_for_new_issue |
2778 | 2821 |
@request.session[:user_id] = 2 |
2779 | 2822 |
post :new, :params => { |
test/integration/api_test/trackers_test.rb | ||
---|---|---|
28 | 28 | |
29 | 29 |
assert_select 'trackers[type=array] tracker id', :text => '2' do |
30 | 30 |
assert_select '~ name', :text => 'Feature request' |
31 |
assert_select '~ description', :text => 'Description for Feature request tracker' |
|
31 | 32 |
end |
32 | 33 |
end |
33 | 34 |
end |
test/unit/tracker_test.rb | ||
---|---|---|
128 | 128 |
end |
129 | 129 |
end |
130 | 130 |
end |
131 | ||
132 |
def test_tracker_should_have_description |
|
133 |
tracker = Tracker.find(1) |
|
134 |
assert tracker.respond_to?(:description) |
|
135 |
assert_equal tracker.description, "Description for Bug tracker" |
|
136 |
end |
|
131 | 137 |
end |
- « Previous
- 1
- …
- 5
- 6
- 7
- Next »