enrollment_term_select.mustache 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <%
  2. # Copyright (C) 2016 - 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. <% default_term ||= @root_account.default_enrollment_term %>
  19. <% terms = terms.not_default %>
  20. <% selected_id ||= nil %>
  21. <% exclude_all_option ||= false %>
  22. <% name ||= 'enrollment_term_id' %>
  23. <% id ||= 'enrollment_term_id' %>
  24. <select id="<%= id %>" name="<%= name %>">
  25. <% unless exclude_all_option %>
  26. <option value="" <%= 'selected' unless selected_id %>>{{#t}}All Terms{{/t}}</option>
  27. <% end %>
  28. <% if default_term %>
  29. <option value="<%= default_term.id %>" <%= 'selected' if default_term.id == selected_id %>><%= default_term.name %></option>
  30. <% end %>
  31. <% if terms.started.not_ended.any? %>
  32. <optgroup label="{{#t}}Active Terms{{/t}}">
  33. <% terms.started.not_ended.by_name.each do |term| %>
  34. <option value="<%= term.id %>" <%= 'selected' if term.id == selected_id %>><%= term.name %></option>
  35. <% end %>
  36. </optgroup>
  37. <% end %>
  38. <% if terms.not_started.any? %>
  39. <optgroup label="{{#t}}Future Terms{{/t}}">
  40. <% terms.not_started.by_name.each do |term| %>
  41. <option value="<%= term.id %>" <%= 'selected' if term.id == selected_id %>><%= term.name %></option>
  42. <% end %>
  43. </optgroup>
  44. <% end %>
  45. <% if terms.ended.any? %>
  46. <optgroup label="{{#t}}Past Terms{{/t}}">
  47. <% terms.ended.by_name.each do |term| %>
  48. <option value="<%= term.id %>" <%= 'selected' if term.id == selected_id %>><%= term.name %></option>
  49. <% end %>
  50. </optgroup>
  51. <% end %>
  52. </select>