scinote-web/app/views/users/settings/teams.html.erb

98 lines
3.7 KiB
Text
Raw Normal View History

2017-01-25 19:01:23 +08:00
<% provide(:head_title, t("users.settings.teams.head_title")) %>
<%= render partial: "users/settings/navigation.html.erb" %>
<div class="tab-content">
<div class="tab-pane tab-pane-settings" role="tabpanel"></div>
<div class="tab-pane tab-pane-settings active" role="tabpanel">
<%= render partial: "users/settings/teams/breadcrumbs.html.erb" %>
<div>
<% if @member_of > 0 %>
<%= t("users.settings.teams.index.member_of", count: @member_of) %>
<% else %>
<em><%= t("users.settings.teams.index.no_teams") %></em>
<% end %>
<%= link_to new_team_path, class: "btn btn-default", style: "margin-left: 30px;" do %>
<span class="glyphicon glyphicon-plus"></span>
<span class="hidden-xs">
<%= t("users.settings.teams.index.new_team") %>
</span>
<% end %>
</div>
<% if @member_of > 0 %>
<table class="table">
<thead>
<tr>
<th><%=t "users.settings.teams.index.thead_name" %></th>
<th><%=t "users.settings.teams.index.thead_role" %></th>
<th class="hidden-xs"><%=t "users.settings.teams.index.thead_created_at" %></th>
<th class="hidden-xs"><%=t "users.settings.teams.index.thead_joined_on" %></th>
<th><%=t "users.settings.teams.index.thead_members" %></th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<% @user_teams.each do |user_team| %>
<% team = user_team.team %>
<tr>
<td>
<% if user_team.admin? %>
<%= link_to team.name, team_path(team) %>
<% else %>
<%= team.name %>
<% end %>
</td>
<td><%= user_team.role_str %></td>
<td class="hidden-xs">
<% if user_team.guest? %>
<%= t("users.settings.teams.index.na") %>
<% else %>
<%= l(team.created_at, format: :full) %>
<% end %>
</td>
<td class="hidden-xs"><%= l(user_team.created_at, format: :full) %></td>
<td>
<% if user_team.guest? %>
<%= t("users.settings.teams.index.na") %>
<% else %>
<%= team.users.count %>
<% end %>
</td>
<td>
<!-- If user is last admin of team, don't allow
him/her to leave team -->
<% if user_team.admin? && team.user_teams.where(role: 2).count <= 1 %>
<div class="btn btn-default btn-xs" type="button" disabled="disabled">
<span class="glyphicon glyphicon-log-out"></span>
<span class="hidden-xs">
<%= t("users.settings.teams.index.leave") %>
</span>
</div>
<% else %>
<%= link_to leave_user_team_html_path(user_team, format: :json),
remote: true,
class: 'btn btn-default btn-xs',
type: 'button',
data: { action: 'leave-user-team' } do %>
<span class="glyphicon glyphicon-log-out"></span>
<span class="hidden-xs">
<%= t("users.settings.teams.index.leave") %>
</span>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<br />
<% end %>
</div>
</div>
<%= render partial: "users/settings/teams/leave_user_team_modal.html.erb" %>
<%= javascript_include_tag "users/settings/teams" %>