123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <%
- # Copyright (C) 2011 - present Instructure, Inc.
- #
- # This file is part of Canvas.
- #
- # Canvas is free software: you can redistribute it and/or modify it under
- # the terms of the GNU Affero General Public License as published by the Free
- # Software Foundation, version 3 of the License.
- #
- # Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- # A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
- # details.
- #
- # You should have received a copy of the GNU Affero General Public License along
- # with this program. If not, see <http://www.gnu.org/licenses/>.
- %>
- <% 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) %>
- <% keep_going = current_depth < depth %>
- <div id="account_<%= account ? account.id : "blank" %>" class="account" style="<%= hidden unless account %>">
- <div class="header">
- <div class="show_account">
- <span class="id" style="display: none;"><%= account ? account.id : nbsp %></span>
- <a href="<%= account_url(account ? account.id : "{{ id }}") %>" class="name"><%= account.name rescue nbsp %></a>
- <span class="links">
- <button
- data-link="<%= context_url(@context, :context_sub_account_url, (account ? account.id : "{{ id }}")) %>"
- class="Button Button--icon-action expand_sub_accounts_link no-hover"
- title="{{#t}}Show Sub-Accounts{{/t}}"
- style="<%= hidden if (keep_going && account && sub_account_count < max_sub_accounts) || (account && sub_account_count == 0) %>"
- >
- <i aria-hidden="true" class="icon-arrow-down standalone-icon"></i>
-
- </button>
- <button
- class="Button Button--icon-action collapse_sub_accounts_link no-hover"
- title="{{#t}}Hide Sub-Accounts{{/t}}"
- style="<%= hidden unless keep_going && account && sub_account_count < max_sub_accounts %>"
- >
- <i aria-hidden="true" class="icon-arrow-up standalone-icon"></i>
-
- </button>
- <button
- class="Button Button--icon-action add_sub_account_link no-hover"
- title="{{#t}}Add Sub-Account{{/t}}"
- style="<%= hidden unless (keep_going && account && sub_account_count < max_sub_accounts) || (account && sub_account_count == 0) %>"
- >
- <i aria-hidden="true" class="icon-add standalone-icon"></i>
-
- </button>
- <button
- class="Button Button--icon-action edit_account_link no-hover"
- title="{{#t}}Edit Account Name{{/t}}"
- >
- <i aria-hidden="true" class="icon-edit standalone-icon"></i>
-
- </button>
- <% if account && !course_count.zero? %>
- <button
- aria-disabled=true
- class="Button Button--icon-action cant_delete_account_link no-hover"
- title="{{#t}}You can't delete a sub-account that has courses in it{{/t}}"
- >
- <i aria-hidden="true" class="icon-trash standalone-icon"></i>
-
- </button>
- <% elsif account != @context %>
- <button
- class="Button Button--icon-action delete_account_link no-hover"
- title="{{#t}}Delete Sub-Account{{/t}}"
- >
- <i aria-hidden="true" class="icon-trash standalone-icon"></i>
-
- </button>
- <% end %>
- </span>
- <div style="<%= hidden unless account && course_count > 0 %>" class="courses_count">
- <%= t('account_courses', 'Course', :count => course_count) if account %>
- </div>
- <div style="<%= hidden unless account && sub_account_count > 0 %>" class="sub_accounts_count">
- <%= t('account_sub_accounts', "Sub-Account", :count => sub_account_count) if account %>
- </div>
- <div class="clear"></div>
- </div>
- <div class="edit_account">
- <%= 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| %>
- <%= f.text_field :name, :class => "account_name" %>
- <% end %>
- </div>
- </div>
- <ul class="sub_accounts">
- <% if account && keep_going && sub_account_count < max_sub_accounts %>
- <% @accounts[account.id][:sub_account_ids].each do |sub_account_id| %>
- <li class="sub_account">
- <% account_data = @accounts[sub_account_id] %>
- {{> views/sub_accounts}}
- </li>
- <% end %>
- <% end %>
- </ul>
- </div>
|