<% if my_module.blank? and @my_module.present? then my_module = @my_module end %>
<% if order.blank? and @order.present? then order = @order end %>
<% timestamp = Time.current + 1.year - 2.days %>
<% activities = my_module.activities.order(created_at: order) %>
<div class="report-element report-module-activity-element" data-ts="<%= timestamp.to_i %>" data-type="my_module_activity" data-id='{ "my_module_id": <%= my_module.id %> }' data-scroll-id="<%= my_module.id %>" data-order="<%= order == :asc ? "asc" : "desc" %>" data-name="<%=t "projects.reports.elements.module_activity.sidebar_name" %>" data-icon-class="fas fa-list">
  <div class="report-element-header">
    <div class="row">
      <div class="pull-left activity-icon">
        <span class="fas fa-list"></span>
      </div>
      <div class="pull-left activity-name">
        <%=t "projects.reports.elements.module_activity.name", my_module: my_module.name %>
      </div>
      <div class="pull-right controls">
        <%= render partial: "reports/elements/element_controls.html.erb", locals: { show_sort: true } %>
      </div>
    </div>
  </div>
  <div class="report-element-body">
    <div class="row">
      <div class="col-xs-12 activity-container">
        <% if activities.count > 0 %>
          <!-- TODO: This might become potentially very big! -->
          <ul class="no-style activity-list">
            <% activities.each do |activity| %>
              <% activity_ts = activity.created_at %>
              <li class="activity" data-ts="<%= activity_ts.to_i %>">
                <span class="activity-prefix">
                  <%=l activity_ts, format: :full %>
                </span>
                <span class="activity-message">
                  &nbsp;
                  <%= sanitize_input(activity.message) %>
                </span>
              </li>
            <% end %>
          </ul>
        <% else %>
          <em><%=t "projects.reports.elements.module_activity.no_activity" %></em>
        <% end %>
      </div>
    </div>
  </div>
  <div class="report-element-children">
    <%= children if (defined? children and children.present?) %>
  </div>
</div>
