2016-11-03 18:27:17 +08:00
|
|
|
<%
|
|
|
|
# How to use this modal:
|
|
|
|
# 1. Render it in the page (HTML) of your choice
|
|
|
|
# 2. Add an element (e.g. <a href>) with following attributes:
|
|
|
|
# * data-trigger="invite-users",
|
|
|
|
# * data-modal-id="modal-id",
|
|
|
|
#
|
|
|
|
# Modal parameters:
|
|
|
|
# * modal_id: unique id so the JS works if multiple modals are present
|
|
|
|
# on the same page
|
|
|
|
# * type:
|
2017-01-25 19:01:23 +08:00
|
|
|
# * 'invite_to_team' => params: team
|
|
|
|
# * 'invite_to_team_with_role' => params: team, role
|
2016-11-03 18:27:17 +08:00
|
|
|
# * 'invite',
|
2017-01-25 19:01:23 +08:00
|
|
|
# * 'invite_with_team_selector',
|
|
|
|
# * 'invite_with_team_selector_and_role' => params: role
|
|
|
|
# * team: invite users to the specified team
|
2016-11-03 18:27:17 +08:00
|
|
|
# * role: all users are invited as the specified role
|
2016-11-06 18:37:53 +08:00
|
|
|
# * (optional) text_title: custom title text for modal
|
|
|
|
# * (optional) text_invite_heading: custom invite heading text for modal
|
|
|
|
%>
|
|
|
|
<%
|
|
|
|
text_title ||= nil
|
|
|
|
text_invite_heading ||= nil
|
2017-01-25 19:01:23 +08:00
|
|
|
invite_to_team = type.in?(%w(invite_to_team invite_to_team_with_role))
|
2021-07-08 22:10:20 +08:00
|
|
|
invite_with_team_selector = type.in?(%w(invite_new_members invite_with_team_selector invite_with_team_selector_and_role))
|
2016-11-03 18:27:17 +08:00
|
|
|
%>
|
|
|
|
<div
|
|
|
|
class="modal modal-invite-users"
|
|
|
|
tabindex="-1"
|
|
|
|
role="dialog"
|
|
|
|
aria-labelledby="invite-users-modal-label"
|
|
|
|
data-id="<%= modal_id %>"
|
|
|
|
data-role="invite-users-modal"
|
|
|
|
data-type="<%= type %>"
|
|
|
|
data-url="<%= invite_users_path %>"
|
|
|
|
data-backdrop="static"
|
|
|
|
data-keyboard="false"
|
2018-07-19 23:56:42 +08:00
|
|
|
data-max-tags="<%= Constants::INVITE_USERS_LIMIT %>"
|
2017-01-25 19:01:23 +08:00
|
|
|
<%= "data-team-id=#{team.id}" if invite_to_team %>
|
|
|
|
<%= "data-team-role=#{role}" if type.in?(%w(invite_to_team_with_role invite_with_team_selector_and_role)) %>
|
2016-11-03 18:27:17 +08:00
|
|
|
>
|
|
|
|
<div class="modal-dialog" role="document">
|
|
|
|
<div class="modal-content">
|
|
|
|
|
|
|
|
<div class="modal-header">
|
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
|
|
|
|
<h4 class="modal-title">
|
2016-11-06 18:37:53 +08:00
|
|
|
<% if text_title %>
|
|
|
|
<%= text_title %>
|
2016-11-03 18:27:17 +08:00
|
|
|
<% else %>
|
2017-01-25 19:01:23 +08:00
|
|
|
<% if invite_to_team %>
|
|
|
|
<%= t('invite_users.to_team.title', team: team.name) %>
|
2016-11-06 18:37:53 +08:00
|
|
|
<% else %>
|
2017-01-25 19:01:23 +08:00
|
|
|
<%= t('invite_users.no_team.title') %>
|
2016-11-06 18:37:53 +08:00
|
|
|
<% end %>
|
2016-11-03 18:27:17 +08:00
|
|
|
<% end %>
|
|
|
|
</h4>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-body">
|
|
|
|
<div data-role="step-form">
|
|
|
|
<p>
|
2016-11-06 18:37:53 +08:00
|
|
|
<% if text_invite_heading %>
|
|
|
|
<%= text_invite_heading %>
|
2016-11-03 18:27:17 +08:00
|
|
|
<% else %>
|
2017-01-25 19:01:23 +08:00
|
|
|
<% if invite_to_team %>
|
|
|
|
<%= t('invite_users.to_team.heading', team: team.name) %>
|
2016-11-06 18:37:53 +08:00
|
|
|
<% else %>
|
2017-01-25 19:01:23 +08:00
|
|
|
<%= t('invite_users.no_team.heading') %>
|
2016-11-06 18:37:53 +08:00
|
|
|
<% end %>
|
2016-11-03 18:27:17 +08:00
|
|
|
<% end %>
|
|
|
|
</p>
|
|
|
|
|
2021-07-13 21:51:05 +08:00
|
|
|
<% if type.in? ['invite_new_members', 'invite'] %>
|
2021-07-08 22:10:20 +08:00
|
|
|
<p><%= t('invite_users.new_members.description') %></p>
|
|
|
|
<h4 class="heading">
|
|
|
|
<span><%= t('invite_users.new_members.input_label') %></span>
|
|
|
|
</h4>
|
|
|
|
<div class="emails-selector" >
|
2021-07-09 17:20:48 +08:00
|
|
|
<div class="select-container">
|
|
|
|
<select name="emails[]" class="emails-input"></select>
|
|
|
|
</div>
|
2021-07-08 22:10:20 +08:00
|
|
|
<p><small><%= t('invite_users.new_members.input_subtitle') %></small></p>
|
|
|
|
</div>
|
|
|
|
<% else %>
|
|
|
|
<div class="user-selector">
|
|
|
|
<select class="emails-input" multiple data-role="tags-input" name="emails[]">
|
|
|
|
</select>
|
|
|
|
<h4><%= t('invite_users.input_subtitle') %></h4>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2016-11-03 18:27:17 +08:00
|
|
|
|
2021-07-08 22:10:20 +08:00
|
|
|
<% if current_user && invite_with_team_selector %>
|
2017-01-25 19:01:23 +08:00
|
|
|
<% # Only allow inviting to teams where user is admin %>
|
2021-07-05 18:39:54 +08:00
|
|
|
<div class="team-selector">
|
|
|
|
<h4 class="heading">
|
|
|
|
<span><%= t('invite_users.select_team') %></span>
|
|
|
|
</h4>
|
|
|
|
<div class="team-selector filter-block small-left">
|
|
|
|
<div class="select-container select-container--with-search select-container--with-blank">
|
|
|
|
<select class="teams-input" name="teams[]"
|
|
|
|
data-placeholder = "<%= t('invite_users.select_team_blank') %>"
|
|
|
|
data-blank = "<%= t('invite_users.select_team_blank') %>"
|
|
|
|
data-select-all = "false"
|
|
|
|
data-toggle-target = "#role-select-container"
|
|
|
|
data-ajax-url = "<%= invitable_teams_path %>"
|
|
|
|
></select>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="role-select-container" class="hidden">
|
|
|
|
<h4 class="heading">
|
|
|
|
<span><%= t('invite_users.select_team_role') %></span>
|
|
|
|
</h4>
|
2021-07-08 22:10:20 +08:00
|
|
|
<div class="form-select">
|
2022-10-06 23:55:51 +08:00
|
|
|
<% normal_user_role = UserRole.find_predefined_normal_user_role %>
|
2022-10-14 17:35:35 +08:00
|
|
|
<%= select_tag "role-id",
|
2022-10-06 23:55:51 +08:00
|
|
|
options_for_select(
|
|
|
|
team_user_roles_for_select
|
|
|
|
.map { |name, id| [id == normal_user_role.id ? "#{name} (#{t('invite_users.default')})" : name, id] },
|
|
|
|
normal_user_role.id
|
|
|
|
), disabled: true, class: "role-input from-control" %>
|
2021-07-08 22:10:20 +08:00
|
|
|
</div>
|
2016-11-03 18:27:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-05 18:39:54 +08:00
|
|
|
</div>
|
2016-11-03 18:27:17 +08:00
|
|
|
<% end %>
|
2019-02-20 17:14:37 +08:00
|
|
|
<% if ENV['ENABLE_RECAPTCHA'] == 'true' %>
|
2022-01-06 17:11:20 +08:00
|
|
|
<%= recaptcha_input_tag include_description: false %>
|
2019-01-23 16:17:27 +08:00
|
|
|
<div class="form-group has-error hidden" id="recaptcha-error-msg" >
|
|
|
|
<span class="has-error help-block"></span>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
2016-11-03 18:27:17 +08:00
|
|
|
</div>
|
2016-11-06 18:29:00 +08:00
|
|
|
<div class="results-container" data-role="step-results" data-clear="true">
|
2016-11-03 18:27:17 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="modal-footer">
|
|
|
|
<div data-role="step-form">
|
2020-01-07 23:13:34 +08:00
|
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">
|
2016-11-03 18:27:17 +08:00
|
|
|
<%= t('general.cancel') %>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<!-- Invite buttons -->
|
2020-04-28 18:30:43 +08:00
|
|
|
<button type="button" class="btn btn-primary"
|
2018-10-02 23:54:12 +08:00
|
|
|
data-role="invite-btn" data-action="invite"
|
|
|
|
disabled="disabled">
|
2016-11-03 18:27:17 +08:00
|
|
|
<%= t('invite_users.invite_btn') %>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
<div class="btn-group" data-role="invite-with-role-div">
|
2020-04-28 18:30:43 +08:00
|
|
|
<button type="button" class="btn btn-primary dropdown-toggle"
|
2018-10-02 23:54:12 +08:00
|
|
|
data-toggle="dropdown" data-id="invite-btn" aria-haspopup="true"
|
|
|
|
aria-expanded="false" data-role="invite-with-role-btn"
|
|
|
|
disabled="disabled">
|
2016-11-03 18:27:17 +08:00
|
|
|
<%= t('invite_users.invite_btn') %>
|
|
|
|
|
|
|
|
<span class="caret"></span>
|
|
|
|
</button>
|
|
|
|
<ul class="dropdown-menu">
|
2022-05-19 15:04:25 +08:00
|
|
|
<% team_user_roles_collection.each do |user_role| %>
|
|
|
|
<li>
|
|
|
|
<%= link_to '#', data: { action: 'invite', 'team-role-id' => user_role.id, remote: true } do %>
|
|
|
|
<%= t('invite_users.invite_as', role: user_role.name.pluralize) %>
|
|
|
|
<% end %>
|
|
|
|
</li>
|
|
|
|
<% end %>
|
2016-11-03 18:27:17 +08:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div data-role="step-results">
|
|
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">
|
|
|
|
<%= t('general.close') %>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|