From 1ff0fc508b67df28724e691a219b54afcd4fa3f2 Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Mon, 13 Nov 2017 22:14:12 +0100 Subject: [PATCH] suite contacts --- app/controllers/admin/contacts_controller.rb | 4 ++-- app/views/admin/contacts/_contact.html.haml | 12 ++++++++---- app/views/admin/contacts/_form.haml | 3 +++ app/views/admin/contacts/index.html.haml | 6 ++++-- db/migrate/20171113205813_add_infos_to_contacts.rb | 7 +++++++ 5 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20171113205813_add_infos_to_contacts.rb diff --git a/app/controllers/admin/contacts_controller.rb b/app/controllers/admin/contacts_controller.rb index 7bd3044..27bc1d9 100644 --- a/app/controllers/admin/contacts_controller.rb +++ b/app/controllers/admin/contacts_controller.rb @@ -7,8 +7,8 @@ class Admin::ContactsController < ApplicationController @contacts = Contact.order("created_at DESC") - if params[:archived] - @contacts = @contacts.where(:archived => true) + if params[:status] + @contacts = @contacts.where(:status => params[:status]) else @contacts = @contacts.where("archived IS NULL or archived = 0") end diff --git a/app/views/admin/contacts/_contact.html.haml b/app/views/admin/contacts/_contact.html.haml index d30753f..61cbf36 100644 --- a/app/views/admin/contacts/_contact.html.haml +++ b/app/views/admin/contacts/_contact.html.haml @@ -1,6 +1,9 @@ %tr.vertical_center.contact#contact{:id => contact.id} %td{:style => "vertical-align:middle;"} =image_tag "/provenance/#{contact.provenance_id}.png", :style => "width:20px;border-radius:50%;box-shadow:0 0 3px rgba(0,0,0,0.5)" + %td + -if contact.urgent + %div{:style => "width:10px;height:10px;border-radius:50%;"} %td{:style => "vertical-align:middle;"} -if !contact.readed %span{:style => "display:inline-block;width:10px;height:10px;border-radius:50%;background:#00B3EC"} @@ -10,10 +13,11 @@ %td =contact.name %td - =contact.email - %br - =contact.tel - + =contact.cp + =contact.city + %td + =contact.small_comment + %td -if contact.admin %span{:style => "background:#{contact.admin.color};padding:5px 10px;color:white"} diff --git a/app/views/admin/contacts/_form.haml b/app/views/admin/contacts/_form.haml index 975f03e..666a931 100644 --- a/app/views/admin/contacts/_form.haml +++ b/app/views/admin/contacts/_form.haml @@ -1,6 +1,8 @@ = semantic_form_for [:admin, @contact], :remote => true do |f| .content =f.inputs do + = f.input :contact_status, :label => "Status :", :collection => ["En cours", "Signés","En attente", "Archivé"] + = f.input :urgent, :label => "Urgent ?" = f.input :readed, :label => "Lu ?" = f.input :admin_id, :label => "Géré par ?", :collection => (Admin.where(:contact_role => true).all.map{|u|[ u.username, u.id]}), :as => :select = f.input :archived, :label => "Archivé ?" @@ -17,6 +19,7 @@ = f.input :city, :label => "Ville" = f.input :country, :label => "Pays", :as => :string + = f.input :small_comment, :label => "Commentaire court" = f.input :notes, :label => "Notes" diff --git a/app/views/admin/contacts/index.html.haml b/app/views/admin/contacts/index.html.haml index 238a958..69af419 100644 --- a/app/views/admin/contacts/index.html.haml +++ b/app/views/admin/contacts/index.html.haml @@ -4,9 +4,11 @@ %h1 Liste des contacts %p - =link_to "Actifs", admin_contacts_path + -["En cours", "Signés","En attente", "Archivé"].each do |status| + + =link_to "Actifs", admin_contacts_path(:status => status) + - =link_to "Archivés", admin_contacts_path(:archived => true) %table.table.table-hover %thead#Admin_rows_header.rows_header diff --git a/db/migrate/20171113205813_add_infos_to_contacts.rb b/db/migrate/20171113205813_add_infos_to_contacts.rb new file mode 100644 index 0000000..7df10d2 --- /dev/null +++ b/db/migrate/20171113205813_add_infos_to_contacts.rb @@ -0,0 +1,7 @@ +class AddInfosToContacts < ActiveRecord::Migration + def change + add_column :contacts, :small_comment, :text + add_column :contacts, :contact_status, :string + add_column :contacts, :urgent, :boolean + end +end