commit
97f3ef86b3
16 changed files with 185 additions and 49 deletions
|
@ -167,18 +167,7 @@ module Instructeurs
|
|||
|
||||
def add_filter
|
||||
if params[:value].present?
|
||||
filters = procedure_presentation.filters
|
||||
table, column = params[:field].split('/')
|
||||
label = find_field(table, column)['label']
|
||||
|
||||
filters[statut] << {
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column,
|
||||
'value' => params[:value]
|
||||
}
|
||||
|
||||
procedure_presentation.update(filters: filters)
|
||||
procedure_presentation.add_filter(statut, params[:field], params[:value])
|
||||
end
|
||||
|
||||
redirect_back(fallback_location: instructeur_procedure_url(procedure))
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
class ApiEntreprise::ExercicesJob < ApiEntreprise::Job
|
||||
rescue_from(ApiEntreprise::API::BadFormatRequest) do |exception|
|
||||
end
|
||||
|
||||
def perform(etablissement_id, procedure_id)
|
||||
etablissement = Etablissement.find(etablissement_id)
|
||||
etablissement_params = ApiEntreprise::ExercicesAdapter.new(etablissement.siret, procedure_id).to_params
|
||||
|
|
|
@ -1,6 +1,15 @@
|
|||
class ApiEntreprise::Job < ApplicationJob
|
||||
DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS = 5
|
||||
|
||||
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
|
||||
error(self, exception)
|
||||
end
|
||||
|
||||
rescue_from(ApiEntreprise::API::BadFormatRequest) do |exception|
|
||||
error(self, exception)
|
||||
end
|
||||
|
||||
def max_attempts
|
||||
ENV[MAX_ATTEMPTS_API_ENTREPRISE_JOBS].to_i || DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS
|
||||
ENV.fetch("MAX_ATTEMPTS_API_ENTREPRISE_JOBS", DEFAULT_MAX_ATTEMPTS_API_ENTREPRISE_JOBS).to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,19 +9,11 @@ class ApplicationJob < ActiveJob::Base
|
|||
Rails.logger.info("#{job.class.name} ended at #{Time.zone.now}")
|
||||
end
|
||||
|
||||
rescue_from(ApiEntreprise::API::ResourceNotFound) do |exception|
|
||||
error(self, exception)
|
||||
end
|
||||
|
||||
rescue_from(ApiEntreprise::API::BadFormatRequest) do |exception|
|
||||
error(self, exception)
|
||||
end
|
||||
|
||||
def error(job, exception)
|
||||
Raven.capture_exception(exception)
|
||||
end
|
||||
|
||||
def max_attempts
|
||||
ENV["MAX_ATTEMPTS_JOBS"].to_i || DEFAULT_MAX_ATTEMPTS_JOBS
|
||||
ENV.fetch("MAX_ATTEMPTS_JOBS", DEFAULT_MAX_ATTEMPTS_JOBS).to_i
|
||||
end
|
||||
end
|
||||
|
|
|
@ -173,8 +173,42 @@ class ProcedurePresentation < ApplicationRecord
|
|||
dossiers.includes(relations_to_include)
|
||||
end
|
||||
|
||||
def human_value_for_filter(filter)
|
||||
if filter['table'] == 'type_de_champ'
|
||||
type_de_champ = TypeDeChamp.find_by(id: filter['column'])
|
||||
return type_de_champ.dynamic_type.filter_to_human(filter['value'])
|
||||
end
|
||||
filter['value']
|
||||
end
|
||||
|
||||
def add_filter(statut, field, value)
|
||||
if value.present?
|
||||
updated_filters = self.filters
|
||||
table, column = field.split('/')
|
||||
label = find_field(table, column)['label']
|
||||
|
||||
if table == 'type_de_champ'
|
||||
type_de_champ = TypeDeChamp.find_by(id: column)
|
||||
value = type_de_champ.dynamic_type.human_to_filter(value)
|
||||
end
|
||||
|
||||
updated_filters[statut] << {
|
||||
'label' => label,
|
||||
'table' => table,
|
||||
'column' => column,
|
||||
'value' => value
|
||||
}
|
||||
|
||||
update(filters: updated_filters)
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_field(table, column)
|
||||
fields.find { |c| c['table'] == table && c['column'] == column }
|
||||
end
|
||||
|
||||
def check_allowed_displayed_fields
|
||||
displayed_fields.each do |field|
|
||||
check_allowed_field(:displayed_fields, field)
|
||||
|
|
|
@ -23,4 +23,12 @@ class TypesDeChamp::TypeDeChampBase
|
|||
def build_champ
|
||||
@type_de_champ.champ.build
|
||||
end
|
||||
|
||||
def filter_to_human(filter_value)
|
||||
filter_value
|
||||
end
|
||||
|
||||
def human_to_filter(human_value)
|
||||
human_value
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,2 +1,22 @@
|
|||
class TypesDeChamp::YesNoTypeDeChamp < TypesDeChamp::CheckboxTypeDeChamp
|
||||
def filter_to_human(filter_value)
|
||||
if filter_value == "true"
|
||||
"oui"
|
||||
elsif filter_value == "false"
|
||||
"non"
|
||||
else
|
||||
filter_value
|
||||
end
|
||||
end
|
||||
|
||||
def human_to_filter(human_value)
|
||||
human_value.downcase!
|
||||
if human_value == "oui"
|
||||
"true"
|
||||
elsif human_value == "non"
|
||||
"false"
|
||||
else
|
||||
human_value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%span.dropdown.print-menu-opener
|
||||
%button.button.dropdown-button.icon-only{ title: 'imprimer' }
|
||||
%button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer' }
|
||||
%span.icon.printer
|
||||
%ul.print-menu.dropdown-content
|
||||
%li
|
||||
|
|
|
@ -100,7 +100,7 @@
|
|||
%span.filter
|
||||
= link_to remove_filter_instructeur_procedure_path(@procedure, { statut: @statut, table: filter['table'], column: filter['column'], value: filter['value'] }) do
|
||||
%img.close-icon{ src: image_url("close.svg") }
|
||||
= "#{filter['label'].truncate(50)} : #{filter['value']}"
|
||||
= "#{filter['label'].truncate(50)} : #{@procedure_presentation.human_value_for_filter(filter)}"
|
||||
%table.table.dossiers-table.hoverable
|
||||
%thead
|
||||
%tr
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
et incubé par
|
||||
= link_to "beta.gouv.fr", "https://beta.gouv.fr", title: "le site de Beta.gouv.fr"
|
||||
%li
|
||||
= link_to "https://numerique.gouv.fr/", title: "DINUM" do
|
||||
%span.footer-logo.footer-logo-dinum{ role: 'img', 'aria-label': 'DINUM' }
|
||||
= link_to "https://beta.gouv.fr", title: "le site de Beta.gouv.fr" do
|
||||
%span.footer-logo.footer-logo-beta-gouv-fr{ role: 'img', 'aria-label': 'beta.gouv.fr' }
|
||||
= link_to "https://numerique.gouv.fr/", title: "DINUM", 'aria-label': 'DINUM' do
|
||||
%span.footer-logo.footer-logo-dinum{ role: 'img' }
|
||||
= link_to "https://beta.gouv.fr", title: "le site de Beta.gouv.fr", 'aria-label': 'beta.gouv.fr' do
|
||||
%span.footer-logo.footer-logo-beta-gouv-fr{ role: 'img' }
|
||||
%span.footer-logo.footer-logo-france{ role: 'img', 'aria-label': 'République Française' }
|
||||
|
||||
%li.footer-column
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
.prologue
|
||||
%p.mandatory-explanation
|
||||
Les champs avec un astérisque (
|
||||
Les champs suivis d’un astérisque (
|
||||
%span.mandatory> *
|
||||
) sont obligatoires.
|
||||
- if dossier.brouillon?
|
||||
|
|
|
@ -6,11 +6,18 @@
|
|||
.container
|
||||
%h1.new-h1 Contact
|
||||
|
||||
.description
|
||||
Contactez-nous via ce formulaire et nous vous répondrons dans les plus brefs délais.
|
||||
Pensez bien à nous donner le plus d'informations possible pour que nous puissions vous aider au mieux
|
||||
|
||||
= form_tag contact_path, method: :post, multipart: true, class: 'form' do |f|
|
||||
|
||||
.description
|
||||
%p
|
||||
Contactez-nous via ce formulaire et nous vous répondrons dans les plus brefs délais.
|
||||
Pensez bien à nous donner le plus d'informations possible pour que nous puissions vous aider au mieux.
|
||||
%br
|
||||
%p.mandatory-explanation
|
||||
Les champs suivis d’un astérisque (
|
||||
%span.mandatory *
|
||||
) sont obligatoires.
|
||||
|
||||
- if !user_signed_in?
|
||||
.contact-champ
|
||||
= label_tag :email do
|
||||
|
@ -28,7 +35,10 @@
|
|||
.card-title
|
||||
👉 Notre réponse
|
||||
.card-content
|
||||
%p Avez-vous bien vérifié que tous les champs obligatoires (*) sont bien remplis ?
|
||||
%p
|
||||
Avez-vous bien vérifié que tous les champs obligatoires (
|
||||
%span.mandatory *
|
||||
) sont bien remplis ?
|
||||
%p Si vous avez des questions sur les informations à saisir, contactez les services en charge de la démarche.
|
||||
%p
|
||||
%a{ href: 'https://faq.demarches-simplifiees.fr/article/12-contacter-le-service-en-charge-de-ma-demarche' }
|
||||
|
@ -90,7 +100,7 @@
|
|||
= text_area_tag :text, params[:text], rows: 6, required: true
|
||||
|
||||
.contact-champ
|
||||
= label_tag :text do
|
||||
= label_tag :piece_jointe do
|
||||
Pièce jointe
|
||||
%p.notice.hidden{ data: { 'contact-type-only': Helpscout::FormAdapter::TYPE_AMELIORATION } }
|
||||
Une capture d’écran peut nous aider à identifier plus facilement l’endroit à améliorer.
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
- if dossier.can_be_updated_by_user? && !current_page?(modifier_dossier_path(dossier))
|
||||
= link_to "Modifier mon dossier", modifier_dossier_path(dossier), class: 'button accepted edit-form', 'title'=> "Vous pouvez modifier votre dossier tant qu'il n'est passé en instruction"
|
||||
%span.dropdown.print-menu-opener
|
||||
%button.button.dropdown-button.icon-only{ title: 'imprimer' }
|
||||
%button.button.dropdown-button.icon-only{ title: 'imprimer', 'aria-label': 'imprimer' }
|
||||
%span.icon.printer
|
||||
%ul.print-menu.dropdown-content
|
||||
%li
|
||||
|
|
5
db/migrate/20200611122406_remove_dossier_procedure_id.rb
Normal file
5
db/migrate/20200611122406_remove_dossier_procedure_id.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class RemoveDossierProcedureId < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
remove_column :dossiers, :procedure_id
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2020_04_29_191305) do
|
||||
ActiveRecord::Schema.define(version: 2020_06_11_122406) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -238,7 +238,6 @@ ActiveRecord::Schema.define(version: 2020_04_29_191305) do
|
|||
|
||||
create_table "dossiers", id: :serial, force: :cascade do |t|
|
||||
t.boolean "autorisation_donnees"
|
||||
t.integer "procedure_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "state"
|
||||
|
@ -262,7 +261,6 @@ ActiveRecord::Schema.define(version: 2020_04_29_191305) do
|
|||
t.index ["archived"], name: "index_dossiers_on_archived"
|
||||
t.index ["groupe_instructeur_id"], name: "index_dossiers_on_groupe_instructeur_id"
|
||||
t.index ["hidden_at"], name: "index_dossiers_on_hidden_at"
|
||||
t.index ["procedure_id"], name: "index_dossiers_on_procedure_id"
|
||||
t.index ["state"], name: "index_dossiers_on_state"
|
||||
t.index ["user_id"], name: "index_dossiers_on_user_id"
|
||||
end
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
describe ProcedurePresentation do
|
||||
let(:procedure) { create(:procedure, :with_type_de_champ, :with_type_de_champ_private) }
|
||||
let(:assign_to) { create(:assign_to, procedure: procedure) }
|
||||
let(:first_type_de_champ_id) { assign_to.procedure.types_de_champ.first.id.to_s }
|
||||
let (:procedure_presentation_id) {
|
||||
let(:first_type_de_champ) { assign_to.procedure.types_de_champ.first }
|
||||
let(:first_type_de_champ_id) { first_type_de_champ.id.to_s }
|
||||
let(:procedure_presentation) {
|
||||
ProcedurePresentation.create(
|
||||
assign_to: assign_to,
|
||||
displayed_fields: [
|
||||
|
@ -10,10 +11,11 @@ describe ProcedurePresentation do
|
|||
{ "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }
|
||||
],
|
||||
sort: { "table" => "user", "column" => "email", "order" => "asc" },
|
||||
filters: { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] }
|
||||
).id
|
||||
filters: filters
|
||||
)
|
||||
}
|
||||
let (:procedure_presentation) { ProcedurePresentation.find(procedure_presentation_id) }
|
||||
let(:procedure_presentation_id) { procedure_presentation.id }
|
||||
let(:filters) { { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } }
|
||||
|
||||
describe "#displayed_fields" do
|
||||
it { expect(procedure_presentation.displayed_fields).to eq([{ "label" => "test1", "table" => "user", "column" => "email" }, { "label" => "test2", "table" => "type_de_champ", "column" => first_type_de_champ_id }]) }
|
||||
|
@ -499,12 +501,14 @@ describe ProcedurePresentation do
|
|||
let(:discarded_dossier) { create(:dossier, procedure: procedure) }
|
||||
let(:type_de_champ) { procedure.types_de_champ.first }
|
||||
|
||||
before do
|
||||
kept_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'keep me')
|
||||
discarded_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'discard me')
|
||||
end
|
||||
context 'with single value' do
|
||||
before do
|
||||
kept_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'keep me')
|
||||
discarded_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'discard me')
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
end
|
||||
|
||||
context 'with multiple search values' do
|
||||
let(:filter) do
|
||||
|
@ -517,6 +521,8 @@ describe ProcedurePresentation do
|
|||
let(:other_kept_dossier) { create(:dossier, procedure: procedure) }
|
||||
|
||||
before do
|
||||
kept_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'keep me')
|
||||
discarded_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'discard me')
|
||||
other_kept_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'and me too')
|
||||
end
|
||||
|
||||
|
@ -524,6 +530,18 @@ describe ProcedurePresentation do
|
|||
is_expected.to contain_exactly(kept_dossier.id, other_kept_dossier.id)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with yes_no type_de_champ' do
|
||||
let(:filter) { [{ 'table' => 'type_de_champ', 'column' => type_de_champ.id.to_s, 'value' => 'true' }] }
|
||||
let(:procedure) { create(:procedure, :with_yes_no) }
|
||||
|
||||
before do
|
||||
kept_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'true')
|
||||
discarded_dossier.champs.find_by(type_de_champ: type_de_champ).update(value: 'false')
|
||||
end
|
||||
|
||||
it { is_expected.to contain_exactly(kept_dossier.id) }
|
||||
end
|
||||
end
|
||||
|
||||
context 'for type_de_champ_private table' do
|
||||
|
@ -864,4 +882,54 @@ describe ProcedurePresentation do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#human_value_for_filter" do
|
||||
let(:filters) { { "suivis" => [{ "label" => "label1", "table" => "type_de_champ", "column" => first_type_de_champ_id, "value" => "true" }] } }
|
||||
|
||||
subject { procedure_presentation.human_value_for_filter(procedure_presentation.filters["suivis"].first) }
|
||||
|
||||
context 'when type_de_champ text' do
|
||||
it 'should passthrough value' do
|
||||
expect(subject).to eq("true")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when type_de_champ yes_no' do
|
||||
let(:procedure) { create(:procedure, :with_yes_no) }
|
||||
|
||||
it 'should transform value' do
|
||||
expect(subject).to eq("oui")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#add_filter" do
|
||||
let(:filters) { { "suivis" => [] } }
|
||||
|
||||
context 'when type_de_champ yes_no' do
|
||||
let(:procedure) { create(:procedure, :with_yes_no) }
|
||||
|
||||
it 'should downcase and transform value' do
|
||||
procedure_presentation.add_filter("suivis", "type_de_champ/#{first_type_de_champ_id}", "Oui")
|
||||
|
||||
expect(procedure_presentation.filters).to eq({ "suivis" => [
|
||||
{ "label" => first_type_de_champ.libelle, "table" => "type_de_champ", "column" => first_type_de_champ_id, "value" => "true" }
|
||||
]
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
context 'when type_de_champ text' do
|
||||
let(:filters) { { "suivis" => [] } }
|
||||
|
||||
it 'should passthrough value' do
|
||||
procedure_presentation.add_filter("suivis", "type_de_champ/#{first_type_de_champ_id}", "Oui")
|
||||
|
||||
expect(procedure_presentation.filters).to eq({ "suivis" => [
|
||||
{ "label" => first_type_de_champ.libelle, "table" => "type_de_champ", "column" => first_type_de_champ_id, "value" => "Oui" }
|
||||
]
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue