diff --git a/app/assets/stylesheets/users.scss b/app/assets/stylesheets/users.scss index efc2526..ff7ab97 100644 --- a/app/assets/stylesheets/users.scss +++ b/app/assets/stylesheets/users.scss @@ -1,3 +1,23 @@ // Place all the styles related to the Users controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: https://sass-lang.com/ + +.form-tag { + display: flex; + width: 100%; +} +.text-field { + flex: 5; + margin: 3px; +} +.submit-button { + flex: 1; + margin: 3px; +} +.stack { + display: flex; + flex-direction: column; +} +.stack > * + * { + margin-top: .5rem; +} diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6e18a4c..ccd077b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -44,8 +44,11 @@ def index end def search - @users = User.search(params[:search]).where.not(id: current_user.id) - @users_to_add = @users.reject do |user| + other_users = User.search(params[:search]).where.not(id: current_user.id) + @users_to_add = other_users.reject do |user| + current_user.sent_contact_request?(user) + end + @users = other_users.select do |user| current_user.sent_contact_request?(user) end end diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 2acae9d..581301a 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -26,4 +26,4 @@ -<% end %> \ No newline at end of file +<% end %> diff --git a/app/views/users/search.html.erb b/app/views/users/search.html.erb index 8a618e0..aac107e 100644 --- a/app/views/users/search.html.erb +++ b/app/views/users/search.html.erb @@ -1,42 +1,18 @@ -
<%= I18n.t('user.attributes.username') %> | -<%= I18n.t('user.attributes.firstname')%> | -<%= I18n.t('user.attributes.lastname')%> | -<%= I18n.t('user.attributes.email')%> | -|
---|---|---|---|---|
<%= user.username%> | -<%= user.firstname%> | -<%= user.lastname%> | -<%= user.email %> | - <% if @users_to_add.include? user %> -<%= button_to '+', user_contact_requests_path(user), method: :post, id: user.id %> | - <% end %> -