Changes delete conversation button tooltip to 'hide' or 'delete'
This commit is contained in:
parent
5d44fa771a
commit
27a1886834
4 changed files with 39 additions and 12 deletions
|
|
@ -10,8 +10,13 @@ class ConversationVisibilitiesController < ApplicationController
|
||||||
@vis = ConversationVisibility.where(:person_id => current_user.person.id,
|
@vis = ConversationVisibility.where(:person_id => current_user.person.id,
|
||||||
:conversation_id => params[:conversation_id]).first
|
:conversation_id => params[:conversation_id]).first
|
||||||
if @vis
|
if @vis
|
||||||
|
participants = @vis.conversation.participants.count
|
||||||
if @vis.destroy
|
if @vis.destroy
|
||||||
flash[:notice] = I18n.t('conversations.destroy.success')
|
if participants == 1
|
||||||
|
flash[:notice] = I18n.t('conversations.destroy.delete_success')
|
||||||
|
else
|
||||||
|
flash[:notice] = I18n.t('conversations.destroy.hide_success')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
redirect_to conversations_path
|
redirect_to conversations_path
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,14 @@
|
||||||
-# the COPYRIGHT file.
|
-# the COPYRIGHT file.
|
||||||
|
|
||||||
.conversation_participants
|
.conversation_participants
|
||||||
|
- if conversation.participants.count > 1
|
||||||
|
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
|
||||||
|
conversation_visibility_path(conversation),
|
||||||
|
:method => 'delete',
|
||||||
|
:data => { :confirm => "#{t('.hide')}?" },
|
||||||
|
:title => t('.hide'),
|
||||||
|
:class => 'close_conversation')
|
||||||
|
- else
|
||||||
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
|
= link_to(content_tag(:div, nil, :class => 'icons-deletelabel'),
|
||||||
conversation_visibility_path(conversation),
|
conversation_visibility_path(conversation),
|
||||||
:method => 'delete',
|
:method => 'delete',
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,8 @@ en:
|
||||||
show:
|
show:
|
||||||
reply: "reply"
|
reply: "reply"
|
||||||
replying: "Replying..."
|
replying: "Replying..."
|
||||||
delete: "delete and block conversation"
|
hide: "hide and mute conversation"
|
||||||
|
delete: "delete conversation"
|
||||||
new:
|
new:
|
||||||
to: "to"
|
to: "to"
|
||||||
subject: "subject"
|
subject: "subject"
|
||||||
|
|
@ -377,8 +378,8 @@ en:
|
||||||
new_conversation:
|
new_conversation:
|
||||||
fail: "Invalid message"
|
fail: "Invalid message"
|
||||||
destroy:
|
destroy:
|
||||||
success: "Conversation successfully removed"
|
delete_success: "Conversation successfully deleted"
|
||||||
|
hide_success: "Conversation successfully hidden"
|
||||||
date:
|
date:
|
||||||
formats:
|
formats:
|
||||||
fullmonth_day: "%B %d"
|
fullmonth_day: "%B %d"
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,18 @@ describe ConversationVisibilitiesController, :type => :controller do
|
||||||
delete :destroy, :conversation_id => @conversation.id
|
delete :destroy, :conversation_id => @conversation.id
|
||||||
}.not_to change(ConversationVisibility, :count)
|
}.not_to change(ConversationVisibility, :count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'returns "hidden"' do
|
||||||
|
get :destroy, :conversation_id => @conversation.id
|
||||||
|
expect(flash.notice).to include("hidden")
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'returns "deleted" when last participant' do
|
||||||
|
get :destroy, :conversation_id => @conversation.id
|
||||||
|
sign_out :user
|
||||||
|
sign_in :user, bob
|
||||||
|
get :destroy, :conversation_id => @conversation.id
|
||||||
|
expect(flash.notice).to include("deleted")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
Loading…
Reference in a new issue