contacts
This commit is contained in:
parent
7935d77684
commit
1b86493950
@ -11,6 +11,7 @@
|
||||
@import "vendor/select2";
|
||||
|
||||
@import "admin/topics";
|
||||
@import "admin/contacts";
|
||||
|
||||
#admin_navbar{
|
||||
border-radius:0px;
|
||||
|
15
app/assets/stylesheets/admin/contacts.scss
Normal file
15
app/assets/stylesheets/admin/contacts.scss
Normal file
@ -0,0 +1,15 @@
|
||||
#contact_actions{
|
||||
margin-top:50px;
|
||||
|
||||
.contact_action{
|
||||
margin-bottom:50px;
|
||||
padding:20px;
|
||||
border:2px solid black;
|
||||
|
||||
.name{
|
||||
float:right;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
71
app/controllers/admin/contact_actions_controller.rb
Normal file
71
app/controllers/admin/contact_actions_controller.rb
Normal file
@ -0,0 +1,71 @@
|
||||
class Admin::ContactActionsController < ApplicationController
|
||||
layout "admin"
|
||||
|
||||
before_filter :auth_admin
|
||||
|
||||
def index
|
||||
|
||||
@contact_actions = ContactAction.order("created_at DESC").all
|
||||
end
|
||||
|
||||
|
||||
def show
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
|
||||
@contact_action_actions = @contact_action.contact_action_actions
|
||||
|
||||
end
|
||||
|
||||
|
||||
def new
|
||||
@contact_action = ContactAction.new(:contact_id => params[:contact_id],:admin_id => current_admin.id, :action_at => Time.now)
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
@contact_action.action_at = @contact_action.action_at.in_time_zone("Paris")
|
||||
end
|
||||
|
||||
def create
|
||||
@contact_action = ContactAction.new(contact_action_params)
|
||||
@contact = @contact_action.contact
|
||||
|
||||
if @contact_action.save
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
@contact = @contact_action.contact
|
||||
|
||||
if @contact_action.update_attributes(contact_action_params)
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
def destroy
|
||||
@contact_action = ContactAction.find(params[:id])
|
||||
|
||||
@contact_action.destroy
|
||||
@contact = @contact_action.contact
|
||||
@contact_actions = @contact.contact_actions.order("action_at DESC").all
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
def contact_action_params
|
||||
params.require(:contact_action).permit!
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
@ -5,7 +5,14 @@ class Admin::ContactsController < ApplicationController
|
||||
|
||||
def index
|
||||
|
||||
@contacts = Contact.order("created_at DESC").all
|
||||
@contacts = Contact.order("created_at DESC")
|
||||
|
||||
if params[:archived]
|
||||
@contacts = @contacts.where(:archived => true)
|
||||
else
|
||||
@contacts = @contacts.where("archived IS NULL or archived = 0")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -16,6 +23,8 @@ class Admin::ContactsController < ApplicationController
|
||||
@contact.readed = true
|
||||
@contact.save
|
||||
end
|
||||
|
||||
@contact_actions = @contact.contact_actions
|
||||
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
class Contact < ActiveRecord::Base
|
||||
|
||||
belongs_to :admin
|
||||
has_many :contact_actions
|
||||
validates :name, :presence => true
|
||||
validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
||||
validates :message, :presence => true
|
||||
|
5
app/models/contact_action.rb
Normal file
5
app/models/contact_action.rb
Normal file
@ -0,0 +1,5 @@
|
||||
class ContactAction < ActiveRecord::Base
|
||||
belongs_to :contact
|
||||
belongs_to :admin
|
||||
belongs_to :contact_action_pattern
|
||||
end
|
2
app/models/contact_action_pattern.rb
Normal file
2
app/models/contact_action_pattern.rb
Normal file
@ -0,0 +1,2 @@
|
||||
class ContactActionPattern < ActiveRecord::Base
|
||||
end
|
27
app/views/admin/contact_actions/_contact_action.html.haml
Normal file
27
app/views/admin/contact_actions/_contact_action.html.haml
Normal file
@ -0,0 +1,27 @@
|
||||
.contact_action#contact_action{:id => contact_action.id, :style => "border-color:#{contact_action.admin.color};"}
|
||||
%p.name
|
||||
|
||||
-if contact_action.contact.admin
|
||||
%span{:style => "background:#{contact_action.admin.color};padding:5px 10px;color:white"}
|
||||
=contact_action.admin.username
|
||||
%p
|
||||
=l contact_action.action_at
|
||||
|
||||
%p
|
||||
%strong
|
||||
-if contact_action.contact_action_pattern
|
||||
=contact_action.contact_action_pattern.title
|
||||
|
||||
%p
|
||||
= contact_action.action_message
|
||||
|
||||
.actions
|
||||
|
||||
|
||||
= link_to i(:"trash-o"), [:admin, contact_action], :confirm => 'Voulez-vous vraiment supprimer cette action ?', :method => :delete, :remote => true
|
||||
|
||||
= link_to i(:pencil), edit_admin_contact_action_path(contact_action), :remote => true
|
||||
|
||||
|
||||
|
||||
|
15
app/views/admin/contact_actions/_form.haml
Normal file
15
app/views/admin/contact_actions/_form.haml
Normal file
@ -0,0 +1,15 @@
|
||||
= semantic_form_for [:admin, @contact_action], :remote => true do |f|
|
||||
.content
|
||||
=f.hidden_field :contact_id
|
||||
=f.inputs do
|
||||
= f.input :contact_action_pattern_id, :label => "Action", :collection => (ContactActionPattern.all.map{|u|[ u.title, u.id]}), :as => :select, :include_blank => false
|
||||
= f.input :action_at, :label => "Date", :as =>:qi_datetime_picker
|
||||
= f.input :admin_id, :label => "Par ?", :collection => (Admin.where(:contact_role => true).all.map{|u|[ u.username, u.id]}), :as => :select
|
||||
|
||||
= f.input :action_message, :label => "Message"
|
||||
|
||||
|
||||
.actions
|
||||
=f.submit "Sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
|
63
app/views/admin/contact_actions/_show.html.haml
Normal file
63
app/views/admin/contact_actions/_show.html.haml
Normal file
@ -0,0 +1,63 @@
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
=l @contact.created_at
|
||||
%tr
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
=@contact.name
|
||||
%tr
|
||||
%td
|
||||
Email
|
||||
%td
|
||||
=@contact.email
|
||||
%tr
|
||||
%td
|
||||
Téléphone
|
||||
%td
|
||||
=@contact.tel
|
||||
%tr
|
||||
%td
|
||||
Lieu
|
||||
%td
|
||||
=@contact.place
|
||||
|
||||
|
||||
|
||||
%hr
|
||||
=simple_format @contact.message
|
||||
%hr
|
||||
|
||||
|
||||
%table.table
|
||||
%tr
|
||||
%td
|
||||
Adresse
|
||||
%td
|
||||
=@contact.address
|
||||
%tr
|
||||
%td
|
||||
Adresse suite
|
||||
%td
|
||||
=@contact.address2
|
||||
%tr
|
||||
%td
|
||||
Ville
|
||||
%td
|
||||
=@contact.cp
|
||||
=@contact.city
|
||||
|
||||
%tr
|
||||
%td
|
||||
Pays
|
||||
|
||||
%td
|
||||
=@contact.country
|
||||
|
||||
%hr
|
||||
=simple_format @contact.notes
|
||||
%hr
|
2
app/views/admin/contact_actions/create.js.erb
Normal file
2
app/views/admin/contact_actions/create.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#contact_actions').html("<%= escape_javascript(render(@contact_actions))%>");
|
||||
close_pane_hover();
|
1
app/views/admin/contact_actions/destroy.js.erb
Normal file
1
app/views/admin/contact_actions/destroy.js.erb
Normal file
@ -0,0 +1 @@
|
||||
$('#contact_action_<%= @contact_action.id %>').remove();
|
4
app/views/admin/contact_actions/edit.haml
Normal file
4
app/views/admin/contact_actions/edit.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Modifier une fiche étudiant
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contact_actions/edit.js.erb
Normal file
1
app/views/admin/contact_actions/edit.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
43
app/views/admin/contact_actions/index.html.haml
Normal file
43
app/views/admin/contact_actions/index.html.haml
Normal file
@ -0,0 +1,43 @@
|
||||
= link_to 'Ajouter une action', new_admin_contact_action_path, :class => "btn btn-primary", :style => "float:right;", :remote => true
|
||||
|
||||
|
||||
%h1 Liste des contact_actions
|
||||
|
||||
|
||||
%table.table.table-hover
|
||||
%thead#Admin_rows_header.rows_header
|
||||
|
||||
%tr
|
||||
%td
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
Coordonnées
|
||||
|
||||
|
||||
%td Géré par
|
||||
|
||||
%td{:style => "width:150px"}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
%tbody#admin_rows.rows
|
||||
|
||||
=render @contact_actions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
2
app/views/admin/contact_actions/index.js.erb
Normal file
2
app/views/admin/contact_actions/index.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
|
||||
$('#Admin_index_block').replaceWith("<%= escape_javascript(render(:partial => "index_block")) %>");
|
4
app/views/admin/contact_actions/new.haml
Normal file
4
app/views/admin/contact_actions/new.haml
Normal file
@ -0,0 +1,4 @@
|
||||
.container
|
||||
%h1 Ajouter une action
|
||||
|
||||
=render :partial => "form"
|
1
app/views/admin/contact_actions/new.js.erb
Normal file
1
app/views/admin/contact_actions/new.js.erb
Normal file
@ -0,0 +1 @@
|
||||
show_pane_hover("<%= escape_javascript(render(:partial => "form"))%>",700,900);
|
6
app/views/admin/contact_actions/show.html.haml
Normal file
6
app/views/admin/contact_actions/show.html.haml
Normal file
@ -0,0 +1,6 @@
|
||||
= link_to i(:pencil), edit_admin_contact_path(@contact), :remote => true
|
||||
= link_to "retour", admin_contacts_path(), :class => "btn btn-primary"
|
||||
#show=render :partial => "show"
|
||||
|
||||
|
||||
|
2
app/views/admin/contact_actions/update.js.erb
Normal file
2
app/views/admin/contact_actions/update.js.erb
Normal file
@ -0,0 +1,2 @@
|
||||
$('#contact_actions').html("<%= escape_javascript(render(@contact_actions))%>");
|
||||
close_pane_hover();
|
@ -1,23 +1,31 @@
|
||||
%tr.vertical_center.contact#contact{:id => contact.id, :class => ("success" if !contact.readed)}
|
||||
|
||||
%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{:style => "vertical-align:middle;"}
|
||||
-if !contact.readed
|
||||
%span{:style => "display:inline-block;width:10px;height:10px;border-radius:50%;background:#00B3EC"}
|
||||
|
||||
%td
|
||||
=l contact.created_at
|
||||
%td
|
||||
=contact.name
|
||||
%td
|
||||
=contact.email
|
||||
%td
|
||||
%br
|
||||
=contact.tel
|
||||
|
||||
|
||||
%td.actions
|
||||
%td
|
||||
-if contact.admin
|
||||
%span{:style => "background:#{contact.admin.color};padding:5px 10px;color:white"}
|
||||
=contact.admin.username
|
||||
%td.actions{:style => "width:430px;text-align:right;"}
|
||||
|
||||
|
||||
= link_to i(:"trash-o"), [:admin, contact], :confirm => 'Voulez-vous vraiment supprimer cet utilisateur ?', :method => :delete, :remote => true
|
||||
= link_to ic(:"trash-o"), [:admin, contact], :confirm => 'Voulez-vous vraiment supprimer cet utilisateur ?', :method => :delete, :remote => true, :class => "btn btn-danger"
|
||||
|
||||
= link_to i(:pencil), edit_admin_contact_path(contact), :remote => true
|
||||
= link_to ic(:pencil)+" modifier / attribuer la fiche", edit_admin_contact_path(contact), :remote => true, :class => "btn btn-warning"
|
||||
|
||||
= link_to i(:eye), [:admin, contact]
|
||||
= link_to ic(:eye)+ " détail de la fiche ", [:admin, contact], :class => "btn btn-primary"
|
||||
|
||||
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
.content
|
||||
=f.inputs do
|
||||
= 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é ?"
|
||||
= f.input :name, :label => "Nom"
|
||||
= f.input :email, :label => "Email"
|
||||
= f.input :tel, :label => "Téléphone"
|
||||
|
@ -3,22 +3,26 @@
|
||||
|
||||
%h1 Liste des contacts
|
||||
|
||||
%p
|
||||
=link_to "Actifs", admin_contacts_path
|
||||
|
||||
=link_to "Archivés", admin_contacts_path(:archived => true)
|
||||
|
||||
%table.table.table-hover
|
||||
%thead#Admin_rows_header.rows_header
|
||||
|
||||
%tr
|
||||
%td
|
||||
%td
|
||||
%td
|
||||
Date
|
||||
%td
|
||||
Nom
|
||||
%td
|
||||
Email
|
||||
%td
|
||||
Tel
|
||||
Coordonnées
|
||||
|
||||
|
||||
|
||||
%td Géré par
|
||||
|
||||
%td{:style => "width:150px"}
|
||||
|
||||
|
@ -1,6 +1,32 @@
|
||||
= link_to i(:pencil), edit_admin_contact_path(@contact), :remote => true
|
||||
= link_to "retour", admin_contacts_path(), :class => "btn btn-primary"
|
||||
.right
|
||||
= link_to "retour", admin_contacts_path(), :class => "btn btn-primary"
|
||||
= link_to ic(:pencil)+" modifier / attribuer la fiche", edit_admin_contact_path(@contact), :remote => true, :class => "btn btn-warning"
|
||||
%br
|
||||
%br
|
||||
#show=render :partial => "show"
|
||||
|
||||
|
||||
|
||||
= link_to 'Ajouter une action', new_admin_contact_action_path(:contact_id => @contact.id, :test => "test"), :class => "btn btn-success", :style => "float:right;", :remote => true
|
||||
|
||||
|
||||
%h2 Interactions
|
||||
|
||||
|
||||
#contact_actions
|
||||
=render @contact_actions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
BIN
public/provenance/1.png
Normal file
BIN
public/provenance/1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
9
test/fixtures/contact_action_patterns.yml
vendored
Normal file
9
test/fixtures/contact_action_patterns.yml
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
title: MyString
|
||||
description: MyText
|
||||
|
||||
two:
|
||||
title: MyString
|
||||
description: MyText
|
15
test/fixtures/contact_actions.yml
vendored
Normal file
15
test/fixtures/contact_actions.yml
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||
|
||||
one:
|
||||
admin_id: 1
|
||||
action_at: 2016-09-28 23:16:06
|
||||
contact_id:
|
||||
action_title: MyString
|
||||
action_message: MyText
|
||||
|
||||
two:
|
||||
admin_id: 1
|
||||
action_at: 2016-09-28 23:16:06
|
||||
contact_id:
|
||||
action_title: MyString
|
||||
action_message: MyText
|
7
test/models/contact_action_pattern_test.rb
Normal file
7
test/models/contact_action_pattern_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ContactActionPatternTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
7
test/models/contact_action_test.rb
Normal file
7
test/models/contact_action_test.rb
Normal file
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class ContactActionTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user