Commit 2c251ae841fcbf667b9d73fedb255b072cd34085
Committed by
Gabriela Navarro
1 parent
c9eccb09
Exists in
master
and in
28 other branches
join_button: Join/Leave/Login Button
- Added buttons at members block. - Added checkbox to show or not the buttons on the community members. - Removed the render button "enter/leave" when the checkbox that enables the button is unchecked - Adjusted style CSS and display button - Added cucumber and unit tests. - Removed some spaces. - There are two cucumber tests that wasn't done by the our team that fail if you don't use selenium. The files are publish_article.feature line 20 and search_enterprises.feature line 33 and we didn't modify them. (ActionItem2844) Signed-off-by: Arthur Del Esposte <arthurmde@yahoo.com.br> Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Fabio Teixeira <fabio1079@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Leandro Alves <leandrosustenido@gmail.com> Signed-off-by: Tales Martins <tales.martins@gmail.com> Signed-off-by: Andre Bedran <bedran.fleck@gmail.com> Signed-off-by: Eduardo Vital <vitaldu@gmail.com>
Showing
10 changed files
with
151 additions
and
41 deletions
Show diff stats
app/helpers/box_organizer_helper.rb
... | ... | @@ -4,4 +4,10 @@ module BoxOrganizerHelper |
4 | 4 | render :partial => 'icon_selector', :locals => { :icon => icon } |
5 | 5 | end |
6 | 6 | |
7 | -end | |
7 | + def extra_option_checkbox(option) | |
8 | + if [:human_name, :name, :value, :checked, :options].all? {|k| option.key? k} | |
9 | + labelled_check_box(option[:human_name], option[:name], option[:value], option[:checked], option[:options]) | |
10 | + end | |
11 | + end | |
12 | + | |
13 | +end | |
8 | 14 | \ No newline at end of file | ... | ... |
app/models/members_block.rb
1 | 1 | class MembersBlock < ProfileListBlock |
2 | + settings_items :show_join_leave_button, :type => :boolean, :default => false | |
2 | 3 | |
3 | 4 | def self.description |
4 | 5 | _('Members') |
... | ... | @@ -14,8 +15,15 @@ class MembersBlock < ProfileListBlock |
14 | 15 | |
15 | 16 | def footer |
16 | 17 | profile = self.owner |
18 | + show_button_block = show_join_leave_button | |
19 | + | |
17 | 20 | lambda do |
18 | - link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | |
21 | + if show_button_block | |
22 | + @view_all = link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | |
23 | + render "blocks/profile_info_actions/join_leave_community" | |
24 | + else | |
25 | + link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members' | |
26 | + end | |
19 | 27 | end |
20 | 28 | end |
21 | 29 | |
... | ... | @@ -23,4 +31,14 @@ class MembersBlock < ProfileListBlock |
23 | 31 | owner.members |
24 | 32 | end |
25 | 33 | |
26 | -end | |
34 | + def extra_option | |
35 | + data = { | |
36 | + :human_name => _("Show join leave button"), | |
37 | + :name => 'block[show_join_leave_button]', | |
38 | + :value => true, | |
39 | + :checked => show_join_leave_button, | |
40 | + :options => {} | |
41 | + } | |
42 | + end | |
43 | + | |
44 | +end | |
27 | 45 | \ No newline at end of file | ... | ... |
app/models/profile_list_block.rb
app/views/blocks/profile_info_actions/_join_leave_community.rhtml
0 → 100644
... | ... | @@ -0,0 +1,29 @@ |
1 | +<%= @view_all unless @view_all.nil? %> | |
2 | + | |
3 | +<% if logged_in? %> | |
4 | + <% if profile.members.include?(user) %> | |
5 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
6 | + :class => 'leave-community', | |
7 | + :title => _("Leave community"), | |
8 | + :style => 'position: relative;') %> | |
9 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
10 | + :class => 'join-community', | |
11 | + :title => _("Join community"), | |
12 | + :style => 'position: relative; display: none;') %> | |
13 | + <% else %> | |
14 | + <% unless profile.already_request_membership?(user) %> | |
15 | + <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
16 | + :class => 'leave-community', | |
17 | + :title => _("Leave community"), | |
18 | + :style => 'position: relative; display: none;') %> | |
19 | + <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
20 | + :class => 'join-community', | |
21 | + :title => _("Join community"), | |
22 | + :style => 'position: relative;') %> | |
23 | + <% end %> | |
24 | + <% end %> | |
25 | +<% else %> | |
26 | + <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, | |
27 | + :class => 'button with-text icon-add', | |
28 | + :title => _('Join this community') %> | |
29 | +<% end %> | |
0 | 30 | \ No newline at end of file | ... | ... |
app/views/blocks/profile_info_actions/community.rhtml
1 | 1 | <ul> |
2 | + <li> | |
3 | + <%= render "blocks/profile_info_actions/join_leave_community" %> | |
4 | + </li> | |
2 | 5 | <% if logged_in? %> |
3 | - <% if profile.members.include?(user) %> | |
4 | - <li> | |
5 | - <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
6 | - :class => 'leave-community', | |
7 | - :title => _("Leave community"), | |
8 | - :style => 'position: relative;') %> | |
9 | - <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
10 | - :class => 'join-community', | |
11 | - :title => _("Join community"), | |
12 | - :style => 'position: relative; display: none;') %> | |
13 | - </li> | |
14 | - <% else %> | |
15 | - <% unless profile.already_request_membership?(user) %> | |
16 | - <li> | |
17 | - <%= button(:delete, content_tag('span', __('Leave community')), profile.leave_url, | |
18 | - :class => 'leave-community', | |
19 | - :title => _("Leave community"), | |
20 | - :style => 'position: relative; display: none;') %> | |
21 | - <%= button(:add, content_tag('span', __('Join')), profile.join_url, | |
22 | - :class => 'join-community', | |
23 | - :title => _("Join community"), | |
24 | - :style => 'position: relative;') %> | |
25 | - </li> | |
26 | - <% end %> | |
27 | - <% end %> | |
28 | - | |
29 | 6 | <% if profile.enable_contact? %> |
30 | 7 | <li> |
31 | 8 | <%= link_to content_tag('span', _('Send an e-mail')), |
... | ... | @@ -39,11 +16,5 @@ |
39 | 16 | <li><%= report_abuse(profile, :button) %></li> |
40 | 17 | |
41 | 18 | <%= render_environment_features(:profile_actions) %> |
42 | - <% else %> | |
43 | - <li> | |
44 | - <%= link_to content_tag('span', _('Join')), profile.join_not_logged_url, | |
45 | - :class => 'button with-text icon-add', | |
46 | - :title => _('Join this community') %> | |
47 | - </li> | |
48 | 19 | <% end %> |
49 | 20 | -</ul> |
21 | +</ul> | |
50 | 22 | \ No newline at end of file | ... | ... |
app/views/box_organizer/_profile_list_block.rhtml
... | ... | @@ -2,5 +2,8 @@ |
2 | 2 | <%= labelled_form_field _('Limit of items'), text_field(:block, :limit, :size => 3) %> |
3 | 3 | <%= check_box(:block, :prioritize_profiles_with_image) %> |
4 | 4 | <label for="block_prioritize_profiles_with_image"><%= _('Prioritize profiles with image') %></label> |
5 | -</div> | |
6 | 5 | |
6 | + <div> | |
7 | + <%= extra_option_checkbox(@block.extra_option) %> | |
8 | + </div> | |
9 | +</div> | |
7 | 10 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,55 @@ |
1 | +Feature: | |
2 | + In order to enter in a community | |
3 | + As a logged user | |
4 | + I want to enter in a community by 'join leave' button in members block | |
5 | + | |
6 | + Background: | |
7 | + Given the following users | |
8 | + | login | name | | |
9 | + | joaosilva | Joao Silva | | |
10 | + | mariasilva | Maria Silva | | |
11 | + And the following communities | |
12 | + | owner | identifier | name | | |
13 | + | joaosilva | sample-community | Sample Community | | |
14 | + And the following blocks | |
15 | + | owner | type | | |
16 | + | sample-community | MembersBlock | | |
17 | + And I am logged in as "joaosilva" | |
18 | + And I go to sample-community's control panel | |
19 | + And I follow "Edit sideboxes" | |
20 | + And I follow "Edit" within ".members-block" | |
21 | + And I check "Show join leave button" | |
22 | + And I press "Save" | |
23 | + | |
24 | + Scenario: a user can join in a community by members block's button | |
25 | + Given I am logged in as "mariasilva" | |
26 | + And I go to sample-community's homepage | |
27 | + When I follow "Join" within ".members-block" | |
28 | + And I go to mariasilva's control panel | |
29 | + And I follow "Manage my groups" | |
30 | + Then I should see "Sample Community" | |
31 | + | |
32 | + Scenario: a user can leave a community by members block's button | |
33 | + Given "Maria Silva" is a member of "Sample Community" | |
34 | + And I am logged in as "mariasilva" | |
35 | + When I go to sample-community's homepage | |
36 | + And I follow "Leave community" within ".members-block" | |
37 | + And I go to mariasilva's control panel | |
38 | + And I follow "Manage my groups" | |
39 | + Then I should not see "Sample Community" | |
40 | + | |
41 | + Scenario: a not logged in user can log in by members block's button | |
42 | + Given I am not logged in | |
43 | + When I go to sample-community's homepage | |
44 | + And I follow "Join" within ".members-block" | |
45 | + Then I should see "Username / Email" | |
46 | + | |
47 | + Scenario: the join-leave button do not appear if the checkbox show-join-leave-button is not checked | |
48 | + And I go to sample-community's control panel | |
49 | + And I follow "Edit sideboxes" | |
50 | + And I follow "Edit" within ".members-block" | |
51 | + And I uncheck "Show join leave button" | |
52 | + And I press "Save" | |
53 | + When I go to sample-community's homepage | |
54 | + Then I should not see "Join" within ".members-block" | |
55 | + And I should not see "Leave community" within ".members-block" | ... | ... |
public/designs/themes/base/style.css
... | ... | @@ -506,7 +506,6 @@ div#notice { |
506 | 506 | #content .people-block .block-footer-content a, |
507 | 507 | #content .profile-list-block .block-footer-content a, |
508 | 508 | #content .enterprises-block .block-footer-content a, |
509 | -#content .members-block .block-footer-content a, | |
510 | 509 | #content .communities-block .block-footer-content a, |
511 | 510 | #content .friends-block .block-footer-content a { |
512 | 511 | position: absolute; |
... | ... | @@ -518,6 +517,32 @@ div#notice { |
518 | 517 | padding-right: 15px; |
519 | 518 | background: url(imgs/arrow-right-p.png) 100% 50% no-repeat; |
520 | 519 | } |
520 | +#content .members-block .block-footer-content a { | |
521 | + position: absolute; | |
522 | + top: 2px; | |
523 | + right: 0px; | |
524 | + font-size: 11px; | |
525 | + color: #000; | |
526 | + text-decoration: none; | |
527 | + padding-right: 15px; | |
528 | +} | |
529 | +#content .members-block .block-footer-content a.button { | |
530 | + position: relative; | |
531 | + padding-left: 10px; | |
532 | + background-color: #EEE; | |
533 | + border: 1px solid #CCC; | |
534 | + color: #555; | |
535 | +} | |
536 | +#content .members-block .block-footer-content a.button:hover { | |
537 | + color: #FFF; | |
538 | + background-color: #555; | |
539 | + border: 1px solid #2e3436; | |
540 | + text-decoration: none; | |
541 | +} | |
542 | +#content .members-block .block-footer-content a.button span { | |
543 | + margin: 0px; | |
544 | + padding: 0px 0px 0px 7px; | |
545 | +} | |
521 | 546 | |
522 | 547 | #content .profile-list-block .block-title { |
523 | 548 | text-align: left; | ... | ... |
public/javascripts/add-and-join.js
... | ... | @@ -12,7 +12,7 @@ jQuery(function($) { |
12 | 12 | }) |
13 | 13 | |
14 | 14 | $(".join-community").live('click', function(){ |
15 | - clicked = $(this) | |
15 | + clicked = $(".join-community"); | |
16 | 16 | url = clicked.attr("href"); |
17 | 17 | loading_for_button(this); |
18 | 18 | $.post(url, function(data){ |
... | ... | @@ -29,7 +29,7 @@ jQuery(function($) { |
29 | 29 | }) |
30 | 30 | |
31 | 31 | $(".leave-community").live('click', function(){ |
32 | - clicked = $(this) | |
32 | + clicked = $(".leave-community"); | |
33 | 33 | url = clicked.attr("href"); |
34 | 34 | loading_for_button(this); |
35 | 35 | $.post(url, function(data){ | ... | ... |
test/unit/members_block_test.rb