docbrown/app/views/internal/chat_channels/index.html.erb
Veggier 126367fa4a
Ability for admins to remove user from internal chat channels (#9235)
* change ui

* admins can remove users from internal chat channels

* rename destroy to remove_user

* change syntax

* add a single user

* remove a single user --debug

* remove a single user --debug

* remove a single user

* remove a single user

* remove a single user

* remove a single user

* add test for remove single user from internal chat_channel

* test

* sytax change

* add delete user for channel test

* add more test case for the remove user from chat channel

* change to single test case
2020-07-22 09:43:38 -04:00

58 lines
2.1 KiB
Text

<h2>Create New Connect Channel</h2>
<div class="row m-3">
<div class="col">
<%= form_for [:internal, ChatChannel.new], html: { class: "inline-form" } do |f| %>
<div class="form-row">
<div class="form-group">
<%= f.text_field :channel_name, placeholder: "Channel Name", required: true %>
<%= f.text_field :usernames_string, placeholder: "Usernames to add" %>
<%= f.submit %>
</div>
</div>
<% end %>
</div>
</div>
<h2>Group Connect Channels</h2>
<div class="row m-3">
<div class="col">
</div>
<div class="col">
<%= search_form_for @q, url: internal_chat_channels_path, class: "form-inline justify-content-end" do |f| %>
<%= f.label :channel_name_cont, "Channel Name", class: "sr-only" %>
<%= f.search_field :channel_name_cont, placeholder: "Channel Name", class: "form-control mx-3" %>
<%= f.submit "Search", class: "btn btn-secondary" %>
<% end %>
</div>
</div>
<%= paginate @group_chat_channels %>
<table class="table">
<thead>
<tr>
<th scope="col">Channel Name</th>
<th scope="col">Users</th>
<th scope="col">Add Users</th>
<th scope="col">Remove User</th>
</tr>
</thead>
<tbody>
<% @group_chat_channels.each do |channel| %>
<tr>
<td><a href="/connect/<%= channel.slug %>" target="_blank" rel="noopener"><%= channel.channel_name %></td>
<td><%= channel.users.pluck(:username).join(", ") %></td>
<td>
<%= form_for [:internal, channel] do |f| %>
<%= f.text_field :usernames_string, placeholder: "Usernames to add" %>
<%= f.submit %>
<% end %>
</td>
<td>
<%= form_with url: remove_user_internal_chat_channel_url(channel), model: [:internal, channel], method: :delete, local: true do |f| %>
<%= f.text_field :username_string, placeholder: "Username to remove" %>
<%= f.submit "Remove From channel", data: { confirm: "Are you sure you want to remove this user?" } %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @group_chat_channels %>