Project

General

Profile

Patch #32162 » progress_bar_recreate.diff

Bernhard Rohloff, 2019-09-27 17:49

View differences:

app/helpers/application_helper.rb
content_tag('p', legend, :class => 'percent').html_safe
end
def bar_graph(pcts, options={})
pcts = [pcts] unless pcts.is_a?(Array)
case pcts[0]
when Integer, Float
pcts = pcts.sort.reverse
bar = content_tag :div, :class => "bar-graph" do
content = pcts.each_with_index.collect do |p, index|
content_tag( 'span', '',
:style => "width: #{p}%",
:title => "#{p.floor}%" )
end.join.html_safe
end
when Hash
pcts = pcts.sort_by{ |k| k[:pcts] }.reverse
bar = content_tag :div, :class => "bar-graph" do
content = pcts.each_with_index.collect do |p, index|
concat content_tag( 'span', '',
:style => "width: #{p[:pcts].floor}%",
:title => "#{p[:label] || ''}: #{p[:pcts].floor}%" )
end.join.html_safe
end
end
legend = content_tag( 'p', options[:legend] || '', :class => 'legend' ).html_safe
content_tag( 'div', bar + legend, :class => "#{options[:class] || ''}" )
end
def checked_image(checked=true)
if checked
@checked_image_tag ||= content_tag(:span, nil, :class => 'icon-only icon-checked')
app/helpers/issues_helper.rb
content_tag('td', link_to_issue(child, :project => (issue.project_id != child.project_id)), :class => 'subject', :style => 'width: 50%') +
content_tag('td', h(child.status), :class => 'status') +
content_tag('td', link_to_user(child.assigned_to), :class => 'assigned_to') +
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(child.done_ratio), :class=> 'done_ratio') +
content_tag('td', child.disabled_core_fields.include?('done_ratio') ? '' : bar_graph(child.done_ratio, :class => 'progress-bar'), :class=> 'done_ratio') +
content_tag('td', buttons, :class => 'buttons'),
:class => css)
end
......
content_tag('td', other_issue.status, :class => 'status') +
content_tag('td', format_date(other_issue.start_date), :class => 'start_date') +
content_tag('td', format_date(other_issue.due_date), :class => 'due_date') +
content_tag('td', other_issue.disabled_core_fields.include?('done_ratio') ? '' : progress_bar(other_issue.done_ratio), :class=> 'done_ratio') +
content_tag('td', other_issue.disabled_core_fields.include?('done_ratio') ? '' : bar_graph(other_issue.done_ratio, :class => 'progress-bar'), :class=> 'done_ratio') +
content_tag('td', buttons, :class => 'buttons'),
:id => "relation-#{relation.id}",
:class => css)
app/helpers/queries_helper.rb
when :last_notes
item.last_notes.present? ? content_tag('div', textilizable(item, :last_notes), :class => "wiki") : ''
when :done_ratio
progress_bar(value)
bar_graph(value, :class => 'progress-bar')
when :relations
content_tag('span',
value.to_s(item) {|other| link_to_issue(other, :subject => false, :tracker => false)}.html_safe,
app/views/issues/show.html.erb
rows.right l(:field_due_date), issue_due_date_details(@issue), :class => 'due-date'
end
unless @issue.disabled_core_fields.include?('done_ratio')
rows.right l(:field_done_ratio), progress_bar(@issue.done_ratio, :legend => "#{@issue.done_ratio}%"), :class => 'progress'
rows.right l(:field_done_ratio), bar_graph(@issue.done_ratio, :legend => "#{@issue.done_ratio}%", :class => 'progress-bar'), :class => 'progress'
end
unless @issue.disabled_core_fields.include?('estimated_hours')
rows.right l(:field_estimated_hours), issue_estimated_hours_details(@issue), :class => 'estimated-hours'
app/views/versions/_issue_counts.html.erb
<% end %>
</td>
<td style="width:240px;">
<%= progress_bar((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}") %>
<%= bar_graph((count[:closed].to_f / count[:total])*100,
:legend => "#{count[:closed]}/#{count[:total]}", :class => 'progress-bar') %>
</td>
</tr>
<% end %>
app/views/versions/_overview.html.erb
<% end %>
<% if version.visible_fixed_issues.count > 0 %>
<%= progress_bar([version.visible_fixed_issues.closed_percent, version.visible_fixed_issues.completed_percent],
:titles =>
["%s: %i%%" % [l(:label_closed_issues_plural), version.visible_fixed_issues.closed_percent],
"%s: %i%%" % [l(:field_done_ratio), version.visible_fixed_issues.completed_percent]],
:legend => ('%i%%' % version.visible_fixed_issues.completed_percent)) %>
<%= bar_graph([
{:pcts => version.visible_fixed_issues.closed_percent, :label => l(:label_closed_issues_plural)},
{:pcts => version.visible_fixed_issues.completed_percent, :label => l(:field_done_ratio)}
],
:legend => ('%i%%' % version.visible_fixed_issues.completed_percent), :class => 'progress-bar') %>
<p class="progress-info">
<%= link_to(l(:label_x_issues, :count => version.visible_fixed_issues.count),
version_filtered_issues_path(version, :status_id => '*')) %>
public/stylesheets/application.css
}
/***** Progress bar *****/
@keyframes graph {
0% { transform: scaleX(0); transform-origin: 0;}
100% { transform: scaleX(1); transform-origin: 0;}
}
#relations .progress-bar { min-width: 100px; max-width: 150px; }
.version-overview .progress-bar { width: 30vw }
.attributes .progress-bar { width: 35%; height: 1em; }
.done-ratio .label { display: none; margin: 0; }
.progress-bar { display: flex; align-items: center; min-width: 50px; }
.progress-bar .legend { margin-left: 6px; }
.bar-graph { flex: 1 0 auto; position: relative; height: 7px; background: #ccc; }
.bar-graph span { transform: scaleX(0); animation: graph 500ms ease 100ms 1 forwards; height: inherit; position: absolute; top: 0; left: 0; transition: opacity 300ms ease; opacity: 1; }
.bar-graph span:nth-child(1) { background: #628db6; }
.bar-graph span:nth-child(2) { background: #3e5b76; }
.bar-graph span:nth-child(3) { background: #303030; }
.bar-graph:hover span:not(:hover) { opacity: 0.3; }
table.progress {
border-collapse: collapse;
border-spacing: 0pt;
(5-5/6)