edit_account_notification.mustache 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. <%= form_for :account_notification,
  19. url: {controller: 'account_notifications', action: 'update', id: announcement.id},
  20. html: {
  21. id: "edit_notification_form_#{announcement.id}",
  22. class: 'edit_notification_form hidden_form',
  23. role: 'region',
  24. method: 'put' } do |f| %>
  25. <div class="grid-row">
  26. <div class="col-xs-12 col-lg-6">
  27. <div class="ic-Form-control">
  28. <label for="<%= "account_notification_subject_#{announcement.id}" %>" class="ic-Label">
  29. {{#t}}Title{{/t}}
  30. </label>
  31. <%= f.text_field :subject, :value => announcement.subject, :class => 'ic-Input', :id => "account_notification_subject_#{announcement.id}" %>
  32. </div>
  33. </div>
  34. <div class="col-xs-12 col-lg-6">
  35. <div class="ic-Form-control">
  36. <label for="account_notification_icon" class="ic-Label">
  37. {{#t}}Announcement type{{/t}}
  38. </label>
  39. <select id="account_notification_icon" class="ic-Input" name="account_notification[icon]">
  40. <%= options_for_select([[t("information"), "information", {:class=>"information"}],
  41. [t("error"), "error", {:class=>"error"}],
  42. [t("warning"), "warning", {:class=>"warning"}],
  43. [t("question"), "question", {:class=>"question"}],
  44. [t("calendar"), "calendar", {:class=>"calendar"}]], announcement.icon) %>
  45. </select>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="ic-Form-control">
  50. <label for="account_notification_message_<%= announcement.id %>" class="ic-Label">
  51. {{#t}}Message{{/t}}
  52. </label>
  53. <%= f.text_area :message, :value => announcement.message, :id => "account_notification_message_#{announcement.id}", :class => 'alert_message edit_notification_form' %>
  54. <% if @account.site_admin? %>
  55. <p>{{#t}}Enter \"{{ACCOUNT_DOMAIN}}\" to substitute the user's root account domain{{/t}}</p>
  56. <p>{{#t}}Enter \"{{CANVAS_USER_ID}}\" to substitute the user's unique Canvas ID{{/t}}</p>
  57. <% end %>
  58. </div>
  59. <div class="ic-Form-control">
  60. <div class="ic-Label" id="aria-announcements-send-to-group">
  61. <%= t "Send to" %>
  62. <%= roles_message(@account) %>
  63. </div>
  64. <div class="grid-row">
  65. <div class="col-xs-12 col-lg-4">
  66. <i><%= t "Course roles" %></i>
  67. <div class="ic-Checkbox-group" role="group" aria-labelledby="aria-announcements-send-to-group">
  68. <% role_ids = announcement.account_notification_roles.map {|r| r.role_id} %>
  69. <% @course_roles.each do |r| %>
  70. <% course_role_checked = role_ids.include? r[:id] %>
  71. <div class="ic-Form-control ic-Form-control--checkbox">
  72. <%= check_box_tag "account_notification_roles[]", r[:id], course_role_checked, { :class => "account_notification_role_cbx", :id => "account_notification_role_#{r[:id]}_cbx_#{announcement.id}" } %>
  73. <label class="ic-Label" for="<%= "account_notification_role_#{r[:id]}_cbx_#{announcement.id}" %>">
  74. <%= r[:label] %>
  75. <span class="screenreader-only">
  76. <%=t "Send this announcement to users with the course role of %{role}", :role => r[:label] %>
  77. </span>
  78. </label>
  79. </div>
  80. <% end %>
  81. <% if @account.root_account? %>
  82. <% nil_role_checked = role_ids.include? nil %>
  83. <div class="ic-Form-control ic-Form-control--checkbox">
  84. <%= check_box_tag "account_notification_roles[]", "NilEnrollment", nil_role_checked, { :class => "account_notification_role_cbx", :id => "account_notification_role_NilEnrollment_cbx_#{announcement.id}" } %>
  85. <label class="ic-Label" for="<%= "account_notification_role_NilEnrollment_cbx_#{announcement.id}" %>">
  86. <%= t "Unenrolled users" %>
  87. <span class="screenreader-only">
  88. <%=t "Send this announcement to unenrolled users" %>
  89. </span>
  90. </label>
  91. </div>
  92. <% end %>
  93. </div>
  94. </div>
  95. <div class="col-xs-12 col-lg-4">
  96. <i><%= t "Account roles" %></i>
  97. <% @account_roles.each do |r| %>
  98. <% account_role_checked = role_ids.include? r[:id] %>
  99. <div class="ic-Form-control ic-Form-control--checkbox">
  100. <%= check_box_tag "account_notification_roles[]", r[:id], account_role_checked, { :class => "account_notification_role_cbx", :id => "account_notification_role_#{r[:id]}_cbx_#{announcement.id}" } %>
  101. <label class="ic-Label" for="<%= "account_notification_role_#{r[:id]}_cbx_#{announcement.id}" %>">
  102. <%= r[:label] %>
  103. <span class="screenreader-only">
  104. <%=t "Send this announcement to users with the account role of %{role}", :role => r[:label] %>
  105. </span>
  106. </label>
  107. </div>
  108. <% end %>
  109. </div>
  110. </div>
  111. </div>
  112. <div class="grid-row">
  113. <div class="col-xs-12 col-lg-6">
  114. <div class="ic-Form-control">
  115. <label class="ic-Label" id="announcement_starts_at_label">
  116. {{#t}}Announcement starts at{{/t}}
  117. <span class="screenreader-only">
  118. <%= datepicker_screenreader_prompt %>
  119. </span>
  120. </label>
  121. <% if announcement.start_at < Date.today %>
  122. <%= f.text_field :start_at,
  123. :value => announcement.start_at.strftime('%b %d, %Y %-I:%M%P'),
  124. :id => "account_notification_start_at_#{announcement.id}",
  125. "aria-labelledby" => "announcement_starts_at_label",
  126. :title => accessible_date_format,
  127. :readonly => true %>
  128. <% else %>
  129. <%= f.text_field :start_at,
  130. :value => announcement.start_at.strftime('%b %d, %Y %-I:%M%P'),
  131. :id => "account_notification_start_at_#{announcement.id}",
  132. :class => 'datetime_field',
  133. "aria-labelledby" => "announcement_starts_at_label",
  134. "data-tooltip" => "",
  135. :title => accessible_date_format %>
  136. <% end %>
  137. </div>
  138. </div>
  139. <div class="col-xs-12 col-lg-6">
  140. <div class="ic-Form-control">
  141. <label class="ic-Label" id="announcement_ends_at_label">
  142. {{#t}}Announcement ends at{{/t}}
  143. <span class="screenreader-only">
  144. <%= datepicker_screenreader_prompt %>
  145. </span>
  146. </label>
  147. <% if announcement.end_at < Date.today %>
  148. <%= f.text_field :end_at,
  149. :value => announcement.end_at.strftime('%b %d, %Y %-I:%M%P'),
  150. :id => "account_notification_end_at_#{announcement.id}",
  151. "aria-labelledby" => "announcement_ends_at_label",
  152. :title => accessible_date_format,
  153. :readonly => true %>
  154. <% else %>
  155. <%= f.text_field :end_at,
  156. :value => announcement.end_at.strftime('%b %d, %Y %-I:%M%P'),
  157. :id => "account_notification_end_at_#{announcement.id}",
  158. :class => 'datetime_field',
  159. "aria-labelledby" => "announcement_ends_at_label",
  160. "data-tooltip" => "",
  161. :title => accessible_date_format %>
  162. <% end %>
  163. </div>
  164. </div>
  165. </div>
  166. <div class="ic-Form-actions">
  167. <%= button_tag(t("Cancel"), :class => "element_toggler btn button-secondary edit_cancel_focus", 'aria-controls' => "edit_notification_form_#{announcement.id}", 'data-cancel-focus-id' => announcement.id) %>
  168. <%= button_tag(t("Save Changes"), :class => 'btn btn-primary') %>
  169. </div>
  170. <% end %>