add a user satisfaction form'

This commit is contained in:
lucien mollard 2018-08-08 17:37:41 +02:00
parent c1db49d4b4
commit 9ecc5f7928
16 changed files with 98 additions and 1 deletions

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm-80 128c-40.2 0-78 17.7-103.8 48.6-8.5 10.2-7.1 25.3 3.1 33.8 10.2 8.4 25.3 7.1 33.8-3.1 16.6-19.9 41-31.4 66.9-31.4s50.3 11.4 66.9 31.4c8.1 9.7 23.1 11.9 33.8 3.1 10.2-8.5 11.5-23.6 3.1-33.8C326 321.7 288.2 304 248 304z" fill="#dc3832"/></svg>

After

Width:  |  Height:  |  Size: 613 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160-64c-17.7 0-32 14.3-32 32s14.3 32 32 32 32-14.3 32-32-14.3-32-32-32zm8 144H160c-13.2 0-24 10.8-24 24s10.8 24 24 24h176c13.2 0 24-10.8 24-24s-10.8-24-24-24z" fill="#f9b916"/></svg>

After

Width:  |  Height:  |  Size: 479 B

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 496 512"><path d="M248 8C111 8 0 119 0 256s111 248 248 248 248-111 248-248S385 8 248 8zm0 448c-110.3 0-200-89.7-200-200S137.7 56 248 56s200 89.7 200 200-89.7 200-200 200zm-80-216c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm160 0c17.7 0 32-14.3 32-32s-14.3-32-32-32-32 14.3-32 32 14.3 32 32 32zm4 72.6c-20.8 25-51.5 39.4-84 39.4s-63.2-14.3-84-39.4c-8.5-10.2-23.7-11.5-33.8-3.1-10.2 8.5-11.5 23.6-3.1 33.8 30 36 74.1 56.6 120.9 56.6s90.9-20.6 120.9-56.6c8.5-10.2 7.1-25.3-3.1-33.8-10.1-8.4-25.3-7.1-33.8 3.1z" fill="#4daa75"/></svg>

After

Width:  |  Height:  |  Size: 604 B

View file

@ -0,0 +1,15 @@
@import "colors";
@import "constants";
#user-satisfaction {
text-align: center;
padding: 20px;
.icon {
padding: 10px 5px;
&:hover {
cursor: pointer;
}
}
}

View file

@ -89,4 +89,16 @@
background-image: image-url("icons/info-blue.svg");
object-fit: contain;
}
&.smile {
background-image: image-url("icons/smile-regular.svg");
}
&.frown {
background-image: image-url("icons/frown-regular.svg");
}
&.meh {
background-image: image-url("icons/meh-regular.svg");
}
}

View file

@ -0,0 +1,6 @@
class NewUser::FeedbacksController < ApplicationController
def create
current_user.feedbacks.create!(mark: params[:mark])
flash.notice = "Merci de votre retour"
end
end

3
app/models/feedback.rb Normal file
View file

@ -0,0 +1,3 @@
class Feedback < ApplicationRecord
belongs_to :user
end

View file

@ -16,6 +16,7 @@ class User < ApplicationRecord
has_many :invites, dependent: :destroy
has_many :dossiers_invites, through: :invites, source: :dossier
has_many :piece_justificative, dependent: :destroy
has_many :feedbacks, dependent: :destroy
has_one :france_connect_information, dependent: :destroy
delegate :given_name, :family_name, :email_france_connect, :gender, :birthdate, :birthplace, :france_connect_particulier_id, to: :france_connect_information

View file

@ -15,6 +15,17 @@
= link_to(dossiers_path(current_tab: 'dossiers-invites')) do
dossiers invités
- if current_user.feedbacks.empty?
.container#user-satisfaction
%h3 Que pensez-vous de ce service ?
.icons
= link_to feedback_path(mark: 0), data: { remote: true, method: :post } do
%span.icon.frown
= link_to feedback_path(mark: 1), data: { remote: true, method: :post } do
%span.icon.meh
= link_to feedback_path(mark: 2), data: { remote: true, method: :post } do
%span.icon.smile
.container
- if @dossiers.present?
- if @dossiers.total_pages >= 2

View file

@ -0,0 +1,4 @@
document.querySelector('#user-satisfaction').innerHTML = '';
var flashMessagesView = "<%= escape_javascript(render partial: 'layouts/flash_messages') %>";
document.querySelector("#flash_messages").outerHTML = flashMessagesView;
<% flash.clear %>

View file

@ -23,6 +23,9 @@
%span.icon.search
%span.icon.sign-out
%span.icon.info
%span.icon.frown
%span.icon.meh
%span.icon.smile
%h1 Formulaires

View file

@ -282,6 +282,7 @@ Rails.application.routes.draw do
post 'recherche'
end
end
resource :feedback, only: [:create]
end
#

View file

@ -0,0 +1,10 @@
class CreateFeedbacks < ActiveRecord::Migration[5.2]
def change
create_table :feedbacks do |t|
t.references :user, foreign_key: true
t.integer :mark
t.timestamps
end
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2018_07_24_153247) do
ActiveRecord::Schema.define(version: 2018_08_08_142237) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -328,6 +328,14 @@ ActiveRecord::Schema.define(version: 2018_07_24_153247) do
t.datetime "updated_at"
end
create_table "feedbacks", force: :cascade do |t|
t.bigint "user_id"
t.integer "mark"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["user_id"], name: "index_feedbacks_on_user_id"
end
create_table "flipflop_features", force: :cascade do |t|
t.string "key", null: false
t.boolean "enabled", default: false, null: false
@ -625,6 +633,7 @@ ActiveRecord::Schema.define(version: 2018_07_24_153247) do
add_foreign_key "closed_mails", "procedures"
add_foreign_key "commentaires", "dossiers"
add_foreign_key "dossiers", "users"
add_foreign_key "feedbacks", "users"
add_foreign_key "initiated_mails", "procedures"
add_foreign_key "procedure_paths", "administrateurs"
add_foreign_key "procedure_paths", "procedures"

View file

@ -0,0 +1,5 @@
FactoryBot.define do
factory :feedback do
mark 3
end
end

View file

@ -10,6 +10,7 @@ describe 'new_user/dossiers/index.html.haml', type: :view do
before do
allow(view).to receive(:new_demarche_url).and_return('#')
allow(controller).to receive(:current_user) { user }
assign(:user_dossiers, Kaminari.paginate_array(user_dossiers).page(1))
assign(:dossiers_invites, Kaminari.paginate_array(dossiers_invites).page(1))
assign(:dossiers, Kaminari.paginate_array(user_dossiers).page(1))
@ -70,4 +71,17 @@ describe 'new_user/dossiers/index.html.haml', type: :view do
expect(rendered).to have_selector('ul.tabs li.active', count: 1)
end
end
context "quand le user n'a aucun feedback" do
it "affiche le formulaire de satisfaction" do
expect(rendered).to have_selector('#user-satisfaction', text: 'Que pensez-vous de ce service ?')
end
end
context "quand le user a un feedback" do
let(:user) { create(:user, feedbacks: [build(:feedback)]) }
it "n'affiche pas le formulaire de satisfaction" do
expect(rendered).to_not have_selector('#user-satisfaction')
end
end
end