admin_merge.mustache 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. <% content_for :page_title do %>{{#t}}Merge User Accounts{{/t}}<% end %>
  19. <% content_for :stylesheets do %>
  20. <style>
  21. .merge_results {
  22. border-collapse: collapse;
  23. margin: 10px 0;
  24. }
  25. .merge_results td, .merge_results th {
  26. padding-right: 10px;
  27. padding-bottom: 3px;
  28. vertical-align: top;
  29. }
  30. .merge_results .result > td, .merge_results .result > th {
  31. padding: 5px;
  32. }
  33. .merge_results tbody .result > td, .merge_results tbody .result > th {
  34. border-top: 1px solid #ddd;
  35. }
  36. .merge_results .result > td {
  37. border-left: 1px solid #ddd;
  38. }
  39. .merge_results thead .result > td {
  40. font-weight: bold;
  41. }
  42. .merge_results th {
  43. font-weight: bold;
  44. padding-right: 10px;
  45. }
  46. </style>
  47. <% end %>
  48. <div style="margin-top: 10px;">
  49. <% if @other_user %>
  50. <h1>{{#t}}Really Merge User Accounts?{{/t}}</h1>
  51. <p><strong>
  52. {{#t}}This process cannot be undone, so please make sure you're certain before you continue.{{/t}}
  53. </strong></p>
  54. <p>
  55. <%= t('merge_result_explanation', "Are you sure you want to merge the account, %{source_user_name}
  56. (%{source_user_email}) into this account, %{target_user_name} (%{target_user_email})? This
  57. process will have the following end result:",
  58. :source_user_name => @user.name, :source_user_email => @user.email,
  59. :target_user_name => @other_user.name, :target_user_email => @other_user.email) %>
  60. {{> views/merge_results}}
  61. </p>
  62. <%= form_tag user_merge_path(@user, :new_user_id => @other_user.id), :method => :post do %>
  63. <div class="button-container">
  64. <button type="submit" class="btn">{{#t}}Merge User Accounts{{/t}}</button>
  65. <a href="<%= dashboard_path %>" class="btn button-secondary">{{#t}}Cancel{{/t}}</a>
  66. </div>
  67. <% end %>
  68. <% else %>
  69. <h1>{{#t}}Merge User Accounts{{/t}}</h1>
  70. <% if @pending_other_user %>
  71. <%= t('merge_result_explanation_again', "You've selected to merge the user, %{user_name} (%{user_email}) into
  72. the account, %{pending_other_user_name} (%{pending_other_user_email}).
  73. This process will have the following end result:",
  74. :user_name => @user.name, :user_email => @user.email,
  75. :pending_other_user_name => @pending_other_user.name, :pending_other_user_email => @pending_other_user.email) %>
  76. {{> views/merge_results}}
  77. <a class="btn" id="prepare_to_merge" style="width: 6em;" href="<%= user_admin_merge_url(@user.id, :new_user_id => @pending_other_user.id) %>">{{#t}}Prepare to Merge Users{{/t}}</a>
  78. <span style="font-size: 0.8em; padding-left: 50px;">
  79. <a class="btn" id="switch_user_positions" style="width: 6em;" href="<%= user_admin_merge_url(@pending_other_user.id, :pending_user_id => @user.id) %>">{{#t}}Switch User Positions{{/t}}</a>
  80. <a class="btn merge_with_other" style="width: 13em;" href="<%= user_admin_merge_url(@user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @user.name) %></a>
  81. <a class="btn merge_with_other" style="width: 13em;" href="<%= user_admin_merge_url(@pending_other_user.id, :clear => 1) %>"><%= t('merge_somone_else', 'Merge Someone Else With %{user_name}', :user_name => @pending_other_user.name) %></a>
  82. </span>
  83. <% else %>
  84. <p><%= t('merge_user_initial_instructions', "You've selected to merge the user, %{user_name} (%{user_email}) with another account.
  85. You can search for the user you'd like to merge with this user using the form below.", :user_name => @user.name, :user_email => @user.email) %></p>
  86. <table>
  87. <tr>
  88. <td style="vertical-align: top; padding: 10px 30px 10px;">
  89. <h2>{{#t}}Find a User{{/t}}</h2>
  90. <% accounts = @current_user.associated_accounts.sort_by(&:name).uniq.select { |a| a.grants_any_right?(@current_user, session, :manage_user_logins, :read_roster) } %>
  91. <% if accounts.empty? %>
  92. {{#t}}You don't have permission to search any accounts{{/t}}
  93. <% else %>
  94. <select id="account_select" style="<%= hidden unless accounts.length > 1%>">
  95. <% accounts.each do |account| %>
  96. <option value="<%= account.id %>"><%= account.name %></option>
  97. <% end %>
  98. </select>
  99. <div style="margin-top: 10px; margin-bottom: 20px;">
  100. <% accounts.each do |account| %>
  101. <div id="account_search_<%= account.id %>" class="account_search" style="display: none;">
  102. <label for="user_name_<%= account.id %>"><%= before_label('name', 'Name') %></label>
  103. <input id="user_name_<%= account.id %>" data-autocomplete-source="<%= account_users_path(account) + '.json' %>" class="user_name" />
  104. </div>
  105. <% end %>
  106. </div>
  107. <div style="margin-top: 20px;">
  108. <span id="selected_name" style="font-weight: bold; padding-right: 10px;"></span>
  109. <a href="#" style="display: none;" rel="<%= user_admin_merge_url(@user.id, :pending_user_id => "{{ id }}") %>" id="select_name" type='button' class='btn btn-small select_button'><%= t 'links.select', "Select" %></a>
  110. </div>
  111. <% end %>
  112. </td>
  113. <td style="vertical-align: top; padding: 10px 10px 10px 30px;">
  114. <h2>{{#t}}Or Enter a User ID{{/t}}</h2>
  115. <%= form_tag user_admin_merge_url(@user.id), {:method => :get} do %>
  116. <label for="manual_user_id"><%= before_label('user_id', 'User ID') %></label>
  117. <input id="manual_user_id" name="pending_user_id" type="text" style="width: 50px;"/>
  118. <button type="submit" class="btn btn-small">{{#t}}Go{{/t}}</button>
  119. <% end %>
  120. </td>
  121. </tr>
  122. </table>
  123. <% js_bundle 'legacy/users_admin_merge' %>
  124. <% end %>
  125. <% end %>
  126. </div>