Feature #26409 » show_assignee_on_gantt.patch
| app/models/issue_query.rb | ||
|---|---|---|
|
options[:draw_progress_line] = (arg == '1' ? '1' : nil)
|
||
|
end
|
||
|
def draw_assigned_to_names
|
||
|
r = options[:draw_assigned_to_names]
|
||
|
r == '1'
|
||
|
end
|
||
|
def draw_assigned_to_names=(arg)
|
||
|
options[:draw_assigned_to_names] = (arg == '1' ? '1' : nil)
|
||
|
end
|
||
|
def build_from_params(params, defaults={})
|
||
|
super
|
||
|
self.draw_relations = params[:draw_relations] || (params[:query] && params[:query][:draw_relations])
|
||
|
self.draw_progress_line = params[:draw_progress_line] || (params[:query] && params[:query][:draw_progress_line])
|
||
|
self.draw_assigned_to_names = params[:draw_assigned_to_names] || (params[:query] && params[:query][:draw_assigned_to_names])
|
||
|
self
|
||
|
end
|
||
| app/views/gantts/show.html.erb | ||
|---|---|---|
|
</label>
|
||
|
</fieldset>
|
||
|
</td>
|
||
|
<td>
|
||
|
<fieldset>
|
||
|
<legend><%= l(:field_assigned_to) %></legend>
|
||
|
<label for="draw_assigned_to_names">
|
||
|
<%= check_box 'query', 'draw_assigned_to_names', :id => 'draw_assigned_to_names' %>
|
||
|
<%= l(:label_display) %>
|
||
|
</label>
|
||
|
</fieldset>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
</div>
|
||
| ... | ... | |
|
subject_width = 330
|
||
|
header_height = 18
|
||
|
assigned_to_width = 100
|
||
|
headers_height = header_height
|
||
|
show_weeks = false
|
||
| ... | ... | |
|
<p class="warning"><%= l(:notice_gantt_chart_truncated, :max => @gantt.max_rows) %></p>
|
||
|
<% end %>
|
||
|
<table style="width:100%; border:0; border-collapse: collapse;">
|
||
|
<table style="width:100%; border:0; border-collapse: collapse;", class="gantt_container">
|
||
|
<tr>
|
||
|
<td style="width:<%= subject_width %>px; padding:0px;" class="gantt_subjects_column">
|
||
|
<%
|
||
| ... | ... | |
|
<% end %>
|
||
|
<% end %>
|
||
|
</td>
|
||
|
<td style="width:<%= assigned_to_width %>px; padding:0px; display:none;" class="gantt_assigned_to_names_column">
|
||
|
<%
|
||
|
style = ""
|
||
|
style += "position:relative;"
|
||
|
style += "height: #{t_height + 24}px;"
|
||
|
style += "width: #{assigned_to_width + 1}px;"
|
||
|
%>
|
||
|
<%= content_tag(:div, :style => style, :class => "gantt_assigned_to_names_container") do %>
|
||
|
<%
|
||
|
style = ""
|
||
|
style += "width: #{assigned_to_width}px;"
|
||
|
style += "height: #{headers_height}px;"
|
||
|
style += 'background: #eee;'
|
||
|
%>
|
||
|
<%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
|
||
|
<%
|
||
|
style = ""
|
||
|
style += "width: #{assigned_to_width}px;"
|
||
|
style += "height: #{t_height}px;"
|
||
|
style += 'border-left: 1px solid #c0c0c0;'
|
||
|
style += 'overflow: hidden;'
|
||
|
%>
|
||
|
<%= content_tag(:div, "", :style => style, :class => "gantt_hdr") %>
|
||
|
<%= content_tag(:div, :class => "gantt_assigned_to_names") do %>
|
||
|
<%= @gantt.assigned_to_names.html_safe %>
|
||
|
<% end %>
|
||
|
<% end %>
|
||
|
</td>
|
||
|
<td>
|
||
|
<div style="position:relative;height:<%= t_height + 24 %>px;overflow:auto;" id="gantt_area">
|
||
|
<%
|
||
| ... | ... | |
|
$(function() {
|
||
|
drawGanttHandler();
|
||
|
resizableSubjectColumn();
|
||
|
$("#draw_relations").change(drawGanttHandler);
|
||
|
$("#draw_progress_line").change(drawGanttHandler);
|
||
|
$("#draw_relations, #draw_progress_line, #draw_assigned_to_names").change(drawGanttHandler);
|
||
|
});
|
||
|
$(window).resize(function() {
|
||
|
drawGanttHandler();
|
||
| app/views/queries/_form.html.erb | ||
|---|---|---|
|
<p><label><%= l(:button_show) %></label>
|
||
|
<label class="inline"><%= check_box_tag "query[draw_relations]", "1", @query.draw_relations %> <%= l(:label_related_issues) %></label>
|
||
|
<label class="inline"><%= check_box_tag "query[draw_progress_line]", "1", @query.draw_progress_line %> <%= l(:label_gantt_progress_line) %></label>
|
||
|
<label class="inline"><%= check_box_tag "query[draw_assigned_to_names]", "1", @query.draw_assigned_to_names %> <%= l(:label_gantt_assigned_to_names) %></label>
|
||
|
</p>
|
||
|
</fieldset>
|
||
|
<% end %>
|
||
| lib/redmine/helpers/gantt.rb | ||
|---|---|---|
|
@date_to = (@date_from >> @months) - 1
|
||
|
@subjects = ''
|
||
|
@lines = ''
|
||
|
@assigned_to_names = ''
|
||
|
@number_of_rows = nil
|
||
|
@truncated = false
|
||
|
if options.has_key?(:max_rows)
|
||
| ... | ... | |
|
@lines
|
||
|
end
|
||
|
# Renders the assigned_to_names of the Gantt chart, the right side of subjects.
|
||
|
def assigned_to_names(options={})
|
||
|
render(options.merge(:only => :assigned_to_names)) unless @assigned_to_names_rendered
|
||
|
@assigned_to_names
|
||
|
end
|
||
|
# Returns issues that will be rendered
|
||
|
def issues
|
||
|
@issues ||= @query.issues(
|
||
| ... | ... | |
|
:indent_increment => 20, :render => :subject,
|
||
|
:format => :html}.merge(options)
|
||
|
indent = options[:indent] || 4
|
||
|
@subjects = '' unless options[:only] == :lines
|
||
|
@lines = '' unless options[:only] == :subjects
|
||
|
@subjects = '' unless options[:only] == :lines || options[:only] == :assigned_to_names
|
||
|
@lines = '' unless options[:only] == :subjects || options[:only] == :assigned_to_names
|
||
|
@assigned_to_names = '' unless options[:only] == :lines || options[:only] == :subjects
|
||
|
@number_of_rows = 0
|
||
|
begin
|
||
|
Project.project_tree(projects) do |project, level|
|
||
| ... | ... | |
|
rescue MaxLinesLimitReached
|
||
|
@truncated = true
|
||
|
end
|
||
|
@subjects_rendered = true unless options[:only] == :lines
|
||
|
@lines_rendered = true unless options[:only] == :subjects
|
||
|
@subjects_rendered = true unless options[:only] == :lines || options[:only] == :assigned_to_names
|
||
|
@lines_rendered = true unless options[:only] == :subjects || options[:only] == :assigned_to_names
|
||
|
@assigned_to_names_rendered = true unless options[:only] == :lines || options[:only] == :subjects
|
||
|
render_end(options)
|
||
|
end
|
||
| ... | ... | |
|
def render_object_row(object, options)
|
||
|
class_name = object.class.name.downcase
|
||
|
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines
|
||
|
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects
|
||
|
send("subject_for_#{class_name}", object, options) unless options[:only] == :lines || options[:only] == :assigned_to_names
|
||
|
send("line_for_#{class_name}", object, options) unless options[:only] == :subjects || options[:only] == :assigned_to_names
|
||
|
assigned_to_name(object, options) unless options[:only] == :lines || options[:only] == :subjects
|
||
|
options[:top] += options[:top_increment]
|
||
|
@number_of_rows += 1
|
||
|
if @max_rows && @number_of_rows >= @max_rows
|
||
| ... | ... | |
|
end
|
||
|
end
|
||
|
def assigned_to_name(issue, options)
|
||
|
if issue.is_a?(Issue) && options[:format] == :html && issue.assigned_to.present?
|
||
|
style = "position: absolute;top: #{options[:top]}px;"
|
||
|
assigned_to_name = view.content_tag(:div, view.content_tag(:span, issue.try(:assigned_to).try(:name)), :style => style, :class => 'issue-assigned-name')
|
||
|
@assigned_to_names << assigned_to_name
|
||
|
assigned_to_name
|
||
|
end
|
||
|
end
|
||
|
def subject(label, options, object=nil)
|
||
|
send "#{options[:format]}_subject", options, label, object
|
||
|
end
|
||
| public/javascripts/gantt.js | ||
|---|---|---|
|
}
|
||
|
}
|
||
|
function drawAssignedToNames(){
|
||
|
if ($("#draw_assigned_to_names").prop('checked')){
|
||
|
$('td.gantt_assigned_to_names_column').show();
|
||
|
$('td.gantt_assigned_to_names_column').resizable({
|
||
|
alsoResize: ".gantt_assigned_to_names_container, .gantt_assigned_to_names_container>.gantt_hdr, .issue-assigned-name",
|
||
|
minWidth: 20,
|
||
|
handles: "e",
|
||
|
containment: "#content",
|
||
|
create: function( event, ui ) {
|
||
|
$(".ui-resizable-e").css("cursor","ew-resize");
|
||
|
}
|
||
|
}).on('resize', function (e) {
|
||
|
e.stopPropagation();
|
||
|
});
|
||
|
if(isMobile()) {
|
||
|
var width = Math.round($('.gantt_container').width()*0.15)
|
||
|
$('.gantt_assigned_to_names_container>.gantt_hdr').width(width-2);
|
||
|
$('.gantt_assigned_to_names_container, .gantt_assigned_to_names_column').width(width);
|
||
|
$('.issue-assigned-name').each(function(){
|
||
|
$(this).width($(".gantt_assigned_to_names_column").width());
|
||
|
});
|
||
|
$('td.gantt_assigned_to_names_column').resizable('disable');
|
||
|
}else{
|
||
|
$('td.gantt_assigned_to_names_column').resizable('enable');
|
||
|
};
|
||
|
}else{
|
||
|
$('td.gantt_assigned_to_names_column').hide();
|
||
|
}
|
||
|
}
|
||
|
function drawGanttHandler() {
|
||
|
var folder = document.getElementById('gantt_draw_area');
|
||
|
if(draw_gantt != null)
|
||
| ... | ... | |
|
else
|
||
|
draw_gantt = Raphael(folder);
|
||
|
setDrawArea();
|
||
|
drawAssignedToNames();
|
||
|
if ($("#draw_progress_line").prop('checked'))
|
||
|
drawGanttProgressLines();
|
||
|
if ($("#draw_relations").prop('checked'))
|
||
| public/stylesheets/application.css | ||
|---|---|---|
|
.gantt_hdr.nwday {background-color:#f1f1f1; color:#999;}
|
||
|
.gantt_subjects { font-size: 0.8em; }
|
||
|
.gantt_subjects div { line-height:16px;height:16px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis; }
|
||
|
.gantt_subjects, .issue-assigned-name { font-size: 0.8em; }
|
||
|
.gantt_subjects div, .issue-assigned-name { line-height:16px;height:16px;overflow:hidden;white-space:nowrap;text-overflow: ellipsis; }
|
||
|
.issue-assigned-name { padding: 0px 3px; width: 100px; }
|
||
|
.task {
|
||
|
position: absolute;
|
||
| public/stylesheets/responsive.css | ||
|---|---|---|
|
* [4] maintain width due to [3]
|
||
|
*/
|
||
|
.gantt_subjects_column {
|
||
|
width: 60% !important; /* [1] */
|
||
|
width: 50% !important; /* [1] */
|
||
|
}
|
||
|
.gantt_subjects_container {
|
||
| ... | ... | |
|
#login-form {width:100%; margin-top:2em;}
|
||
|
}
|
||
| test/functional/queries_controller_test.rb | ||
|---|---|---|
|
:query => {
|
||
|
:name => "test_create_from_gantt",
|
||
|
:draw_relations => '1',
|
||
|
:draw_progress_line => '1'
|
||
|
:draw_progress_line => '1',
|
||
|
:draw_assigned_to_names => '1'
|
||
|
}
|
||
|
}
|
||
|
assert_response 302
|
||
| ... | ... | |
|
assert_redirected_to "/issues/gantt?query_id=#{query.id}"
|
||
|
assert_equal true, query.draw_relations
|
||
|
assert_equal true, query.draw_progress_line
|
||
|
assert_equal true, query.draw_assigned_to_names
|
||
|
end
|
||
|
def test_create_project_query_from_gantt
|
||
| ... | ... | |
|
:query => {
|
||
|
:name => "test_create_from_gantt",
|
||
|
:draw_relations => '0',
|
||
|
:draw_progress_line => '0'
|
||
|
:draw_progress_line => '0',
|
||
|
:draw_assigned_to_names => '0'
|
||
|
}
|
||
|
}
|
||
|
assert_response 302
|
||
| ... | ... | |
|
assert_redirected_to "/projects/ecookbook/issues/gantt?query_id=#{query.id}"
|
||
|
assert_equal false, query.draw_relations
|
||
|
assert_equal false, query.draw_progress_line
|
||
|
assert_equal false, query.draw_assigned_to_names
|
||
|
end
|
||
|
def test_create_project_public_query_should_force_private_without_manage_public_queries_permission
|
||
| test/unit/lib/redmine/helpers/gantt_test.rb | ||
|---|---|---|
|
assert_select "div.tooltip", /#{@issue.subject}/
|
||
|
end
|
||
|
test "#assigned_to_names" do
|
||
|
create_gantt
|
||
|
issue = Issue.generate!
|
||
|
issue.update(:assigned_to_id => issue.assignable_users.first.id)
|
||
|
@project.issues << issue
|
||
|
@output_buffer = @gantt.assigned_to_names(:format => :html)
|
||
|
assert_select "div.issue-assigned-name span", /#{issue.assigned_to.name}/
|
||
|
end
|
||
|
test "#subject_for_project" do
|
||
|
create_gantt
|
||
|
@output_buffer = @gantt.subject_for_project(@project, :format => :html)
|
||
| ... | ... | |
|
assert_select "div.label", :text => 'line'
|
||
|
end
|
||
|
test "#assigned_to_name" do
|
||
|
create_gantt
|
||
|
options = {:top => 64, :format => :html}
|
||
|
issue = Issue.generate!
|
||
|
issue.assigned_to_id = issue.assignable_users.first.id
|
||
|
@output_buffer = @gantt.assigned_to_name(issue, options)
|
||
|
assert_select 'div.issue-assigned-name[style*="position: absolute;top: 64px;"]' do
|
||
|
assert_select 'span', issue.assigned_to.name
|
||
|
end
|
||
|
end
|
||
|
def test_sort_issues_no_date
|
||
|
project = Project.generate!
|
||
|
issue1 = Issue.generate!(:subject => "test", :project => project)
|
||