Skip to content

Commit

Permalink
Added ticket-grouping (hidden) / Bug fix for ticket-references
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitrij Denissenko committed Mar 31, 2009
1 parent cd2e818 commit d0ec4de
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/helpers/format_helper.rb
Expand Up @@ -2,15 +2,15 @@ module FormatHelper
include NavigationHelper

def datetime_format(datetime)
datetime.strftime(RetroCM[:content][:format][:datetime])
I18n.l datetime.to_time, :format => RetroCM[:content][:format][:datetime]
end

def date_format(datetime)
datetime.strftime(RetroCM[:content][:format][:date])
I18n.l datetime.to_date, :format => RetroCM[:content][:format][:date]
end

def time_format(datetime)
datetime.strftime(RetroCM[:content][:format][:time])
I18n.l datetime, :format => RetroCM[:content][:format][:time]
end

def boolean_format(value, t_yes = nil, t_no = nil)
Expand Down Expand Up @@ -133,7 +133,7 @@ def format_internal_ticket_link(ticket_id, options = {})

def find_project_for_ticket(ticket_id)
projects = RetroCM[:content][:markup][:global_ticket_refs] ? User.current.active_projects : [Project.current]
projects.find do |project|
projects.detect do |project|
!project.existing_tickets[ticket_id].blank?
end
end
Expand Down
29 changes: 28 additions & 1 deletion app/helpers/tickets_helper.rb
Expand Up @@ -7,7 +7,7 @@ def html_classes_for_ticket(ticket)

def last_change_content_one_line(ticket)
if ticket.changes.last.nil? or ticket.changes.last.content.blank?
''
h(datetime_format(ticket.updated_at))
else
content = "#{ticket.changes.last.author} (#{datetime_format(ticket.updated_at)})"
content += ": " + truncate(ticket.changes.last.content.squish, :length => 600)
Expand Down Expand Up @@ -109,6 +109,33 @@ def toggle_internal_navigation(open, close)
).squish
end

GROUP_BY_PROCS = {
'update' => lambda { |t| t.updated_at.end_of_week.to_date }
}

def render_grouped(tickets, group_by = nil)
return render(tickets) unless GROUP_BY_PROCS[group_by]

tickets.group_by(&GROUP_BY_PROCS[group_by]).map do |value, ticket_group|

spacer = content_tag :td, ticket_spacer_value(value, group_by),
:class => 'group quieter strong centered',
:colspan => ( property_types.any? ? 8 : 7 )

"<tr>#{spacer}</tr>" + render(ticket_group)

end.join("\n")
end

def ticket_spacer_value(value, group_by)
case group_by
when 'update'
h(date_format(value))
else
'&ndash'
end
end

protected

def html_class_for_ticket_state(ticket)
Expand Down
2 changes: 1 addition & 1 deletion app/models/association_proxies/active_user_projects.rb
Expand Up @@ -11,7 +11,7 @@ def initialize(user)
super(records)
end

def find(param)
def find(*args)
case param
when String
detect {|i| i.to_param == param }
Expand Down
2 changes: 1 addition & 1 deletion app/views/tickets/index.html.erb
Expand Up @@ -46,7 +46,7 @@
</tfoot>

<tbody id="tickets">
<%= render :partial => 'ticket', :collection => @tickets %>
<%= render_grouped @tickets, params[:group] %>
</tbody>
</table>

Expand Down
Binary file added public/images/bg.group.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions public/stylesheets/app/tickets.css
Expand Up @@ -5,6 +5,14 @@
.tickets .content-header { margin-bottom:1em; border-color: #ccc; }
.tickets .internal-navigation { border-top:0; margin-top:-10px; padding-bottom:0.5em; }

.tickets table tbody td.group,
.tickets table tbody td.group:hover {
line-height:1;
padding:3px 1em 2px; font-size:90%;
background:#d2d2d2 url(../../images/bg.group.gif) left bottom repeat-x;
border:1px solid #aaa; border-bottom:1px solid #999;
}

.ticket-statement-positive .ticket-col-id a,
.ticket-statement-positive .ticket-col-status a,
.ticket-statement-positive .ticket-col-summary h6 a { color: #672; }
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/res/tables.css
Expand Up @@ -61,7 +61,7 @@ table.record-list {

table.record-list thead th {
background: #fff url(../../images/menu_item.png) repeat-x;
color: #000; border: 1px solid #ddd; border-bottom: 1px solid #ccc;
color: #000; border: 1px solid #ccc; border-bottom: 1px solid #bbb;
}
table.record-list thead td { color: #000; padding: 2px 0 4px 0;}
table.record-list thead td input { width: auto; border: 1px solid #999;}
Expand Down
3 changes: 2 additions & 1 deletion spec/helpers/format_helper_spec.rb
Expand Up @@ -141,7 +141,8 @@ def do_find
describe 'if global ticket references are enabled' do
it 'should search for tickets within all user-accessible projects' do
RetroCM[:content][:markup].should_receive(:[]).with(:global_ticket_refs).and_return(true)
@user.should_receive(:active_projects).and_return([])
@user.should_receive(:admin?).and_return(true)
@user.should_receive(:active_projects).and_return(AssociationProxies::ActiveUserProjects.new(@user))
do_find.should be_nil
end
end
Expand Down

0 comments on commit d0ec4de

Please sign in to comment.