sub_accounts.mustache 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. <% account ||= nil; current_depth ||= 0; depth ||= 1; max_sub_accounts ||= 100; sub_account_count ||= account.try(:sub_account_count); course_count ||= account.try(:course_count) %>
  19. <% keep_going = current_depth < depth %>
  20. <div id="account_<%= account ? account.id : "blank" %>" class="account" style="<%= hidden unless account %>">
  21. <div class="header">
  22. <div class="show_account">
  23. <span class="id" style="display: none;"><%= account ? account.id : nbsp %></span>
  24. <a href="<%= account_url(account ? account.id : "{{ id }}") %>" class="name"><%= account.name rescue nbsp %></a>
  25. <span class="links">
  26. <button
  27. data-link="<%= context_url(@context, :context_sub_account_url, (account ? account.id : "{{ id }}")) %>"
  28. class="Button Button--icon-action expand_sub_accounts_link no-hover"
  29. title="{{#t}}Show Sub-Accounts{{/t}}"
  30. style="<%= hidden if (keep_going && account && sub_account_count < max_sub_accounts) || (account && sub_account_count == 0) %>"
  31. >
  32. <i aria-hidden="true" class="icon-arrow-down standalone-icon"></i>
  33. </button>
  34. <button
  35. class="Button Button--icon-action collapse_sub_accounts_link no-hover"
  36. title="{{#t}}Hide Sub-Accounts{{/t}}"
  37. style="<%= hidden unless keep_going && account && sub_account_count < max_sub_accounts %>"
  38. >
  39. <i aria-hidden="true" class="icon-arrow-up standalone-icon"></i>
  40. </button>
  41. <button
  42. class="Button Button--icon-action add_sub_account_link no-hover"
  43. title="{{#t}}Add Sub-Account{{/t}}"
  44. style="<%= hidden unless (keep_going && account && sub_account_count < max_sub_accounts) || (account && sub_account_count == 0) %>"
  45. >
  46. <i aria-hidden="true" class="icon-add standalone-icon"></i>
  47. </button>
  48. <button
  49. class="Button Button--icon-action edit_account_link no-hover"
  50. title="{{#t}}Edit Account Name{{/t}}"
  51. >
  52. <i aria-hidden="true" class="icon-edit standalone-icon"></i>
  53. </button>
  54. <% if account && !course_count.zero? %>
  55. <button
  56. aria-disabled=true
  57. class="Button Button--icon-action cant_delete_account_link no-hover"
  58. title="{{#t}}You can't delete a sub-account that has courses in it{{/t}}"
  59. >
  60. <i aria-hidden="true" class="icon-trash standalone-icon"></i>
  61. </button>
  62. <% elsif account != @context %>
  63. <button
  64. class="Button Button--icon-action delete_account_link no-hover"
  65. title="{{#t}}Delete Sub-Account{{/t}}"
  66. >
  67. <i aria-hidden="true" class="icon-trash standalone-icon"></i>
  68. </button>
  69. <% end %>
  70. </span>
  71. <div style="<%= hidden unless account && course_count > 0 %>" class="courses_count">
  72. <%= t('account_courses', 'Course', :count => course_count) if account %>
  73. </div>
  74. <div style="<%= hidden unless account && sub_account_count > 0 %>" class="sub_accounts_count">
  75. <%= t('account_sub_accounts', "Sub-Account", :count => sub_account_count) if account %>
  76. </div>
  77. <div class="clear"></div>
  78. </div>
  79. <div class="edit_account">
  80. <%= form_for (account || Account.new), :url => (account ? context_url(@context, :context_sub_account_url, account.id) : context_url(@context, :context_sub_accounts_url)), :html => {:class => "edit_sub_account_form form-inline", :method => (account ? :put : :post)} do |f| %>
  81. <%= f.text_field :name, :class => "account_name" %>
  82. <% end %>
  83. </div>
  84. </div>
  85. <ul class="sub_accounts">
  86. <% if account && keep_going && sub_account_count < max_sub_accounts %>
  87. <% @accounts[account.id][:sub_account_ids].each do |sub_account_id| %>
  88. <li class="sub_account">
  89. <% account_data = @accounts[sub_account_id] %>
  90. {{> views/sub_accounts}}
  91. </li>
  92. <% end %>
  93. <% end %>
  94. </ul>
  95. </div>