Skip to content

Commit

Permalink
fixed minor issues related to group_by option, added bold face for
Browse files Browse the repository at this point in the history
current issue in subissues_list on 'show' action.
  • Loading branch information
hron committed Jun 25, 2009
1 parent f89f3ab commit c507a38
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 47 deletions.
31 changes: 21 additions & 10 deletions app/views/issues/_list.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,28 @@
<% end %>
</tr></thead>
<tbody>
<% if query.view_options['show_parents'] == ViewOption::SHOW_PARENTS[:never] -%>
<% group = false %>
<% emphasis_issues ||= [] %>
<% unless query.view_options['show_parents'] == ViewOption::SHOW_PARENTS[:organize_by] -%>
<% issues.each do |issue| -%>
<%= issue_content( issue, query) %>
<% end -%>
<% elsif query.view_options['show_parents'] == ViewOption::SHOW_PARENTS[:always] -%>
<% issues.each do |issue| -%>
<% issue.ancestors.reverse.each do |parent_issue| -%>
<%= issue_content( parent_issue, query, :unfiltered => true) %>
<% if @query.grouped? && issue.send(@query.group_by) != group %>
<% group = issue.send(@query.group_by) %>
<% reset_cycle %>
<tr class="group open">
<td colspan="<%= query.columns.size + 2 %>">
<span class="expander" onclick="toggleRowGroup(this); return false;">&nbsp;</span>
<%= group.blank? ? 'None' : group %> <span class="count">(<%= @issue_count_by_group[group] %>)</span>
</td>
</tr>
<% end %>
<% if query.view_options['show_parents'] == ViewOption::SHOW_PARENTS[:always] -%>
<% issue.ancestors.reverse.each do |parent_issue| -%>
<%= issue_content( parent_issue, query, :unfiltered => true) %>
<% end -%>
<% end -%>
<%= issue_content( issue, query) %>
<%= issue_content( issue, query, :emphasis => ( emphasis_issues ? emphasis_issues.include?( issue) : false)) %>
<% end -%>
<% elsif query.view_options['show_parents'] == ViewOption::SHOW_PARENTS[:organize_by] -%>
<% else -%>
<% parents_on_first_lvl = []
issues.each do |i|
if i.parent
Expand All @@ -32,9 +42,10 @@
parents_on_first_lvl += [ first_parent ] unless parents_on_first_lvl.include?( first_parent)
end -%>
<% parents_on_first_lvl.each do |parent| -%>
<%= issues_family_content( parent, issues, query) %>
<%= issues_family_content( parent, issues, query, emphasis_issues) %>
<% end -%>
<% end -%>
</tbody>
</table>
<% end -%>

13 changes: 7 additions & 6 deletions app/views/issues/_subissues_list.rhtml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<% if @issue.root.self_and_descendants.size > 1 %>
<% if @issue.root.self_and_descendants.size > 1 %>
<% content_for :header_tags do %>
<%= javascript_include_tag 'context_menu' %>
<%= stylesheet_link_tag 'context_menu' %>
<% end %>
<hr />
<p><strong><%=l(:subtasks_label_subissues)%></strong></p>
<div id="subissues">
<%= render( :partial => 'issues/list',
:locals => {
:issues => @issue.root.self_and_descendants,
:query => @query }) %>
<%= render( :partial => 'issues/list',
:locals => {
:issues => @issue.root.self_and_descendants,
:emphasis_issues => [ @issue ],
:query => @query }) %>
</div>
<div id="context-menu" style="display: none;"></div>
<%= javascript_tag "new ContextMenu('#{url_for(:controller => 'issues', :action => 'context_menu')}')" %>
<% end %>
<% end %>
4 changes: 4 additions & 0 deletions assets/stylesheets/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
filter: alpha(opacity=50);
}

.issue-emphasis {
font-weight: bold;
}

