forked from External/greenlight
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:
parent
01c93b1f67
commit
b67bee2638
|
@ -180,7 +180,6 @@ class RoomsController < ApplicationController
|
|||
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)
|
||||
|
|
|
@ -130,12 +130,6 @@ class User < ApplicationRecord
|
|||
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))
|
||||
|
|
|
@ -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">
|
||||
|
@ -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 %>">
|
||||
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
@ -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">
|
||||
|
|
|
@ -173,7 +173,7 @@ describe RoomsController, type: :controller do
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue