Commit 26e5b3d6c63c9359dae7d95ac195ac5f5e008789
1 parent
7949d4e8
Exists in
staging
and in
31 other branches
Confirmation modal on join community buttons
Showing
5 changed files
with
15 additions
and
9 deletions
Show diff stats
app/controllers/public/profile_controller.rb
... | ... | @@ -94,8 +94,7 @@ class ProfileController < PublicController |
94 | 94 | |
95 | 95 | def join |
96 | 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 | 99 | profile.add_member(user) |
101 | 100 | if !profile.members.include?(user) | ... | ... |
app/helpers/memberships_helper.rb
1 | 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 | 7 | modal_button :add, _('Join this community'), url, class: 'join-community' |
8 | 8 | else |
9 | 9 | button :add, _('Join this community'), url, class: 'join-community' |
10 | 10 | end |
11 | 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 | 17 | end | ... | ... |
app/helpers/profile_image_helper.rb
... | ... | @@ -61,6 +61,8 @@ module ProfileImageHelper |
61 | 61 | image_tag(profile_icon(profile, size), opt ) |
62 | 62 | end |
63 | 63 | |
64 | + include MembershipsHelper | |
65 | + | |
64 | 66 | def links_for_balloon(profile) |
65 | 67 | if environment.enabled?(:show_balloon_with_profile_links_when_clicked) |
66 | 68 | if profile.kind_of?(Person) |
... | ... | @@ -76,7 +78,7 @@ module ProfileImageHelper |
76 | 78 | {_('Wall') => {:href => url_for(profile.public_profile_url)}}, |
77 | 79 | {_('Members') => {:href => url_for(:controller => :profile, :action => :members, :profile => profile.identifier)}}, |
78 | 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 | 82 | {_('Leave community') => {:href => url_for(profile.leave_url), :class => 'leave-community', :style => 'display: none'}}, |
81 | 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 | 8 | class: 'leave-community', |
9 | 9 | style: 'position: relative;' %> |
10 | 10 | <% else %> |
11 | - <%= join_community_button(true) %> | |
11 | + <%= join_community_button({:logged => true}) %> | |
12 | 12 | <% end %> |
13 | 13 | <% end %> |
14 | 14 | <% else %> |
15 | - <%= join_community_button(false) %> | |
15 | + <%= join_community_button %> | |
16 | 16 | <% end %> |
17 | 17 | </div> |
18 | 18 | ... | ... |
app/views/profile/_private_profile.html.erb
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | |
8 | 8 | <% button_bar do %> |
9 | 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 | 11 | <% end %> |
12 | 12 | <% if @action == :add_friend && logged_in? && !user.already_request_friendship?(profile) %> |
13 | 13 | <%= button(:add, content_tag('span', _('Add friend')), profile.add_url, :class => 'add-friend', :title => _("Add friend"), :style => 'position: relative;') %> | ... | ... |