Skip to content

Commit

Permalink
Allowed admins to share room with themselves (#2442)
Browse files Browse the repository at this point in the history
  • Loading branch information
farhatahmad committed Jan 18, 2021
1 parent 0e8e188 commit 957bf88
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion app/assets/javascripts/room.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ $(document).on('turbolinks:load', function(){
$(".share-room").click(function() {
// Update the path of save button
$("#save-access").attr("data-path", $(this).data("path"))
$("#room-owner-uid").val($(this).data("owner"))

// Get list of users shared with and display them
displaySharedUsers($(this).data("users-path"))
Expand All @@ -82,7 +83,7 @@ $(document).on('turbolinks:load', function(){
$(".bs-searchbox").siblings().hide()
} else {
// Manually populate the dropdown
$.get($("#share-room-select").data("path"), { search: $(".bs-searchbox input").val() }, function(users) {
$.get($("#share-room-select").data("path"), { search: $(".bs-searchbox input").val(), owner_uid: $("#room-owner-uid").val() }, function(users) {
$(".select-options").remove()
if (users.length > 0) {
users.forEach(function(user) {
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def shared_access_list
roles_can_appear << role.name if role.get_permission("can_appear_in_share_list") && role.priority >= 0
end

initial_list = User.where.not(uid: current_user.uid)
initial_list = User.where.not(uid: params[:owner_uid])
.with_role(roles_can_appear)
.shared_list_search(params[:search])
.pluck_to_hash(:uid, :name)
Expand Down
2 changes: 1 addition & 1 deletion app/views/admins/components/_server_room_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
</a>
<% end %>
<% if shared_access_allowed %>
<a href="" data-toggle="modal" data-target="#shareRoomModal" class="share-room dropdown-item" data-path="<%= room_shared_access_path(room) %>" data-users-path="<%= room_shared_users_path(room) %>">
<a href="" data-toggle="modal" data-target="#shareRoomModal" class="share-room dropdown-item" data-path="<%= room_shared_access_path(room) %>" data-users-path="<%= room_shared_users_path(room) %>" data-owner="<%= room.owner.uid %>">
<i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %>
</a>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/rooms/components/_room_block.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</a>
<% end %>
<% if shared_access_allowed %>
<a href="" data-toggle="modal" data-target="#shareRoomModal" class="share-room dropdown-item" data-path="<%= room_shared_access_path(room) %>" data-users-path="<%= room_shared_users_path(room) %>">
<a href="" data-toggle="modal" data-target="#shareRoomModal" class="share-room dropdown-item" data-path="<%= room_shared_access_path(room) %>" data-users-path="<%= room_shared_users_path(room) %>" data-owner="<%= room.owner.uid %>">
<i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %>
</a>
<% end %>
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/modals/_share_room_modal.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<ul id="user-list" class="list-group">
</ul>
</div>
<input id="room-owner-uid" type="hidden">
<div class="mt-6">
<button id="save-access" class="btn btn-primary btn-block" onclick="saveAccessChanges()" ><%= t("modal.share_access.save") %></button>
<button class="btn btn-secondary text-primary btn-block" onclick="$('#shareRoomModal').modal('hide')"><%= t("modal.share_access.cancel_changes") %></button>
Expand Down

0 comments on commit 957bf88

Please sign in to comment.