Skip to content

Commit 5061731

Browse files
committed
Allow assigning self as conversation participant
1 parent b1824a1 commit 5061731

File tree

8 files changed

+28
-19
lines changed

8 files changed

+28
-19
lines changed

app/controllers/better_together/conversations_controller.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ def show # rubocop:todo Metrics/MethodLength
4848
private
4949

5050
def available_participants
51-
participants = Person
52-
.where.not(id: helpers.current_person.id)
51+
participants = Person.all
5352

5453
unless helpers.current_person.permitted_to?('manage_platform')
5554
# only allow messaging platform mangers unless you are a platform_manager

app/models/better_together/person.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ def cover_image_variant(width, height)
7272
cover_image.variant(resize_to_fill: [width, height]).processed
7373
end
7474

75+
def handle
76+
slug
77+
end
78+
79+
def select_option_title
80+
"#{name} - @#{handle}"
81+
end
82+
7583
def to_s
7684
name
7785
end

app/views/better_together/conversations/_conversation.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<li id="<%= dom_id(conversation) %>" class="<%= dom_class(conversation) %> list-group-item rounded-0 <%= 'active' if conversation == @conversation %>">
66
<%= link_to conversation_path(conversation), class: "stretched-link text-decoration-none d-flex justify-content-between" do %>
77
<div class="mb-1 conversation-participants justify-content-between">
8-
<%= render partial: 'better_together/people/mention', collection: conversation.participants.where.not(id: current_person.id), as: :person %>
8+
<%= render partial: 'better_together/people/mention', collection: conversation.participants, as: :person %>
99
</div>
1010

1111
<strong><%= conversation.title if conversation.title.present? %></strong>

app/views/better_together/conversations/_conversation_content.html.erb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!-- app/views/conversations/_conversation_content.html.erb -->
22
<div id="<%= dom_id(conversation) %>" class="conversation-messages card shadow-sm d-flex flex-column justify-content-between h-100">
3-
<div class="card-header bg-secondary text-white text-center rounded-0">
4-
<h4 class="mb-0">
5-
<%= conversation.participants.reject { |participant| participant == current_person }.map(&:to_s).join(', ') %>
6-
<% if conversation.title.present? %>
7-
(<%= conversation.title %>)
8-
<% end %>
9-
</h4>
3+
<div class="card-header bg-secondary text-white text-center d-flex align-content-center justify-content-between rounded-0">
4+
<%= render partial: 'better_together/people/mention', collection: conversation.participants, as: :person %>
5+
<% if conversation.title.present? %>
6+
<h4 class="m-0">
7+
<%= conversation.title %>
8+
</h4>
9+
<% end %>
1010
</div>
1111

1212
<div id="conversation_messages" class="card-body p-4" style="overflow-y: auto; height: 50vh;" data-controller="better_together--conversation-messages">

app/views/better_together/conversations/new.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<div class="card-body">
88
<%= form_with(model: @conversation, local: true) do |form| %>
99
<div class="mb-3">
10-
<%= form.label :title %>
11-
<%= form.text_field :title, class: 'form-control' %>
10+
<%= form.label :participant_ids, t('.add_participants') %>
11+
<%= form.collection_select :participant_ids, available_participants, :id, :select_option_title, { }, { multiple: true, class: 'form-select', required: true, data: { controller: "better_together--slim-select" } } %>
1212
</div>
1313

1414
<div class="mb-3">
15-
<%= form.label :participant_ids, t('.add_participants') %>
16-
<%= form.collection_select :participant_ids, available_participants, :id, :name, {}, { multiple: true, class: 'form-control', required: true } %>
15+
<%= form.label :title %>
16+
<%= form.text_field :title, class: 'form-control' %>
1717
</div>
1818

1919
<div>

app/views/better_together/people/_mention.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="text-decoration-none me-2 <%= dom_class(person, :mention) %> <%= 'me' if person == current_person %>" href="<%= person %>" id="<%= dom_id(person, :mention) %>">
1+
<a class="text-decoration-none me-2 <%= dom_class(person, :mention) %> <%= 'me' if person == current_person %>" href="<%= person_path(person) if person == current_person %>" id="<%= dom_id(person, :mention) %>">
22
<%# Display avatar and name inline %>
33
<%= profile_image_tag(person, class: 'mention', size: 25) %>
44
<span class="identity-name"><%= person.name %></span>

config/locales/en.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ en:
1111
contact_details:
1212
title: "Contact Details"
1313
conversations:
14+
communicator:
15+
create_conversation: "Create Conversation"
1416
conversation:
1517
last_message: "Last message"
1618
layout_with_sidebar:
@@ -20,7 +22,6 @@ en:
2022
new: "New"
2123
new_conversation: "New Conversation"
2224
add_participants: "Add Participants"
23-
create_conversation: "Create Conversation"
2425
empty:
2526
no_messages: "No messages yet. Why not start the conversation?"
2627
platform_invitation:
@@ -72,7 +73,7 @@ en:
7273
placeholder: "Type your message..."
7374
send: "Send"
7475
new_message_notifier:
75-
new_message: "New Message in %{conversation_title}"
76+
new_message: "New Message"
7677
from_html: "From: %{sender}"
7778
notifications:
7879
index:

config/locales/es.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ es:
1111
contact_details:
1212
title: "Detalles de Contacto"
1313
conversations:
14+
communicator:
15+
create_conversation: "Crear Conversación"
1416
conversation:
1517
last_message: "Último mensaje"
1618
layout_with_sidebar:
@@ -20,7 +22,6 @@ es:
2022
new: "Nuevo"
2123
new_conversation: "Nueva Conversación"
2224
add_participants: "Agregar Participantes"
23-
create_conversation: "Crear Conversación"
2425
empty:
2526
no_messages: "Aún no hay mensajes. ¿Por qué no iniciar la conversación?"
2627
platform_invitation:
@@ -72,7 +73,7 @@ es:
7273
placeholder: "Escribe tu mensaje..."
7374
send: "Enviar"
7475
new_message_notifier:
75-
new_message: "Nuevo mensaje en %{conversation_title}"
76+
new_message: "Nuevo mensaje"
7677
from_html: "De: %{sender}"
7778
notifications:
7879
index:

0 commit comments

Comments
 (0)