Feature #442 » 01-add-description-to-trackers_r1785.patch
| app/controllers/projects_controller.rb | ||
|---|---|---|
|
helper :queries
|
||
|
helper :repositories
|
||
|
helper :members
|
||
|
helper :trackers
|
||
|
# Lists visible projects
|
||
|
def index
|
||
| app/helpers/issues_helper.rb | ||
|---|---|---|
|
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
|
||
| app/helpers/trackers_helper.rb | ||
|---|---|---|
|
# 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
|
||
| app/models/tracker.rb | ||
|---|---|---|
|
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)}
|
||
| ... | ... | |
|
'core_fields',
|
||
|
'position',
|
||
|
'custom_field_ids',
|
||
|
'project_ids'
|
||
|
'project_ids',
|
||
|
'description'
|
||
|
def to_s; name end
|
||
| app/views/issues/_form.html.erb | ||
|---|---|---|
|
<% 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' %>
|
||
| app/views/issues/_trackers_description.html.erb | ||
|---|---|---|
|
<% 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 %>
|
||
| app/views/projects/settings/_issues.html.erb | ||
|---|---|---|
|
<% @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][]', '' %>
|
||
| app/views/projects/show.html.erb | ||
|---|---|---|
|
<% @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) %>
|
||
| app/views/trackers/_form.html.erb | ||
|---|---|---|
|
: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| %>
|
||
| app/views/trackers/index.api.rsb | ||
|---|---|---|
|
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
|
||
| app/views/trackers/index.html.erb | ||
|---|---|---|
|
<thead><tr>
|
||
|
<th><%=l(:label_tracker)%></th>
|
||
|
<th><%=l(:field_default_status)%></th>
|
||
|
<th><%=l(:field_description)%></th>
|
||
|
<th></th>
|
||
|
<th></th>
|
||
|
</tr></thead>
|
||
| ... | ... | |
|
<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">
|
||
| config/locales/en.yml | ||
|---|---|---|
|
label_font_monospace: Monospaced font
|
||
|
label_font_proportional: Proportional font
|
||
|
label_last_notes: Last notes
|
||
|
label_trackers_description: Trackers description
|
||
|
label_open_trackers_description: View all trackers description
|
||
|
button_login: Login
|
||
|
button_submit: Submit
|
||
| db/migrate/20170503103500_add_trackers_description.rb | ||
|---|---|---|
|
class AddTrackersDescription < ActiveRecord::Migration[5.1]
|
||
|
def self.up
|
||
|
add_column :trackers, :description, :string, :after => :name
|
||
|
end
|
||
|
def self.down
|
||
|
remove_column :trackers, :description
|
||
|
end
|
||
|
end
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
#issue_tree td.checkbox, #relations td.checkbox {display:none;}
|
||
|
#relations 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: 16px; background: url(../images/arrow_expanded.png) no-repeat 0% 40%; cursor:pointer; }
|
||
|
fieldset.collapsible.collapsed>legend { background-image: url(../images/arrow_collapsed.png); }
|
||
| ... | ... | |
|
height:1px;
|
||
|
overflow:hidden;
|
||
|
}
|
||
| public/stylesheets/responsive.css | ||
|---|---|---|
|
float: none !important;
|
||
|
}
|
||
|
#all_attributes #issue_tracker_id {
|
||
|
width: 90%;
|
||
|
}
|
||
|
#issue_is_private_label {
|
||
|
display: inline;
|
||
|
}
|
||
| test/fixtures/trackers.yml | ||
|---|---|---|
|
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
|
||
| test/functional/issues_controller_test.rb | ||
|---|---|---|
|
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 => {
|
||
| test/integration/api_test/trackers_test.rb | ||
|---|---|---|
|
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
|
||
| test/unit/tracker_test.rb | ||
|---|---|---|
|
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
|
||
- « Previous
- 1
- …
- 5
- 6
- 7
- Next »