GRN2-264: Allow users to change the room settings on Home Room (#951)

* GRN2-264: Allow users to change the room settings on Home Room

* fixing inconsistencies

* removing 'secondary_rooms' method and adjusting looping
This commit is contained in:
etiennevvv 2020-02-11 13:47:11 -05:00 committed by farhatahmad
parent 01c93b1f67
commit b67bee2638
5 changed files with 24 additions and 44 deletions

View File

@ -180,7 +180,6 @@ class RoomsController < ApplicationController
begin begin
options = params[:room].nil? ? params : params[:room] options = params[:room].nil? ? params : params[:room]
raise "Room name can't be blank" if options[:name].blank? raise "Room name can't be blank" if options[:name].blank?
raise "Unauthorized Request" if @room == current_user.main_room
# Update the rooms values # Update the rooms values
room_settings_string = create_room_settings_string(options) room_settings_string = create_room_settings_string(options)

View File

@ -130,12 +130,6 @@ class User < ApplicationRecord
reset_sent_at < 2.hours.ago reset_sent_at < 2.hours.ago
end end
# Retrives a list of all a users rooms that are not the main room, sorted by last session date.
def secondary_rooms
room_list = rooms.where.not(uid: main_room.uid)
room_list.where.not(last_session: nil).order("last_session desc") + room_list.where(last_session: nil)
end
# Retrieves a list of rooms that are shared with the user # Retrieves a list of rooms that are shared with the user
def shared_rooms def shared_rooms
Room.where(id: shared_access.pluck(:room_id)) Room.where(id: shared_access.pluck(:room_id))

View File

@ -13,7 +13,7 @@
# with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. # with BigBlueButton; if not, see <http://www.gnu.org/licenses/>.
%> %>
<div id="<%= if room == current_user.main_room then 'home_room_block' else 'room-block' end %>" data-path="<%= update_settings_path(room) %>" data-room-settings=<%= room.room_settings %> data-room-access-code="<%= room.access_code %>" class="card"> <div id="room-block" data-path="<%= update_settings_path(room) %>" data-room-settings=<%= room.room_settings %> data-room-access-code="<%= room.access_code %>" class="card">
<div class="card-body p-1"> <div class="card-body p-1">
<table class="table table-hover table-vcenter text-wrap table-no-border"> <table class="table table-hover table-vcenter text-wrap table-no-border">
<tbody class="no-border-top"> <tbody class="no-border-top">
@ -28,11 +28,7 @@
</td> </td>
<td> <td>
<div id="room-name"> <div id="room-name">
<% if room == current_user.main_room %> <h4 id="room-name-text" contenteditable="false" class="m-0 force-text-normal" ><%= room.name %></h4>
<h4 id="room-name-text" contenteditable="false" class="m-0 force-text-normal" ><%= t("home_room") %></h4>
<% else %>
<h4 id="room-name-text" contenteditable="false" class="m-0 force-text-normal" ><%= room.name %></h4>
<% end %>
</div> </div>
<div id="room-name-editable" style="display: none"> <div id="room-name-editable" style="display: none">
<input id="room-name-editable-input" class="form-control input-sm w-100 h-4" value="<%= room.name %>"> <input id="room-name-editable-input" class="form-control input-sm w-100 h-4" value="<%= room.name %>">
@ -46,26 +42,24 @@
</div> </div>
</td> </td>
<td class="text-right"> <td class="text-right">
<% unless room == current_user.main_room %> <div class="item-action dropdown" data-display="static">
<div class="item-action dropdown" data-display="static"> <a href="javascript:void(0)" data-toggle="dropdown" data-display="static" class="icon">
<a href="javascript:void(0)" data-toggle="dropdown" data-display="static" class="icon"> <i class="fas fa-ellipsis-v px-4"></i>
<i class="fas fa-ellipsis-v px-4"></i> </a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-md-left">
<a href="" data-toggle="modal" data-target="#createRoomModal" class="update-room dropdown-item">
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %>
</a> </a>
<div class="dropdown-menu dropdown-menu-right dropdown-menu-md-left"> <% if shared_access_allowed %>
<a href="" data-toggle="modal" data-target="#createRoomModal" class="update-room dropdown-item"> <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) %>">
<i class="dropdown-icon fas fa-cog"></i> <%= t("room.settings") %> <i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %>
</a> </a>
<% if shared_access_allowed %> <% end %>
<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="#deleteRoomModal" data-path="<%= room_path(room) %>" data-name="<%= room.name %>" class="delete-room dropdown-item">
<i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %> <i class="dropdown-icon far fa-trash-alt"></i> <%= t("delete") %>
</a> </a>
<% end %>
<a href="" data-toggle="modal" data-target="#deleteRoomModal" data-path="<%= room_path(room) %>" data-name="<%= room.name %>" class="delete-room dropdown-item">
<i class="dropdown-icon far fa-trash-alt"></i> <%= t("delete") %>
</a>
</div>
</div> </div>
<% end %> </div>
</td> </td>
</tbody> </tbody>
</table> </table>