.expanded-issue {
background-image: url(contract.png);
background-repeat: no-repeat;
Expand Down
42 changes: 36 additions & 6 deletions lib/redmine_subtasks/redmine_ext/issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ def after_save
# Update start/due dates of following issues
relations_from.each(&:set_issue_to_dates)

# If target version is set, but "Due to" date is not, set
# it as the same as the date of target version.
if leaf? && due_date.nil? && fixed_version && fixed_version.due_date
self.update_attribute :due_date, fixed_version.due_date
end

if parent
# Set default status of parent if new status opened the issue.
if !status.is_closed? && parent.status.is_closed?
Expand All @@ -86,11 +92,6 @@ def after_save
end
end

# If target version is set, but "Due to" date is not, set
# it as the same as the date of target version.
if leaf? && due_date.nil? && fixed_version && fixed_version.due_date
self.update_attribute :due_date, fixed_version.due_date
end

# Close duplicates if the issue was closed
if @issue_before_change && !@issue_before_change.closed? && self.closed?
Expand All @@ -106,6 +107,35 @@ def after_save
end
end

def create_journal_with_subtasks
if @current_journal
# attributes changes
skip_attrs = %w(id description lock_version created_on updated_on)
skip_attrs += %w(due_date done_ratio estimated_hours) unless leaf?

(Issue.column_names - skip_attrs).each do |c|
unless send(c)==@issue_before_change.send(c)
@current_journal.details << JournalDetail.new(:property => 'attr',
:prop_key => c,
:old_value => @issue_before_change.send(c),
:value => send(c))
end
end

# custom fields changes
custom_values.each {|c|
next if (@custom_values_before_change[c.custom_field_id]==c.value ||
(@custom_values_before_change[c.custom_field_id].blank? && c.value.blank?))
@current_journal.details << JournalDetail.new(:property => 'cf',
:prop_key => c.custom_field_id,
:old_value => @custom_values_before_change[c.custom_field_id],
:value => c.value)
}
@current_journal.save
end
end
alias_method_chain :create_journal, :subtasks

# Moves/copies an issue to a new project and tracker
# Returns the moved/copied issue on success, false on failure
def move_to(new_project, new_tracker = nil, options = {})
Expand Down Expand Up @@ -192,7 +222,7 @@ def estimated_hours

def due_date
if leaf?
read_attribute(:due_date)
read_attribute( :due_date)
else
dates = children.map( &:due_date)
dates.max if ( dates && dates.any?)
Expand Down
57 changes: 32 additions & 25 deletions lib/redmine_subtasks/redmine_ext/queries_helper_patch.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require_dependency 'queries_helper'
require 'queries_helper'

module RedmineSubtasks
module RedmineExt
Expand All @@ -15,27 +15,32 @@ def self.included(base) # :nodoc:
module InstanceMethods

def column_content_with_subtasks(column, issue, query)
if column.is_a?(QueryCustomFieldColumn)
cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
show_value(cv)
# if column.is_a?(QueryCustomFieldColumn)
# cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
# show_value(cv)
# else
# value = issue.send(column.name)
# if value.is_a?(Date)
# format_date(value)
# elsif value.is_a?(Time)
# format_time(value)
# else
# case column.name
# when :subject
# subject_in_tree(issue, value, query)
# when :done_ratio
# progress_bar(value, :width => '80px')
# when :fixed_version
# link_to(h(value), { :controller => 'versions', :action => 'show', :id => issue.fixed_version_id })
# else
# h(value)
# end
# end
# end
if column.name == :subject
subject_in_tree( issue, issue.send( column.name), query)
else
value = issue.send(column.name)
if value.is_a?(Date)
format_date(value)
elsif value.is_a?(Time)
format_time(value)
else
case column.name
when :subject
subject_in_tree(issue, value, query)
when :done_ratio
progress_bar(value, :width => '80px')
when :fixed_version
link_to(h(value), { :controller => 'versions', :action => 'show', :id => issue.fixed_version_id })
else
h(value)
end
end
column_content_without_subtasks column, issue
end
end

Expand All @@ -61,24 +66,26 @@ def issue_content(issue, query, options = { })
html = ""
html << "<tr id=\"issue-#{issue.id}\" class=\"issue hascontextmenu " +
( options[:unfiltered] ? 'issue-unfiltered ' : '') +
( options[:emphasis] ? 'issue-emphasis ' : '' ) +
"status-#{issue.status.position} priority-#{issue.priority.position} " +
cycle('odd', 'even') + '">'
html << '<td class="checkbox">' + check_box_tag( "ids[]", issue.id, false, :id => nil) + '</td>'
html << '<td>' + link_to( issue.id, :controller => 'issues', :action => 'show', :id => issue) + '</td>'
query.columns.each do |column|
html << content_tag( 'td', column_content(column, issue, query), :class => column.name)
html << content_tag( 'td', column_content_with_subtasks(column, issue, query), :class => column.name)
end
html << "</tr>"
html
end

def issues_family_content( parent, issues_to_show, query)
def issues_family_content( parent, issues_to_show, query, emphasis_issues)
html = ""
html << issue_content( parent, query, :unfiltered => !( issues_to_show.include? parent))
html << issue_content( parent, query, :unfiltered => !( issues_to_show.include? parent),
:emphasis => ( emphasis_issues ? emphasis_issues.include?( parent) : false))
unless parent.children.empty?
parent.children.each do |child|
if issues_to_show.include?( child) || issues_to_show.detect { |i| i.ancestors.include? child }
html << issues_family_content( child, issues_to_show, query)
html << issues_family_content( child, issues_to_show, query, emphasis_issues)
end
end
end
Expand Down

0 comments on commit c507a38

Please sign in to comment.