recent_activity.mustache 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <%
  2. # Copyright (C) 2012 - present Instructure, Inc.
  3. #
  4. # This file is part of Canvas.
  5. #
  6. # Canvas is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU Affero General Public License as published by the Free
  8. # Software Foundation, version 3 of the License.
  9. #
  10. # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
  11. # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  12. # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
  13. # details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License along
  16. # with this program. If not, see <http://www.gnu.org/licenses/>.
  17. %>
  18. <h2 class="recent-activity-header">
  19. <% if @context.nil? || @context.is_a?(User) %>
  20. <%= t :recent_activity, "Recent Activity" %>
  21. <% else %>
  22. <%= t :recent_activity_in_course, "Recent Activity in %{course_or_group}", :course_or_group => @context.nickname_for(@current_user, :short_name) %>
  23. <% end %>
  24. </h2>
  25. <ul class="recent_activity unstyled_list">
  26. <% categorized_items =
  27. Rails.cache.fetch(['categorized_stream_items', @current_user, collection_cache_key(@stream_items)].cache_key, :expires_in => 15.minutes) do
  28. categorize_stream_items(@stream_items)
  29. end
  30. %>
  31. <% %w(Announcement Conversation Assignment DiscussionTopic AssessmentRequest).each do |category| %>
  32. <% items = categorized_items[category] %>
  33. <% category_class = category.underscore %>
  34. <% if items.present? %>
  35. <li class="stream-category stream-<%= category_class %>" data-category="<%= category %>">
  36. <div class="stream_header">
  37. <div class="image-block">
  38. <div class=image-block-image>
  39. <i class="<%= {
  40. 'conversation' => 'icon-message',
  41. 'grading' => 'icon-check-plus',
  42. 'discussion_topic' => 'icon-discussion',
  43. 'assessment_request' => 'icon-peer-review'
  44. }[category_class] || "icon-#{category_class}" %>"></i>
  45. </div>
  46. <div class=image-block-content>
  47. <div class=title>
  48. <%= activity_category_title(category, items) %>
  49. </div>
  50. <% unread_count = items.select { |i| i.unread }.size %>
  51. <% if unread_count > 0 %>
  52. <strong class="unread-count">
  53. <span class="accessibly-hidden"><%= t(:unread_count_badge, { :one => "1 *unread item*", :other => "%{count} *unread items*" },
  54. :count => unread_count,
  55. :wrapper => '<span>\1</span>') %>
  56. </span>
  57. </strong>
  58. <% end %>
  59. <div class="links">
  60. <%= activity_category_links(category, items) %>
  61. </div>
  62. </div>
  63. </div>
  64. <div class=header-right-side>
  65. <a href="#" class="toggle-details" aria-controls="details_container"></a>
  66. </div>
  67. </div>
  68. <div class='details_container'>
  69. <table id="<%= category_class %>-details" class="stream-details">
  70. <caption class="accessibly-hidden"><%= category_details_label(category) %></caption>
  71. <thead class="accessibly-hidden">
  72. <tr>
  73. <th scope="col">{{#t}}Unread{{/t}}</th>
  74. <th scope="col">{{#t}}Message{{/t}}</th>
  75. <th scope="col">{{#t}}Date{{/t}}</th>
  76. <th></th>
  77. </tr>
  78. </thead>
  79. {{> views/shared/recent_activity_item}}
  80. </table>
  81. </div>
  82. </li>
  83. <% end %>
  84. <% end %>
  85. </ul>
  86. <% if categorized_items.values.map(&:count).sum == 0 %>
  87. {{> views/shared/no_recent_activity}}
  88. <% end %>