Skip to content

Instantly share code, notes, and snippets.

@josephj
Created January 28, 2014 06:25
Show Gist options
  • Save josephj/8663108 to your computer and use it in GitHub Desktop.
Save josephj/8663108 to your computer and use it in GitHub Desktop.
<%
title = (title.blank?) ? t('shared.activity_list.title') : title
is_empty = (activities.size == 0)
has_pagination = (activities.size > 0)
type = controller_name.singularize
action_path = activities_path(:type => type,
:id => params[:id],
:start_date => params[:start_date] )
if activities.try(:last)
query = params.except(:controller, :action).merge(:last_timestamp => activities.last.try(:created_at).to_i).to_query
next_path = "/activities?#{query}"
end
%>
<div id="activity-list" data-url="<%= action_path %>" class="medium-small">
<div class="mod-content">
<div class="hd bar clearfix">
<h3 class="title"><%= title %></h3>
<div class="dropform-group pull-right">
<%= button_tag :class => 'btn btn-icon btn-filter btn-toggle-filter', :data => { :toggle => 'dropform', :align => 'right' } do %>
<i class="kbp kbp-filter"></i>
<%= t('shared.activity_list.filter') %>
<% end %>
<%= render :partial => 'shared/activity_filter', :locals => { :action_path => action_path,
:departments => @departments,
:systems => @systems,
:filter_types => @filter_types,
:task_categories => @task_categories } %>
</div>
</div>
<div class="bd">
<ol class="activity-list<%= active_str(is_empty, true, ' activity-list-empty') %>">
<%= content_tag(:li, simple_format(t('shared.activity.empty')), :class => 'no-activity') if is_empty %>
<% activities.each_with_index do |activity, i|
activity.id = i + 1
type = activity.activity_type.gsub(/\./, '_')
dashed_type = type.gsub(/_/, '-')
title = activity.activity_type.gsub(/\./, ' ').titleize %>
<li id="activity-<%= activity.id %>" class="activity <%= activity_class(activity) %> <%= activity_sub_class(activity) %>">
<div class="type cell">
<i class="kba kba-<%= dashed_type %>" data-toggle="tooltip" title="<%= title %>"></i>
</div>
<div class="content cell">
<% content_for :tasks, '', :flush => true # Force flush content %>
<% begin %>
<%= render :partial => "shared/activity_#{type}", :locals => { :type => type,
:activity => activity,
:user => activity.user,
:contact => activity.contact } %>
<% rescue => e %>
<%= activity.activity_type %>
<% Airbrake.notify(e) %>
<% end %>
</div>
<div class="user mini cell">
<% if activity.user %>
<%= image_tag activity.user.avatar, :size => '25x25' %>
<%= link_to activity.user.full_name, '#', :class => 'name' %>
<% end %>
<div class="created-at mini">
<div class="datetime"><%= activity.created_at.to_standard_time %></div>
<div class="relative">(<%= time_ago_in_words(activity.created_at) %> ago)</div>
</div>
<%= yield :tasks if content_for?(:tasks) %>
</div>
</li>
<% end %>
<li class="activity" style="display:none">
<a href="<%== next_path %>" rel="next">Next</a>
</li>
</ol>
</div>
<div class="ft">
<%= content_tag(:div, :class => 'bar bar-pagination') do %>
<div class="wrapper">
<ul class="pagination">
<li>
<a href="<%== next_path %>" rel="next" class="btn shadow">Next</a>
</li>
</ul>
</div>
<% end if has_pagination %>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment