From 279fbd1925b6fb71f0d2bbacf9cb834de33f5a8c Mon Sep 17 00:00:00 2001 From: Gabriel Silva Date: Tue, 14 Jun 2016 17:59:46 +0000 Subject: [PATCH] finishes followed profiles list --- app/controllers/my_profile/followers_controller.rb | 2 +- app/controllers/public/profile_controller.rb | 3 ++- app/models/person.rb | 2 +- app/models/profile.rb | 2 +- app/views/followers/_profile_list.html.erb | 8 ++++---- app/views/followers/_set_category_modal.html.erb | 10 ++++++---- public/stylesheets/blocks/profile-info.scss | 5 ++--- public/stylesheets/profile-list.scss | 41 +++++++++++++++++++++++++++-------------- 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/controllers/my_profile/followers_controller.rb b/app/controllers/my_profile/followers_controller.rb index 170e772..2b3ce53 100644 --- a/app/controllers/my_profile/followers_controller.rb +++ b/app/controllers/my_profile/followers_controller.rb @@ -1,7 +1,7 @@ class FollowersController < MyProfileController def index - @followed_people = Person.all.limit(10).paginate(:per_page => 5, :page => params[:npage]) + @followed_people = current_person.following_profiles.paginate(:per_page => 5, :page => params[:npage]) end def set_category diff --git a/app/controllers/public/profile_controller.rb b/app/controllers/public/profile_controller.rb index e091766..b526ad4 100644 --- a/app/controllers/public/profile_controller.rb +++ b/app/controllers/public/profile_controller.rb @@ -166,7 +166,8 @@ class ProfileController < PublicController if current_person.follows?(profile) current_person.unfollow(profile) end - redirect_to profile.url + redirect_url = params["redirect_to"] ? params["redirect_to"] : profile.url + redirect_to redirect_url end def check_friendship diff --git a/app/models/person.rb b/app/models/person.rb index d9f19b2..255bc7b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -601,7 +601,7 @@ class Person < Profile protected def followed_by?(profile) - self == profile || self.is_a_friend?(profile) || self.followers.include?(profile) + self == profile || self.followers.include?(profile) end end diff --git a/app/models/profile.rb b/app/models/profile.rb index 499291c..2e11755 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -204,7 +204,7 @@ class Profile < ApplicationRecord scope :more_recent, -> { order "created_at DESC" } scope :following_profiles, -> person { - distinct.select('profiles.*'). + distinct.select('profiles.*, profile_followers.group'). joins('join profile_followers ON profile_followers.profile_id = profiles.id'). where('profile_followers.follower_id = ?', person.id) } diff --git a/app/views/followers/_profile_list.html.erb b/app/views/followers/_profile_list.html.erb index 2611cbe..9551797 100644 --- a/app/views/followers/_profile_list.html.erb +++ b/app/views/followers/_profile_list.html.erb @@ -3,12 +3,12 @@
  • <%= link_to_profile profile_image(profile) + tag('br') + profile.short_name, profile.identifier, :class => 'profile-link' %> -
    - <%= _(Category) %> -
    +

    + <%= profile.group %> +

    <%= button_without_text :remove, content_tag('span',_('unfollow')), - { :controller => "profile", :profile => profile.identifier , :action => 'unfollow', :redirect_to => "gabriel" }, + { :controller => "profile", :profile => profile.identifier , :action => 'unfollow', :redirect_to => url_for({:controller => "followers", :profile => user.identifier}) }, :title => _('remove') %> <%= modal_icon_button :change_categoy, content_tag('span',_('change category')), profile.url.merge(:controller => 'followers', :action => 'set_category', :profile => profile.identifier)%> diff --git a/app/views/followers/_set_category_modal.html.erb b/app/views/followers/_set_category_modal.html.erb index fa9d159..81631e5 100644 --- a/app/views/followers/_set_category_modal.html.erb +++ b/app/views/followers/_set_category_modal.html.erb @@ -1,8 +1,10 @@ -
    -

    <%= _("Select a category") %>

    +
    +

    <%= _("Choose a new category") %>

    - <%= labelled_text_field _("Category: "), "person_category" %> -
    +
    + <%= labelled_text_field _("Category: "), "person_category" %> +
    +
    <%= submit_button('save', _('Save')) %> <%= modal_close_button _("Cancel") %>
    diff --git a/public/stylesheets/blocks/profile-info.scss b/public/stylesheets/blocks/profile-info.scss index cac9d52..b1d8611 100644 --- a/public/stylesheets/blocks/profile-info.scss +++ b/public/stylesheets/blocks/profile-info.scss @@ -99,9 +99,6 @@ margin: 0px 0px 5px 0px; padding: 2px; } -#follower-container { - padding-top: 5px; -} #follower-container:hover { background-color: #eee; -o-transition:.5s; @@ -109,6 +106,8 @@ -moz-transition:.5s; -webkit-transition:.5s; transition:.5s; + padding-top: 5px; + padding-bottom: 5px; } #follower-container #category-form { margin-bottom: 5px; diff --git a/public/stylesheets/profile-list.scss b/public/stylesheets/profile-list.scss index 05cfeef..3458bb9 100644 --- a/public/stylesheets/profile-list.scss +++ b/public/stylesheets/profile-list.scss @@ -216,22 +216,35 @@ font-size: 12px; } .action-profile-members .profile_link{ - position: relative; + position: relative; } .action-profile-members .profile_link span.new-profile:last-child{ - position: absolute; - top: 3px; - right: 2px; - text-transform: uppercase; - color: #FFF; - font-size: 9px; - background: #66CC33; - padding: 2px; - display: block; - width: 35px; - font-weight: 700; + position: absolute; + top: 3px; + right: 2px; + text-transform: uppercase; + color: #FFF; + font-size: 9px; + background: #66CC33; + padding: 2px; + display: block; + width: 35px; + font-weight: 700; } .action-profile-members .profile_link .fn{ - font-style: normal; - color: #000; + font-style: normal; + color: #000; +} +.category-name { + margin-top: 0px; + margin-bottom: 0px; + font-style: italic; + color: #888a85; + text-align: center; +} +.set-category-modal { + width: 250px; +} +.set-category-modal #actions-container { + margin-top: 20px } -- libgit2 0.21.2