Skip to content

Commit

Permalink
Merge pull request #436 from coopdevs/fix/members-small-issues
Browse files Browse the repository at this point in the history
Little improvements in /members
  • Loading branch information
sseerrggii authored Oct 19, 2018
2 parents 54a1701 + 6e81774 commit fbd3026
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
12 changes: 4 additions & 8 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ class UsersController < ApplicationController
before_filter :authenticate_user!

def index
search_and_load_members current_organization.members.active
search_and_load_members current_organization.members.active, {s: 'member_uid asc'}
end

def manage
search_and_load_members current_organization.members
search_and_load_members current_organization.members, {s: 'member_uid asc'}
end

def show
Expand Down Expand Up @@ -57,8 +57,8 @@ def update

private

def search_and_load_members(members_scope)
@search = members_scope.ransack(search_params)
def search_and_load_members(members_scope, default_search_params)
@search = members_scope.ransack(default_search_params.merge(params.fetch(:q, {})))

@members =
@search.result.eager_load(:account, :user).page(params[:page]).per(20)
Expand All @@ -67,10 +67,6 @@ def search_and_load_members(members_scope)
@members.map { |m| MemberDecorator.new(m, self.class.helpers) }
end

def search_params
{s: 'member_uid asc'}.merge(params.fetch(:q, {}))
end

def scoped_users
current_organization.users
end
Expand Down
22 changes: 13 additions & 9 deletions app/views/users/_member_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,21 @@
</div>
<div class="to-member-card__body">
<div class="to-member-card__body__description">
<%= member.description %>
<%= member.description&.truncate(124) %>
</div>
<div class="to-member-card__body__items">
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-earphone"></span>
<%= phone_to member.phone %>
</div>
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-envelope"></span>
<%= member.mail_to %>
</div>
<% if member.phone.present? && !member.phone.blank? %>
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-earphone"></span>
<%= phone_to member.phone %>
</div>
<% end %>
<% if member.mail_to.present? && !member.mail_to.blank? %>
<div class="to-member-card__body__item">
<span class="glyphicon glyphicon-envelope"></span>
<%= member.mail_to %>
</div>
<% end %>
<div class="to-member-card__body__item">
<%= "Balance: " %>
<%= member.account_balance %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/users/_user_row.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<%= member.inactive_icon %>
<%= member.link_to_self %>
</td>
<td class="hidden-xs"> <%= member.mail_to %> </td>
<td class="hidden-xs hidden-sm"> <%= phone_to member.phone %> </td>
<td class="hidden-xs hidden-sm"> <%= member.account_balance %> </td>
<td> <%= member.mail_to %> </td>
<td> <%= phone_to member.phone %> </td>
<td> <%= member.account_balance %> </td>
<% if current_user.manages?(current_organization) %>
<td class="hover-actions hidden-xs hidden-sm">
<td class="hover-actions">
<% if member.active? %>
<%= render 'toggle_manager_link', member: member if can_toggle_manager?(member) %>
<% else %>
Expand Down
8 changes: 4 additions & 4 deletions app/views/users/manage.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
<th>
<%= sort_link @search, :user_username, User.human_attribute_name(:username) %>
</th>
<th class="hidden-xs">
<th>
<%= User.human_attribute_name(:email) %>
</th>
<th class="hidden-xs hidden-sm">
<th>
<%= User.human_attribute_name(:phone) %>
</th>
<th class="hidden-xs hidden-sm">
<th>
<%= sort_link @search, 'account_balance', Account.human_attribute_name(:balance) %>
</th>
<% if current_user.manages? current_organization %>
<th class="hidden-xs hidden-sm">
<th>
<span class="glyphicon glyphicon-hand-down"></span>
<%= t(".actions") %>
</th>
Expand Down
1 change: 1 addition & 0 deletions spec/fabricators/user_fabricator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
address { Faker::Address.street_address + " " + Faker::Address.zip_code + " " + Faker::Address.city + " (" + Faker::Address.state + ")"}
gender { ["male", "female"].shuffle.first }
description { Faker::Lorem.paragraph }
last_sign_in_at { DateTime.new(2018, 10, 1) }

terms_accepted_at DateTime.now.utc
confirmed_at DateTime.now.utc
Expand Down

0 comments on commit fbd3026

Please sign in to comment.