Commit c30872d615166cb31dcd85352d82f6550bc11dcb

Authored by Gabriel Silva
1 parent 51077785

Creates follow category form

Signed-off-by: Artur Bersan de Faria <artur_bersan@hotmail.com>
Signed-off-by: Gabriel Silva <gabriel93.silva@gmail.com>
app/controllers/public/profile_controller.rb
... ... @@ -157,14 +157,16 @@ class ProfileController &lt; PublicController
157 157  
158 158 def follow
159 159 if !current_person.follows?(profile)
160   - current_person.follow(profile)
  160 + current_person.follow(profile, params['follow']['category'])
161 161 end
  162 + redirect_to profile.url
162 163 end
163 164  
164 165 def unfollow
165 166 if current_person.follows?(profile)
166 167 current_person.unfollow(profile)
167 168 end
  169 + redirect_to profile.url
168 170 end
169 171  
170 172 def check_friendship
... ...
app/models/person.rb
... ... @@ -200,7 +200,7 @@ class Person &lt; Profile
200 200 end
201 201 end
202 202  
203   - def follow(profile, group = nil)
  203 + def follow(profile, group = "")
204 204 unless self.following_profiles.include?(profile)
205 205 profile_follower = ProfileFollower.new
206 206 profile_follower.profile = profile
... ...
app/views/blocks/profile_info_actions/_person.html.erb
... ... @@ -8,10 +8,15 @@
8 8 <% end %>
9 9  
10 10 <li>
11   - <% if profile.follows?(user) %>
12   - <%= button(:unfollow, content_tag('span', _('Unfollow')), "#", :class => 'add-friend', :title => _("Unfollow"), :style => 'position: relative;') %>
  11 + <% if user.follows?(profile) %>
  12 + <%= button(:unfollow, content_tag('span', _('Unfollow')), {:profile => profile.identifier, :controller => 'profile', :action => 'unfollow'}) %>
13 13 <% else %>
14   - <%= modal_button(:follow, _('Follow'),{ :profile => profile.identifier, :controller => 'followed_people', :action => 'set_category'}, :title => _("Follow"), :style => 'position: relative;') %>
  14 + <form id="follower-container" action="<%= url_for({:profile => profile.identifier, :controller => 'profile', :action => 'follow'}) %>">
  15 + <div id="category-form" style="display: none;">
  16 + <%= labelled_text_field _("Choose a category: "), "follow[category]" %>
  17 + </div>
  18 + <%= submit_button('follow', _('Follow')) %>
  19 + </form>
15 20 <% end %>
16 21 </li>
17 22  
... ...
public/javascripts/application.js
... ... @@ -26,6 +26,7 @@
26 26 *= require pagination.js
27 27 * views speficics
28 28 *= require add-and-join.js
  29 +*= require followers.js
29 30 *= require report-abuse.js
30 31 *= require autogrow.js
31 32 *= require require_login.js
... ...
public/javascripts/followers.js 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +$("#follower-container").live("mouseenter", function() {
  2 + $("#category-form").fadeIn();
  3 +}).live("mouseleave", function() {
  4 + $("#category-form").fadeOut();
  5 +});
... ...
public/stylesheets/blocks/profile-info.scss
... ... @@ -99,3 +99,17 @@
99 99 margin: 0px 0px 5px 0px;
100 100 padding: 2px;
101 101 }
  102 +#follower-container {
  103 + padding-top: 5px;
  104 +}
  105 +#follower-container:hover {
  106 + background-color: #eee;
  107 + -o-transition:.5s;
  108 + -ms-transition:.5s;
  109 + -moz-transition:.5s;
  110 + -webkit-transition:.5s;
  111 + transition:.5s;
  112 +}
  113 +#follower-container #category-form {
  114 + margin-bottom: 5px;
  115 +}
... ...