From 480fbbdbfb5805bda606e0f8322853ceda7bb833 Mon Sep 17 00:00:00 2001 From: Benjamin Myara Date: Mon, 3 Sep 2018 14:10:45 +0100 Subject: [PATCH] done --- app/assets/stylesheets/pages/_contacts.scss | 16 +++++++++++++++- app/controllers/connections_controller.rb | 6 ++++++ app/views/connections/new.html.erb | 1 - app/views/pages/_contact.html.erb | 4 ++++ app/views/pages/index.html.erb | 2 ++ config/routes.rb | 2 +- 6 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/pages/_contacts.scss b/app/assets/stylesheets/pages/_contacts.scss index a897fcf..ad0cd0b 100644 --- a/app/assets/stylesheets/pages/_contacts.scss +++ b/app/assets/stylesheets/pages/_contacts.scss @@ -6,7 +6,8 @@ a:hover { display: flex; justify-content: space-between; a { - align-self: flex-end; + align-self: center; + margin-top: 19px; } } @@ -145,6 +146,19 @@ a:hover { overflow: scroll; } +.close { + margin-right: 8px; + margin-top: -46px; + float: right; + font-size: 27px; + font-weight: bold; + line-height: 1; + color: #F55E4F; + text-shadow: 0 1px 0 #000; + opacity: 0.8; + filter: alpha(opacity=20); +} + diff --git a/app/controllers/connections_controller.rb b/app/controllers/connections_controller.rb index 0a8b48b..bf1c1be 100644 --- a/app/controllers/connections_controller.rb +++ b/app/controllers/connections_controller.rb @@ -15,4 +15,10 @@ class ConnectionsController < ApplicationController end end + + def destroy + connection = current_user.connections.find_by(contact_id: params[:id].to_i) + connection.destroy + redirect_to root_path + end end diff --git a/app/views/connections/new.html.erb b/app/views/connections/new.html.erb index 0543a78..081a36c 100644 --- a/app/views/connections/new.html.erb +++ b/app/views/connections/new.html.erb @@ -6,4 +6,3 @@ <%= f.submit %> <% end %> - diff --git a/app/views/pages/_contact.html.erb b/app/views/pages/_contact.html.erb index 6878932..724cb14 100644 --- a/app/views/pages/_contact.html.erb +++ b/app/views/pages/_contact.html.erb @@ -26,6 +26,10 @@ end <% end %> + <%= link_to connection_path(contact), method: :delete do %> + + <% end %> + diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index a9edc98..3b7a929 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -12,6 +12,8 @@ <%= render "pages/contact", contact: contact %> <% end %> + +
diff --git a/config/routes.rb b/config/routes.rb index 60e89c4..2fb2ca1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -42,6 +42,6 @@ Rails.application.routes.draw do patch '/users/:id', to: 'users#update' delete '/users/:id', to: 'users#destroy' - resources :connections, only: [:create, :new] + resources :connections, only: [:create, :new, :destroy] #get '/add_contact', to: 'connections#create' end