View File

@ -25,7 +25,7 @@
<div class="col-lg-8 col-sm-12"> <div class="col-lg-8 col-sm-12">
<div id="room-title" class="display-3 form-inline <%= 'edit_hover_class' if current_user.main_room != @room %>" data-path="<%= update_settings_path(@room) %>"> <div id="room-title" class="display-3 form-inline <%= 'edit_hover_class' if current_user.main_room != @room %>" data-path="<%= update_settings_path(@room) %>">
<% if current_user.main_room == @room %> <% if current_user.main_room == @room %>
<h1 contenteditable=false id="user-text" class="display-3 text-left mb-3 font-weight-400"><%= t("home_room") %></h1> <h1 contenteditable=false id="user-text" class="display-3 text-left mb-3 font-weight-400"><%= @room.name %></h1>
<a class="disable-click"><i class="fas fa-home align-top home-indicator ml-2"></i></a> <a class="disable-click"><i class="fas fa-home align-top home-indicator ml-2"></i></a>
<% else %> <% else %>
<h1 contenteditable=false id="user-text" class="display-3 text-left mb-3 font-weight-400"><%= @room.name %></h1> <h1 contenteditable=false id="user-text" class="display-3 text-left mb-3 font-weight-400"><%= @room.name %></h1>
@ -77,19 +77,12 @@
</div> </div>
<div id="room_block_container" class="row pt-7 pb-5"> <div id="room_block_container" class="row pt-7 pb-5">
<% if current_user.rooms.length > 1 %> <% current_user.rooms.each do |room| %>
<div class="col-lg-4 col-md-6 col-sm-12"> <div class="col-lg-4 col-md-6 col-sm-12">
<%= link_to current_user.main_room do %> <%= link_to room do %>
<%= render "rooms/components/room_block", room: current_user.main_room %> <%= render "rooms/components/room_block", room: room %>
<% end %> <% end %>
</div> </div>
<% current_user.secondary_rooms.each do |room| %>
<div class="col-lg-4 col-md-6 col-sm-12">
<%= link_to room do %>
<%= render "rooms/components/room_block", room: room %>
<% end %>
</div>
<% end %>
<% end %> <% end %>
<% if shared_access_allowed %> <% if shared_access_allowed %>

View File

@ -173,7 +173,7 @@ describe RoomsController, type: :controller do
post :create, params: { room: room_params } post :create, params: { room: room_params }
r = @owner.secondary_rooms.last r = @owner.rooms.last
expect(r.name).to eql(name) expect(r.name).to eql(name)
expect(r.owner).to eql(@owner) expect(r.owner).to eql(@owner)
expect(r.room_settings).to eql(json_room_settings) expect(r.room_settings).to eql(json_room_settings)