term.mustache 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. <% term ||= nil %>
  19. <tr class="term" id="term_<%= term ? term.id : "blank" %>" style="<%= hidden unless term %>">
  20. <td class="header">
  21. <div class="show_term">
  22. <span class="name"><%= term.name rescue nbsp %></span>
  23. </div>
  24. <div class="show_term" style="font-size: 0.8em;">
  25. <% if term && (term.sis_source_id && can_do(@root_account, @current_user, :read_sis) || can_do(@root_account, @current_user, :manage_sis)) %>
  26. <div style="font-size: 0.8em;">
  27. <%= before_label :sis_id, "SIS ID" %> <span class="sis_source_id"><%= term.sis_source_id %></span>
  28. </div>
  29. <% end %>
  30. <% if term.try(:grading_period_group).try(:active?) %>
  31. <div style="font-size: 0.8em;">
  32. <%= before_label :grading_period_set_title, "Grading Period Set" %>
  33. <span class="grading_period_set_title">
  34. <%= link_to grading_period_set_title(term.grading_period_group, term.root_account.name),
  35. context_url(@context, :context_grading_standards_url) %>
  36. </span>
  37. </div>
  38. <% end %>
  39. <%= term && t(:course_count, "Course", :count => @course_counts_by_term[term.id] || 0) %><br/>
  40. </div>
  41. <%= form_for (term || EnrollmentTerm.new), :url => (term ? context_url(@context, :context_term_url, term.id) : context_url(@context, :context_terms_url)), :html => {:class => "enrollment_term_form", :method => (term ? :put : :post)} do |f| %>
  42. <div class="control-group edit_term">
  43. <label class="control-label" for="enrollment_term_name"><%= t :name, 'Term Name:' %></label>
  44. <div class="controls">
  45. <%= f.text_field :name, :class => "input-xlarge" %>
  46. </div>
  47. </div>
  48. <% if can_do(@root_account, @current_user, :manage_sis) %>
  49. <div class="control-group edit_term">
  50. <label class="control-label" for="enrollment_term_sis_source_id"><%= t :sis_source_id, 'SIS ID:' %></label>
  51. <div class="controls">
  52. <%= f.text_field :sis_source_id, :class => "input-xlarge" %>
  53. </div>
  54. </div>
  55. <% end %>
  56. <% end %>
  57. </td>
  58. <% types = [StudentEnrollment, TeacherEnrollment, TaEnrollment, DesignerEnrollment] %>
  59. <td class="permissions">
  60. <table>
  61. <tr class="general_dates">
  62. <td>
  63. <%= mt :term_runs_from, "**Term Runs** from" %>&nbsp;
  64. </td>
  65. <%= render :partial => 'timespan', :locals => { :object => term, :key => '', :start_tooltip => t('titles.term_starts', "Term starts"),
  66. :end_tooltip => t('titles.term_ends', "Term ends"), :whenever => [true, true] } %>
  67. </tr>
  68. <% types.each do |type| %>
  69. <% override = term.enrollment_dates_overrides.detect{|edo|
  70. edo.context_type == @context.class.to_s &&
  71. edo.context_id == @context.id &&
  72. edo.enrollment_type == type.to_s
  73. } if term %>
  74. <% override ||= EnrollmentDatesOverride.new %>
  75. <% type_string = type.to_s.underscore %>
  76. <% start_whenever = true %>
  77. <tr class="<%= "#{type_string}_dates"%>">
  78. <td>
  79. <% case type_string
  80. when 'student_enrollment'
  81. start_tooltip = t 'tooltips.term_starts_students', "For students the term starts"
  82. end_tooltip = t 'tooltips.term_ends_students', "For students the term ends"
  83. access_label = mt 'labels.students_can_access_from', "**Students** can access from"
  84. start_whenever = false
  85. when 'teacher_enrollment'
  86. start_tooltip = t 'tooltips.term_starts_teachers', "For teachers the term starts"
  87. end_tooltip = t 'tooltips.term_ends_teachers', "For teachers the term ends"
  88. access_label = mt 'labels.teachers_can_access_from', "**Teachers** can access from"
  89. when 'ta_enrollment'
  90. start_tooltip = t 'tooltips.term_starts_tas', "For TAs the term starts"
  91. end_tooltip = t 'tooltips.term_ends_tas', "For TAs the term ends"
  92. access_label = mt 'labels.tas_can_access_from', "**TAs** can access from"
  93. when 'designer_enrollment'
  94. start_tooltip = t 'tooltips.term_starts_designers', "For designers the term starts"
  95. end_tooltip = t 'tooltips.term_ends_designers', "For designers the term ends"
  96. access_label = mt 'labels.designers_can_access_from', "**Designers** can access from"
  97. end
  98. %>
  99. <%= access_label %>
  100. &nbsp;
  101. </td>
  102. <%= render :partial => 'timespan', :locals => { :object => override, :key => "[overrides][#{type_string}]",
  103. :start_tooltip => start_tooltip, :end_tooltip => end_tooltip,
  104. :date_class_prefix => "#{type_string}_", :whenever => [start_whenever, false] } %>
  105. </tr>
  106. <% end %>
  107. <tr class="edit-buttons">
  108. <td></td>
  109. <td></td>
  110. <td></td>
  111. <td class="edit_term edit_term_buttons">
  112. <button class="btn button-secondary cancel_button" type="button"><%= t '#buttons.cancel', "Cancel" %></button>
  113. <button class="btn btn-primary submit_button" type="button"><%= term ? t('buttons.update', "Update Term") : t('buttons.add', "Add Term") %></button>
  114. </td>
  115. </tr>
  116. </table>
  117. </td>
  118. <td class="links">
  119. <a href="#" class="edit_term_link no-hover" title="<%= t 'Edit Term %{name}', name: term.try(:name) %>"><i class="icon-edit standalone-icon" aria-hidden="true"></i></a>
  120. <% if term && @course_counts_by_term[term.id].to_i > 0 %>
  121. <a href="#" class="cant_delete_term_link no-hover" title="<%= t 'Delete Term %{name}', name: term.try(:name) %>"><i class="icon-end standalone-icon" aria-hidden="true"></i></a>
  122. <% elsif term != @context.default_enrollment_term %>
  123. <a href="#" class="delete_term_link no-hover" title="<%= t 'Delete Term %{name}', name: term.try(:name) %>"><i class="icon-trash standalone-icon" aria-hidden="true"></i></a>
  124. <% end %>
  125. </td>
  126. </tr>