event_list.mustache 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <%
  2. # Copyright (C) 2011 - 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. <%
  19. event_list ||= nil
  20. title ||= t('titles.events', "Events")
  21. display_count ||= 3
  22. display_count += 1 if event_list.length == display_count + 1
  23. period ||= nil
  24. show_context ||= false
  25. show_more ||= true
  26. upcoming ||= false
  27. is_recent_feedback ||= false
  28. partial = is_recent_feedback ? 'courses/recent_feedback' : 'courses/recent_event'
  29. contexts_to_link_to ||= nil
  30. %>
  31. <div class="events_list <%= is_recent_feedback ? 'recent_feedback' : 'coming_up' %>">
  32. <h2><% unless is_recent_feedback %><a class='event-list-view-calendar icon-calendar-day standalone-icon' href='<%= calendar_url_for(contexts_to_link_to) %>'><%= t 'links.view_calendar', "View Calendar" %></a><% end %> <%= title %></h2>
  33. <ul class="right-side-list events">
  34. <% if !event_list || event_list.empty? %>
  35. <li>
  36. <small>
  37. <% if period == :one_week %>
  38. {{#t}}Nothing for the next week{{/t}}
  39. <% elsif period == :two_weeks && !is_recent_feedback %>
  40. {{#t}}Nothing for the next two weeks{{/t}}
  41. <% else %>
  42. {{#t}}Nothing for now{{/t}}
  43. <% end %>
  44. </small>
  45. </li>
  46. <% else %>
  47. <% (event_list || []).each_with_index do |e, i| %>
  48. <%= render :partial => partial, :object => e, :locals => {:show_context => show_context, :is_hidden => i >= display_count, :upcoming => upcoming } %>
  49. <% end %>
  50. <% if event_list.length > display_count && show_more %>
  51. <li>
  52. <a href="#" class="more_link">
  53. <% if event_list.length >= 20 %>
  54. <% if upcoming %>
  55. <% if period == :one_week %>
  56. <%= t('at_least_more_events_one_week_future', 'at least %{count_of_events} more in the next week', :count_of_events => (event_list.length - display_count)) %>
  57. <% elsif period == :two_weeks %>
  58. <%= t('at_least_more_events_two_weeks_future', 'at least %{count_of_events} more in the next two weeks', :count_of_events => (event_list.length - display_count)) %>
  59. <% else %>
  60. <%= t('at_least_more_events', 'at least %{count_of_events} more', :count_of_events => (event_list.length - display_count)) %>
  61. <% end %>
  62. <% else %>
  63. <% if period == :one_week %>
  64. <%= t('at_least_more_events_one_week', 'at least %{count_of_events} more in the past week', :count_of_events => (event_list.length - display_count)) %>
  65. <% elsif period == :two_weeks %>
  66. <%= t('at_least_more_events_two_weeks', 'at least %{count_of_events} more in the past two weeks', :count_of_events => (event_list.length - display_count)) %>
  67. <% else %>
  68. <%= t('at_least_more_events', 'at least %{count_of_events} more', :count_of_events => (event_list.length - display_count)) %>
  69. <% end %>
  70. <% end %>
  71. <% else %>
  72. <% if upcoming %>
  73. <% if period == :one_week %>
  74. <%= t('more_events_one_week_future', '%{count_of_events} more in the next week', :count_of_events => (event_list.length - display_count)) %>
  75. <% elsif period == :two_weeks %>
  76. <%= t('more_events_two_weeks_future', '%{count_of_events} more in the next two weeks', :count_of_events => (event_list.length - display_count)) %>
  77. <% else %>
  78. <%= t('more_events', '%{count_of_events} more', :count_of_events => (event_list.length - display_count)) %>
  79. <% end %>
  80. <% else %>
  81. <% if period == :one_week %>
  82. <%= t('more_events_one_week', '%{count_of_events} more in the past week', :count_of_events => (event_list.length - display_count)) %>
  83. <% elsif period == :two_weeks %>
  84. <%= t('more_events_two_weeks', '%{count_of_events} more in the past two weeks', :count_of_events => (event_list.length - display_count)) %>
  85. <% else %>
  86. <%= t('more_events', '%{count_of_events} more', :count_of_events => (event_list.length - display_count)) %>
  87. <% end %>
  88. <% end %>
  89. <% end %>
  90. &hellip;</a>
  91. </li>
  92. <% end %>
  93. <% end %>
  94. </ul>
  95. </div>