Skip to content

Commit

Permalink
GRN2-264: Allow users to change the room settings on Home Room (bigbl…
Browse files Browse the repository at this point in the history
…uebutton#951)

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

* fixing inconsistencies

* removing 'secondary_rooms' method and adjusting looping
  • Loading branch information
etiennevvv authored and farhatahmad committed Feb 12, 2020
1 parent 01c93b1 commit b67bee2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 44 deletions.
1 change: 0 additions & 1 deletion app/controllers/rooms_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ def update_settings
begin
options = params[:room].nil? ? params : params[:room]
raise "Room name can't be blank" if options[:name].blank?
raise "Unauthorized Request" if @room == current_user.main_room

# Update the rooms values
room_settings_string = create_room_settings_string(options)
Expand Down
6 changes: 0 additions & 6 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,6 @@ def password_reset_expired?
reset_sent_at < 2.hours.ago
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
def shared_rooms
Room.where(id: shared_access.pluck(:room_id))
Expand Down
42 changes: 18 additions & 24 deletions app/views/rooms/components/_room_block.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# 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">
<table class="table table-hover table-vcenter text-wrap table-no-border">
<tbody class="no-border-top">
Expand All @@ -28,11 +28,7 @@
</td>
<td>
<div id="room-name">
<% if room == current_user.main_room %>
<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 %>
<h4 id="room-name-text" contenteditable="false" class="m-0 force-text-normal" ><%= room.name %></h4>
</div>
<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 %>">
Expand All @@ -45,27 +41,25 @@
<% end %>
</div>
</td>
<td class="text-right">
<% unless room == current_user.main_room %>
<div class="item-action dropdown" data-display="static">
<a href="javascript:void(0)" data-toggle="dropdown" data-display="static" class="icon">
<i class="fas fa-ellipsis-v px-4"></i>
<td class="text-right">
<div class="item-action dropdown" data-display="static">
<a href="javascript:void(0)" data-toggle="dropdown" data-display="static" class="icon">
<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>
<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") %>
<% 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) %>">
<i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %>
</a>
<% 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) %>">
<i class="dropdown-icon fas fa-users"></i> <%= t("room.share") %>
</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>
<% 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>
<% end %>
</div>
</td>
</tbody>
</table>
Expand Down
17 changes: 5 additions & 12 deletions app/views/rooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<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) %>">
<% 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>
<% else %>
<h1 contenteditable=false id="user-text" class="display-3 text-left mb-3 font-weight-400"><%= @room.name %></h1>
Expand Down Expand Up @@ -77,21 +77,14 @@
</div>

<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">
<%= link_to current_user.main_room do %>
<%= render "rooms/components/room_block", room: current_user.main_room %>
<%= link_to room do %>
<%= render "rooms/components/room_block", room: room %>
<% end %>
</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 %>
<% if shared_access_allowed %>
<% current_user.shared_rooms.each do |room| %>
<div class="col-lg-4 col-md-6 col-sm-12">
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/rooms_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def random_valid_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.owner).to eql(@owner)
expect(r.room_settings).to eql(json_room_settings)
Expand Down

0 comments on commit b67bee2

Please sign in to comment.