small design fixes for invites
This commit is contained in:
parent
66b7b7e27a
commit
2a553940d4
4 changed files with 19 additions and 25 deletions
|
|
@ -3,7 +3,6 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class InvitationsController < ApplicationController
|
||||
|
||||
before_action :authenticate_user!
|
||||
|
||||
def new
|
||||
|
|
@ -14,13 +13,13 @@ class InvitationsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html do
|
||||
render 'invitations/new', layout: false
|
||||
render "invitations/new", layout: false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
emails = inviter_params[:emails].split(',').map(&:strip).uniq
|
||||
emails = inviter_params[:emails].split(",").map(&:strip).uniq
|
||||
|
||||
valid_emails, invalid_emails = emails.partition {|email| valid_email?(email) }
|
||||
|
||||
|
|
@ -28,21 +27,18 @@ class InvitationsController < ApplicationController
|
|||
session[:invalid_email_invites] = invalid_emails
|
||||
|
||||
unless valid_emails.empty?
|
||||
Workers::Mail::InviteEmail.perform_async(valid_emails.join(','),
|
||||
current_user.id,
|
||||
inviter_params)
|
||||
Workers::Mail::InviteEmail.perform_async(valid_emails.join(","), current_user.id, inviter_params)
|
||||
end
|
||||
|
||||
if emails.empty?
|
||||
flash[:error] = t('invitations.create.empty')
|
||||
flash[:error] = t("invitations.create.empty")
|
||||
elsif invalid_emails.empty?
|
||||
flash[:notice] = t('invitations.create.sent', :emails => valid_emails.join(', '))
|
||||
flash[:notice] = t("invitations.create.sent", emails: valid_emails.join(", "))
|
||||
elsif valid_emails.empty?
|
||||
flash[:error] = t('invitations.create.rejected') + invalid_emails.join(', ')
|
||||
flash[:error] = t("invitations.create.rejected", emails: invalid_emails.join(", "))
|
||||
else
|
||||
flash[:error] = t('invitations.create.sent', :emails => valid_emails.join(', '))
|
||||
flash[:error] << '. '
|
||||
flash[:error] << t('invitations.create.rejected') + invalid_emails.join(', ')
|
||||
flash[:error] = t("invitations.create.sent", emails: valid_emails.join(", ")) + ". " +
|
||||
t("invitations.create.rejected", emails: invalid_emails.join(", "))
|
||||
end
|
||||
|
||||
redirect_to :back
|
||||
|
|
@ -57,9 +53,9 @@ class InvitationsController < ApplicationController
|
|||
def html_safe_string_from_session_array(key)
|
||||
return "" unless session[key].present?
|
||||
return "" unless session[key].respond_to?(:join)
|
||||
value = session[key].join(', ').html_safe
|
||||
value = session[key].join(", ").html_safe
|
||||
session[key] = nil
|
||||
return value
|
||||
value
|
||||
end
|
||||
|
||||
def inviter_params
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
= text_field_tag 'email_inviter[emails]', @invalid_emails, title: t('.comma_separated_plz'),
|
||||
placeholder: 'foo@bar.com, max@foo.com...', class: "form-control"
|
||||
#already_sent
|
||||
= t('invitations.create.note_already_sent', emails: @valid_emails) unless @valid_emails.empty?
|
||||
= t("invitations.create.note_already_sent", emails: @valid_emails) unless @valid_emails.empty?
|
||||
|
||||
.form-group
|
||||
%label.col-sm-2.control-label{ for: 'email_inviter_locale' }
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ en:
|
|||
invitations:
|
||||
create:
|
||||
sent: "Invitations have been sent to: %{emails}"
|
||||
rejected: "The following email addresses had problems: "
|
||||
rejected: "The following email addresses had problems: %{emails}"
|
||||
no_more: "You have no more invitations."
|
||||
empty: "Please enter at least one email address."
|
||||
note_already_sent: "Invitations have already been sent to: %{emails}"
|
||||
|
|
|
|||
|
|
@ -81,10 +81,10 @@ describe InvitationsController, :type => :controller do
|
|||
expect(response).to redirect_to @referer
|
||||
end
|
||||
|
||||
it 'flashes an error' do
|
||||
it "flashes an error" do
|
||||
post :create, @invite
|
||||
|
||||
expected = I18n.t('invitations.create.rejected') + @emails.split(',').join(', ')
|
||||
expected = I18n.t("invitations.create.rejected", emails: @emails.split(",").join(", "))
|
||||
expect(flash[:error]).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
|
@ -108,12 +108,10 @@ describe InvitationsController, :type => :controller do
|
|||
expect(response).to redirect_to @referer
|
||||
end
|
||||
|
||||
it 'flashes a notice' do
|
||||
it "flashes a notice" do
|
||||
post :create, @invite
|
||||
expected = I18n.t('invitations.create.sent', :emails =>
|
||||
@valid_emails.split(',').join(', ')) +
|
||||
'. ' + I18n.t('invitations.create.rejected') +
|
||||
@invalid_emails.split(',').join(', ')
|
||||
expected = I18n.t("invitations.create.sent", emails: @valid_emails.split(",").join(", ")) + ". " +
|
||||
I18n.t("invitations.create.rejected", emails: @invalid_emails.split(",").join(", "))
|
||||
expect(flash[:error]).to eq(expected)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue