Commit 11901a70507139d4b11162131b0eced781be147e
1 parent
7bc0a2a4
Exists in
master
and in
28 other branches
sub_organizations_plugin: Add display full visualization
Add mode that displays more information about related organizations on the relationship page. (ActionItem 2866) Signed-off-by: Arthur Del Esposte <athurmde@yahoo.com.br> Signed-off-by: Carlos Andre <carlos.andre.souza@msn.com> Signed-off-by: Daniel Bucher <daniel.bucher88@gmail.com> Signed-off-by: David Carlos <ddavidcarlos1392@gmail.com> Signed-off-by: Gabriela Navarro <navarro1703@gmail.com> Signed-off-by: Leandro Alves <leandrosustenido@gmail.com> Signed-off-by: Luiz Matos <luizff.matos@gmail.com> Signed-off-by: Marcos Ramos <ms.ramos@outlook.com>
Showing
9 changed files
with
352 additions
and
20 deletions
Show diff stats
plugins/sub_organizations/controllers/sub_organizations_plugin_profile_controller.rb
... | ... | @@ -4,20 +4,40 @@ class SubOrganizationsPluginProfileController < ProfileController |
4 | 4 | before_filter :organizations_only |
5 | 5 | |
6 | 6 | def children |
7 | - @organizations = SubOrganizationsPlugin::Relation.children(profile) | |
8 | - | |
7 | + children = SubOrganizationsPlugin::Relation.children(profile) | |
8 | + family_relation(children) | |
9 | 9 | render 'related_organizations' |
10 | 10 | end |
11 | 11 | |
12 | 12 | def parents |
13 | - @organizations = SubOrganizationsPlugin::Relation.parents(profile) | |
14 | - | |
13 | + parents = SubOrganizationsPlugin::Relation.parents(profile) | |
14 | + family_relation(parents) | |
15 | 15 | render 'related_organizations' |
16 | 16 | end |
17 | 17 | |
18 | - | |
19 | 18 | private |
20 | 19 | |
20 | + def family_relation(_profile) | |
21 | + @communities = _profile.communities | |
22 | + @enterprises = _profile.enterprises | |
23 | + @full = true | |
24 | + | |
25 | + if !params[:type] and !params[:display] | |
26 | + @communities = SubOrganizationsPlugin.limit(@communities) | |
27 | + @enterprises = SubOrganizationsPlugin.limit(@enterprises) | |
28 | + @full = false | |
29 | + elsif !params[:type] | |
30 | + @total = _profile | |
31 | + @total = @total.paginate(:per_page => 2, :page => params[:npage]) | |
32 | + if params[:display] == 'compact' | |
33 | + @full = false | |
34 | + end | |
35 | + else | |
36 | + @communities = @communities.paginate(:per_page => 2, :page => params[:npage]) | |
37 | + @enterprises = @enterprises.paginate(:per_page => 2, :page => params[:npage]) | |
38 | + end | |
39 | + end | |
40 | + | |
21 | 41 | def organizations_only |
22 | 42 | render_not_found if !profile.organization? |
23 | 43 | end | ... | ... |
plugins/sub_organizations/features/sub_organizations_display.feature
0 → 100644
... | ... | @@ -0,0 +1,80 @@ |
1 | +Feature: sub_organizations_display | |
2 | + As a user | |
3 | + I want my organizations to have blocks that lists it's related-organizations | |
4 | + In order to have quick access to it's related-organizations | |
5 | + | |
6 | + Background: | |
7 | + Given "SubOrganizations" plugin is enabled | |
8 | + And the following users | |
9 | + | login | name | | |
10 | + | nelson | Nelson | | |
11 | + And feature "enterprise_registration" is enabled on environment | |
12 | + And the following community | |
13 | + | identifier | name | owner | description | city | state | | |
14 | + | springfield | Springfield | nelson | Springfield description | Los Angeles | California | | |
15 | + | moe | Moe | nelson | Moe description | Kansas | Texas | | |
16 | + And the following enterprise | |
17 | + | identifier | name | owner | description | city | state | | |
18 | + | school | School | nelson | School description | Terra do Nunca | Billy Jean | | |
19 | + And I am logged in as "nelson" | |
20 | + And I go to springfield's control panel | |
21 | + When I follow "Edit sideboxes" | |
22 | + And I follow "Add a block" | |
23 | + And I choose "Related Organizations" | |
24 | + And I press "Add" | |
25 | + | |
26 | + @selenium | |
27 | + Scenario: Display the sub organization block when there is a sub enterprise and communitys | |
28 | + When I go to springfield's control panel | |
29 | + And I follow "Manage sub-groups" | |
30 | + And I follow "Register a new sub-enterprise" | |
31 | + And I fill in "Name" with "Bart" | |
32 | + And I press "Next" | |
33 | + Then I should see "Enterprise registration completed" | |
34 | + And I am logged in as admin | |
35 | + And I go to admin_user's control panel | |
36 | + When I follow "Tasks" within ".control-panel" | |
37 | + Then I should see "Nelson wants to create enterprise Bart." | |
38 | + And the first mail is to admin_user@example.com | |
39 | + And I choose "Accept" | |
40 | + And I press "Apply!" | |
41 | + And I am logged in as "nelson" | |
42 | + When I go to springfield's control panel | |
43 | + And I follow "Manage sub-groups" | |
44 | + And I follow "Create a new sub-community" | |
45 | + And I fill in "Name" with "Homer" | |
46 | + And I press "Create" | |
47 | + When I go to springfield's "children" page from "SubOrganizationsPluginProfileController" of "SubOrganizations" plugin | |
48 | + Then I should see "Homer" within ".related-organizations-block" | |
49 | + And I should see "Bart" within ".related-organizations-block" | |
50 | + | |
51 | + Scenario: Display with compact mode | |
52 | + Given "moe" is a sub organization of "springfield" | |
53 | + And "school" is a sub organization of "springfield" | |
54 | + When I go to springfield's homepage | |
55 | + And I follow "View all" within ".related-organizations-block" | |
56 | + Then I should see "Springfield's sub-communities" | |
57 | + And I should see "Springfield's sub-enterprises" | |
58 | + | |
59 | + Scenario: Display with full mode for sub-communities | |
60 | + Given "moe" is a sub organization of "springfield" | |
61 | + When I go to springfield's homepage | |
62 | + And I follow "View all" within ".related-organizations-block" | |
63 | + Then I should see "Springfield's sub-communities" | |
64 | + And I follow "Full" within ".search-customize-options" | |
65 | + Then I should see "Moe description" within ".related-organizations-description" | |
66 | + And I should see "Kansas, Texas" within ".related-organizations-region-name" | |
67 | + | |
68 | + Scenario: Display with full mode for sub-enterprises | |
69 | + Given "school" is a sub organization of "springfield" | |
70 | + When I go to springfield's homepage | |
71 | + And I follow "View all" within ".related-organizations-block" | |
72 | + And I should see "Springfield's sub-enterprises" | |
73 | + And I follow "Full" within ".search-customize-options" | |
74 | + Then I should see "School description" within ".related-organizations-description" | |
75 | + And I should see "Terra do Nunca, Billy Jean" within ".related-organizations-region-name" | |
76 | + | |
77 | + Scenario: Display message when display full block are empty | |
78 | + Given I follow "View all" within ".related-organizations-block" | |
79 | + Then I should see "There are no sub-communities yet." | |
80 | + And I should see "There are no sub-enterprises yet." | ... | ... |
plugins/sub_organizations/lib/sub_organizations_plugin.rb
1 | 1 | require_dependency File.dirname(__FILE__) + '/related_organizations_block' |
2 | 2 | |
3 | +class SubOrganizationsPlugin < Noosfero::Plugin; end; | |
4 | + | |
5 | +require_dependency 'sub_organizations_plugin/search_helper' | |
6 | + | |
3 | 7 | class SubOrganizationsPlugin < Noosfero::Plugin |
4 | 8 | |
9 | + include SearchHelper | |
10 | + | |
11 | + DISPLAY_LIMIT = 12 | |
12 | + | |
5 | 13 | def self.plugin_name |
6 | 14 | _("Sub-groups") |
7 | 15 | end |
... | ... | @@ -47,6 +55,10 @@ class SubOrganizationsPlugin < Noosfero::Plugin |
47 | 55 | {'sub_organizations_plugin_parent_to_be' => parent_to_be} if parent_to_be.present? |
48 | 56 | end |
49 | 57 | |
58 | + def self.limit(organizations) | |
59 | + organizations.all(:limit => DISPLAY_LIMIT, :order => 'updated_at DESC').sort_by{ rand } | |
60 | + end | |
61 | + | |
50 | 62 | def self.extra_blocks |
51 | 63 | { |
52 | 64 | RelatedOrganizationsBlock => {:type => [Enterprise, Community], :position => ['1', '2', '3']} | ... | ... |
plugins/sub_organizations/lib/sub_organizations_plugin/relation_helper.rb
0 → 100644
... | ... | @@ -0,0 +1,9 @@ |
1 | +module SubOrganizationsPlugin::RelationHelper | |
2 | + def display_relation(organization,type,display_mode) | |
3 | + if display_mode == 'full' | |
4 | + render :partial => 'sub_organizations_plugin_profile/full_related_organizations', :locals => {:organizations => organization,:organization_type => type} | |
5 | + else | |
6 | + render :partial => 'sub_organizations_plugin_profile/related_organizations', :locals => {:organizations => organization, :organization_type => type} | |
7 | + end | |
8 | + end | |
9 | +end | |
0 | 10 | \ No newline at end of file | ... | ... |
plugins/sub_organizations/lib/sub_organizations_plugin/search_helper.rb
0 → 100644
... | ... | @@ -0,0 +1,18 @@ |
1 | +require_dependency 'search_helper' | |
2 | + | |
3 | +module SubOrganizationsPlugin::SearchHelper | |
4 | + | |
5 | + include SearchHelper | |
6 | + | |
7 | + def display_selectors(display, float = 'right') | |
8 | + display = 'compact' if display.blank? | |
9 | + compact_link = display == 'compact' ? _('Compact') : link_to(_('Compact'), params.merge(:display => 'compact')) | |
10 | + full_link = display == 'full' ? _('Full') : link_to(_('Full'), params.merge(:display => 'full')) | |
11 | + content_tag('div', | |
12 | + content_tag('strong', _('Display')) + ': ' + [compact_link,full_link].compact.join(' | ').html_safe, | |
13 | + :class => 'search-customize-options' | |
14 | + ) | |
15 | + end | |
16 | + | |
17 | + | |
18 | +end | ... | ... |
plugins/sub_organizations/public/style.css
... | ... | @@ -17,3 +17,108 @@ |
17 | 17 | padding-right: 15px; |
18 | 18 | background: url(images/arrow-right-p.png) 100% 50% no-repeat; |
19 | 19 | } |
20 | + | |
21 | +.clearfix { | |
22 | + clear: both; | |
23 | +} | |
24 | + | |
25 | +.related-organizations-list-block .vcard{ | |
26 | + margin-right: 10px; | |
27 | + -webkit-border-radius: 0 !important; | |
28 | + -moz-border-radius: 0!important; | |
29 | + -o-border-radius: 0!important; | |
30 | + border-radius: 0!important; | |
31 | +} | |
32 | +.related-organizations-item-column-right .search-result-title{ | |
33 | + margin: 10px 0; | |
34 | +} | |
35 | + | |
36 | +#main-content-wrapper-8 ul{ | |
37 | + padding-left: 0; | |
38 | +} | |
39 | + | |
40 | +.related-organizations-list-block ul li{ | |
41 | + list-style: none; | |
42 | + margin: 10px 0; | |
43 | + border: 1px solid #ccc; | |
44 | + /*padding: 10px 5px;*/ | |
45 | +} | |
46 | + | |
47 | +.related-organizations-list-block ul li:hover{ | |
48 | + border: 1px solid #999; | |
49 | +} | |
50 | + | |
51 | +.related-organizations-list-block .profile_link{ | |
52 | + height: auto !important; | |
53 | + max-height: none !important; | |
54 | + max-width: none !important; | |
55 | + height: 150px; | |
56 | + width: 150px; | |
57 | +} | |
58 | + | |
59 | +.related-organizations-list-block .org { | |
60 | + display: none !important; | |
61 | +} | |
62 | + | |
63 | +.related-organizations-item .profile-image img{ | |
64 | + max-height: 150px; | |
65 | + max-width: 150px; | |
66 | +} | |
67 | + | |
68 | + | |
69 | +.menu-submenu-list>li{ | |
70 | + border: 0!important; | |
71 | +} | |
72 | + | |
73 | +.related-organizations-list-block .menu-submenu{ | |
74 | + bottom: 147px; | |
75 | + right: 5px; | |
76 | +} | |
77 | + | |
78 | +.related-organizations-region-name{ | |
79 | + line-height: 2em; | |
80 | + font-weight: bold; | |
81 | +} | |
82 | + | |
83 | +.related-organizations-description{ | |
84 | + color: #333; | |
85 | +} | |
86 | + | |
87 | + | |
88 | +.related-organizations-list-block .vcard a{ | |
89 | + padding: 0; | |
90 | + margin: 0; | |
91 | + border: 0; | |
92 | +} | |
93 | + | |
94 | +.related-organizations-list-block .vcard img { | |
95 | + opacity: 1; | |
96 | + -webkit-transition: all 0.5s ease-out; | |
97 | + -moz-transition: all 0.5s ease-out; | |
98 | + -o-transition: all 0.5s ease-out; | |
99 | + -ms-transition: all 0.5s ease-out; | |
100 | + transition: all 0.5s ease-out; | |
101 | +} | |
102 | + | |
103 | +.related-organizations-list-block .vcard img:hover { | |
104 | + opacity: 0.5; | |
105 | +} | |
106 | + | |
107 | +.related-organizations-item-column-right { | |
108 | + float: right; | |
109 | + position: relative; | |
110 | + width: 65%; | |
111 | +} | |
112 | + | |
113 | +.related-organizations-item-column-left { | |
114 | +float: left; | |
115 | +position: relative; | |
116 | +width: 35%; | |
117 | +} | |
118 | + | |
119 | +.related-organizations-block ul { | |
120 | + min-width: 196px; | |
121 | + width: 192px; | |
122 | + margin: 0px 0px 0px -3px; | |
123 | + padding: 0px; | |
124 | +} | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.rhtml
0 → 100644
... | ... | @@ -0,0 +1,63 @@ |
1 | +<% extend SubOrganizationsPlugin::SearchHelper %> | |
2 | +<div class="related-organizations-list-block"> | |
3 | + | |
4 | + <h1><%= __("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> | |
5 | + <ul> | |
6 | + <% organizations.each do |organization| %> | |
7 | + <li class="related-organizations-item"> | |
8 | + <div class="related-organizations-item"> | |
9 | + <div class="related-organizations-item-column-left"> | |
10 | + <%= profile_image_link organization, :big, 'div' %> | |
11 | + </div> | |
12 | + <div class="related-organizations-item-column-right"> | |
13 | + <%= link_to_homepage(organization.name, organization.identifier, :class => "search-result-title") %> | |
14 | + <div class="related-organizations-description"> | |
15 | + <% if organization.description %> | |
16 | + <% body_stripped = strip_tags(organization.description) %> | |
17 | + <% elsif organization.home_page and organization.home_page.body %> | |
18 | + <% body_stripped = strip_tags(organization.home_page.body) %> | |
19 | + <% end %> | |
20 | + <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %> | |
21 | + </div> | |
22 | + <div class="related-organizations-region"> | |
23 | + <span class="related-organizations-region-label"><%= _("City") %></span> | |
24 | + <% if organization.region %> | |
25 | + <span class="related-organizations-region-name"><%= city_with_state(organization.region) %></span> | |
26 | + <% elsif organization.city and organization.state %> | |
27 | + <span class="related-organizations-region-name"><%= "#{organization.city}, #{organization.state}" %></span> | |
28 | + <% end %> | |
29 | + </div> | |
30 | + | |
31 | + <div class="related-organizations-categorization"> | |
32 | + <% organization.top_level_categorization.each do |parent, children| %> | |
33 | + <div class="related-organizations-category-<%=parent.id%> related-organizations-category"> | |
34 | + <span class="related-organizations-categorization-parent"><%= parent.name %></span> | |
35 | + <span class="related-organizations-categorization-children"> | |
36 | + <%= children.collect(&:name).join(', ') %> | |
37 | + </span> | |
38 | + </div> | |
39 | + <% end %> | |
40 | + </div> | |
41 | + </div> | |
42 | + | |
43 | + <br class="clearfix" /> | |
44 | + | |
45 | + </div> | |
46 | + </li> | |
47 | + <% end %> | |
48 | + </ul> | |
49 | + | |
50 | + <div id='pagination-related-organizations'> | |
51 | + <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | |
52 | + </div> | |
53 | + | |
54 | + <% button_bar(:class => "related-organizations-button-bar") do %> | |
55 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
56 | + <%= button :add, __("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
57 | + | |
58 | + <% if !@full %> | |
59 | + <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | |
60 | + <% end %> | |
61 | + <% end %> | |
62 | + | |
63 | +</div> | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/_related_organizations.rhtml
1 | +<% extend SubOrganizationsPlugin::ApplicationHelper %> | |
1 | 2 | <div class="common-profile-list-block"> |
2 | - | |
3 | 3 | <h1><%= __("#{profile.name}'s sub-#{organization_type.pluralize}") %></h1> |
4 | 4 | |
5 | -<ul class='profile-list'> | |
6 | -<% organizations.each do |organization| %> | |
7 | - <%= profile_image_link(organization)%> | |
8 | -<% end %> | |
9 | -</ul> | |
5 | + <ul class='profile-list'> | |
6 | + <% organizations.each do |organization| %> | |
7 | + <%= profile_image_link(organization)%> | |
8 | + <% end %> | |
9 | + </ul> | |
10 | + <% if organizations.length == 0 %> | |
11 | + <li><%= __("There are no sub-#{organization_type.pluralize} yet. " ) %></li> | |
12 | + <% end %> | |
13 | + <% button_bar(:class => "related-organizations-button-bar") do %> | |
14 | + <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
15 | + <%= button :add, __("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
10 | 16 | |
11 | -<% button_bar(:class => "related-organizations-button-bar") do %> | |
12 | - <%= button :back, _('Go back'), { :controller => 'profile' } %> | |
13 | - <%= button :add, __("Add a new #{organization_type}"), :controller => 'sub_organizations_plugin_myprofile', :action => 'index' if logged_in? && user.has_permission?(:edit_profile, profile) && !environment.enabled?("disable_asset_#{organization_type.pluralize}") %> | |
17 | + <% if !@full %> | |
18 | + <%= button :more, _('View all'), { :controller => 'sub_organizations_plugin_profile', :action => params[:action], :type => organization_type } %> | |
19 | + <% end %> | |
20 | + <% end %> | |
21 | +</div> | |
22 | +<% if @full %> | |
23 | + <div id='pagination-profiles'> | |
24 | + <%= pagination_links(organizations, {:param_name => 'npage', :page_links => true}) %> | |
25 | + </div> | |
14 | 26 | <% end %> |
15 | - | |
16 | -</div><!-- fim class="common-profile-list-block" --> | |
27 | +<!-- fim class="common-profile-list-block" --> | ... | ... |
plugins/sub_organizations/views/sub_organizations_plugin_profile/related_organizations.rhtml
1 | -<% if params[:type] != 'enterprise' %> | |
2 | - <%= render :partial => 'sub_organizations_plugin_profile/related_organizations', :locals => {:organizations => @organizations.communities, :organization_type => 'community'} %> | |
1 | +<% extend SubOrganizationsPlugin::SearchHelper %> | |
2 | +<% extend SubOrganizationsPlugin::RelationHelper %> | |
3 | + | |
4 | +<div id="search-actions"> | |
5 | + <%= display_selectors(params[:display]) %> | |
6 | +</div> | |
7 | + | |
8 | +<% if params[:type] == 'community' %> | |
9 | + <%= display_relation(@communities,params[:type],params[:display]) %> | |
10 | +<% end %> | |
11 | + | |
12 | +<% if params[:type] == 'enterprise' %> | |
13 | + <%= display_relation(@enterprises,params[:type],params[:display]) %> | |
3 | 14 | <% end %> |
4 | 15 | |
5 | -<% if params[:type] != 'community' %> | |
6 | - <%= render :partial => 'sub_organizations_plugin_profile/related_organizations', :locals => {:organizations => @organizations.enterprises, :organization_type => 'enterprise'} %> | |
16 | +<% if ["full"].include?(params[:display]) and !params[:type] %> | |
17 | + <%= display_relation(@total,"organizations",params[:display]) %> | |
18 | +<% elsif !params[:type] %> | |
19 | + <%= display_relation(@communities,"community",params[:display]) %> | |
20 | + <%= display_relation(@enterprises,"enterprise",params[:display]) %> | |
7 | 21 | <% end %> | ... | ... |