Commit 26e5b3d6c63c9359dae7d95ac195ac5f5e008789

Authored by Marcos Pereira
1 parent 7949d4e8

Confirmation modal on join community buttons

app/controllers/public/profile_controller.rb
@@ -94,8 +94,7 @@ class ProfileController < PublicController @@ -94,8 +94,7 @@ class ProfileController < PublicController
94 94
95 def join 95 def join
96 if !user.memberships.include?(profile) 96 if !user.memberships.include?(profile)
97 - return if profile.community? && profile.requires_email &&  
98 - current_person && !current_person.public_fields.include?("email") 97 + return if profile.community? && show_confirmation_modal?(profile)
99 98
100 profile.add_member(user) 99 profile.add_member(user)
101 if !profile.members.include?(user) 100 if !profile.members.include?(user)
app/helpers/memberships_helper.rb
1 module MembershipsHelper 1 module MembershipsHelper
2 2
3 - def join_community_button(logged)  
4 - url = logged ? profile.join_url : profile.join_not_logged_url 3 + def join_community_button options={:logged => false}
  4 + url = options[:logged] ? profile.join_url : profile.join_not_logged_url
5 5
6 - if profile.requires_email? && current_person && !current_person.public_fields.include?("email") 6 + if show_confirmation_modal? profile
7 modal_button :add, _('Join this community'), url, class: 'join-community' 7 modal_button :add, _('Join this community'), url, class: 'join-community'
8 else 8 else
9 button :add, _('Join this community'), url, class: 'join-community' 9 button :add, _('Join this community'), url, class: 'join-community'
10 end 10 end
11 end 11 end
  12 +
  13 + def show_confirmation_modal? profile
  14 + profile.requires_email? && current_person && !current_person.public_fields.include?("email")
  15 + end
  16 +
12 end 17 end
app/helpers/profile_image_helper.rb
@@ -61,6 +61,8 @@ module ProfileImageHelper @@ -61,6 +61,8 @@ module ProfileImageHelper
61 image_tag(profile_icon(profile, size), opt ) 61 image_tag(profile_icon(profile, size), opt )
62 end 62 end
63 63
  64 + include MembershipsHelper
  65 +
64 def links_for_balloon(profile) 66 def links_for_balloon(profile)
65 if environment.enabled?(:show_balloon_with_profile_links_when_clicked) 67 if environment.enabled?(:show_balloon_with_profile_links_when_clicked)
66 if profile.kind_of?(Person) 68 if profile.kind_of?(Person)
@@ -76,7 +78,7 @@ module ProfileImageHelper @@ -76,7 +78,7 @@ module ProfileImageHelper
76 {_('Wall') => {:href => url_for(profile.public_profile_url)}}, 78 {_('Wall') => {:href => url_for(profile.public_profile_url)}},
77 {_('Members') => {:href => url_for(:controller => :profile, :action => :members, :profile => profile.identifier)}}, 79 {_('Members') => {:href => url_for(:controller => :profile, :action => :members, :profile => profile.identifier)}},
78 {_('Agenda') => {:href => url_for(:controller => :profile, :action => :events, :profile => profile.identifier)}}, 80 {_('Agenda') => {:href => url_for(:controller => :profile, :action => :events, :profile => profile.identifier)}},
79 - {_('Join') => {:href => url_for(profile.join_url), :class => 'join-community', :style => 'display: none'}}, 81 + {_('Join') => {:href => url_for(profile.join_url), :class => 'join-community'+ (show_confirmation_modal?(profile) ? ' modal-toggle' : '') , :style => 'display: none'}},
80 {_('Leave community') => {:href => url_for(profile.leave_url), :class => 'leave-community', :style => 'display: none'}}, 82 {_('Leave community') => {:href => url_for(profile.leave_url), :class => 'leave-community', :style => 'display: none'}},
81 {_('Send an e-mail') => {:href => url_for(:profile => profile.identifier, :controller => 'contact', :action => 'new'), :class => 'send-an-email', :style => 'display: none'}} 83 {_('Send an e-mail') => {:href => url_for(:profile => profile.identifier, :controller => 'contact', :action => 'new'), :class => 'send-an-email', :style => 'display: none'}}
82 ] 84 ]
app/views/blocks/profile_info_actions/_join_leave_community.html.erb
@@ -8,11 +8,11 @@ @@ -8,11 +8,11 @@
8 class: 'leave-community', 8 class: 'leave-community',
9 style: 'position: relative;' %> 9 style: 'position: relative;' %>
10 <% else %> 10 <% else %>
11 - <%= join_community_button(true) %> 11 + <%= join_community_button({:logged => true}) %>
12 <% end %> 12 <% end %>
13 <% end %> 13 <% end %>
14 <% else %> 14 <% else %>
15 - <%= join_community_button(false) %> 15 + <%= join_community_button %>
16 <% end %> 16 <% end %>
17 </div> 17 </div>
18 18
app/views/profile/_private_profile.html.erb
@@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
7 7
8 <% button_bar do %> 8 <% button_bar do %>
9 <% if @action == :join && logged_in? %> 9 <% if @action == :join && logged_in? %>
10 - <%= button(:add, content_tag('span', _('Join')), profile.join_url, :class => 'join-community', :title => _("Join community"), :style => 'position: relative;') %> 10 + <%= join_community_button({:logged => true}) %>
11 <% end %> 11 <% end %>
12 <% if @action == :add_friend && logged_in? && !user.already_request_friendship?(profile) %> 12 <% if @action == :add_friend && logged_in? && !user.already_request_friendship?(profile) %>
13 <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %> 13 <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %>