rename ProcedureLabel by Label
This commit is contained in:
parent
1a3f73eb01
commit
35dee477ea
20 changed files with 62 additions and 62 deletions
|
@ -108,7 +108,7 @@ module Administrateurs
|
||||||
flash.now.alert = @procedure.errors.full_messages
|
flash.now.alert = @procedure.errors.full_messages
|
||||||
render 'new'
|
render 'new'
|
||||||
else
|
else
|
||||||
@procedure.create_generic_procedure_labels
|
@procedure.create_generic_labels
|
||||||
flash.notice = 'Démarche enregistrée.'
|
flash.notice = 'Démarche enregistrée.'
|
||||||
current_administrateur.instructeur.assign_to_procedure(@procedure)
|
current_administrateur.instructeur.assign_to_procedure(@procedure)
|
||||||
|
|
||||||
|
|
|
@ -64,14 +64,14 @@ module Instructeurs
|
||||||
end
|
end
|
||||||
|
|
||||||
def dossier_labels
|
def dossier_labels
|
||||||
labels = params[:procedure_label_id]&.map(&:to_i) || []
|
labels = params[:label_id]&.map(&:to_i) || []
|
||||||
|
|
||||||
@dossier = dossier
|
@dossier = dossier
|
||||||
labels.each { |params_label| DossierLabel.find_or_create_by(dossier_id: @dossier.id, procedure_label_id: params_label) }
|
labels.each { |params_label| DossierLabel.find_or_create_by(dossier_id: @dossier.id, label_id: params_label) }
|
||||||
|
|
||||||
all_labels = DossierLabel.where(dossier_id: @dossier.id).pluck(:procedure_label_id)
|
all_labels = DossierLabel.where(dossier_id: @dossier.id).pluck(:label_id)
|
||||||
|
|
||||||
(all_labels - labels).each { DossierLabel.find_by(dossier_id: @dossier.id, procedure_label_id: _1).destroy }
|
(all_labels - labels).each { DossierLabel.find_by(dossier_id: @dossier.id, label_id: _1).destroy }
|
||||||
|
|
||||||
render :change_state
|
render :change_state
|
||||||
end
|
end
|
||||||
|
|
|
@ -133,7 +133,7 @@ class Dossier < ApplicationRecord
|
||||||
belongs_to :transfer, class_name: 'DossierTransfer', foreign_key: 'dossier_transfer_id', optional: true, inverse_of: :dossiers
|
belongs_to :transfer, class_name: 'DossierTransfer', foreign_key: 'dossier_transfer_id', optional: true, inverse_of: :dossiers
|
||||||
has_many :transfer_logs, class_name: 'DossierTransferLog', dependent: :destroy
|
has_many :transfer_logs, class_name: 'DossierTransferLog', dependent: :destroy
|
||||||
has_many :dossier_labels, dependent: :destroy
|
has_many :dossier_labels, dependent: :destroy
|
||||||
has_many :procedure_labels, through: :dossier_labels
|
has_many :labels, through: :dossier_labels
|
||||||
|
|
||||||
after_destroy_commit :log_destroy
|
after_destroy_commit :log_destroy
|
||||||
|
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
class DossierLabel < ApplicationRecord
|
class DossierLabel < ApplicationRecord
|
||||||
belongs_to :dossier
|
belongs_to :dossier
|
||||||
belongs_to :procedure_label
|
belongs_to :label
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class ProcedureLabel < ApplicationRecord
|
class Label < ApplicationRecord
|
||||||
belongs_to :procedure
|
belongs_to :procedure
|
||||||
has_many :dossier_labels, dependent: :destroy
|
has_many :dossier_labels, dependent: :destroy
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Procedure < ApplicationRecord
|
||||||
has_and_belongs_to_many :procedure_tags
|
has_and_belongs_to_many :procedure_tags
|
||||||
|
|
||||||
has_many :bulk_messages, dependent: :destroy
|
has_many :bulk_messages, dependent: :destroy
|
||||||
has_many :procedure_labels, dependent: :destroy
|
has_many :labels, dependent: :destroy
|
||||||
|
|
||||||
def active_dossier_submitted_message
|
def active_dossier_submitted_message
|
||||||
published_dossier_submitted_message || draft_dossier_submitted_message
|
published_dossier_submitted_message || draft_dossier_submitted_message
|
||||||
|
@ -529,7 +529,7 @@ class Procedure < ApplicationRecord
|
||||||
procedure.closing_notification_en_cours = false
|
procedure.closing_notification_en_cours = false
|
||||||
procedure.template = false
|
procedure.template = false
|
||||||
procedure.monavis_embed = nil
|
procedure.monavis_embed = nil
|
||||||
procedure.procedure_labels = procedure_labels.map(&:dup)
|
procedure.labels = labels.map(&:dup)
|
||||||
|
|
||||||
if !procedure.valid?
|
if !procedure.valid?
|
||||||
procedure.errors.attribute_names.each do |attribute|
|
procedure.errors.attribute_names.each do |attribute|
|
||||||
|
@ -937,9 +937,9 @@ class Procedure < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_generic_procedure_labels
|
def create_generic_labels
|
||||||
ProcedureLabel::GENERIC_LABELS.each do |label|
|
Label::GENERIC_LABELS.each do |label|
|
||||||
ProcedureLabel.create(name: label[:name], color: label[:color], procedure_id: self.id)
|
Label.create(name: label[:name], color: label[:color], procedure_id: self.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -131,7 +131,7 @@ class DossierFilterService
|
||||||
assert_supported_column(table, column)
|
assert_supported_column(table, column)
|
||||||
dossiers
|
dossiers
|
||||||
.joins(:dossier_labels)
|
.joins(:dossier_labels)
|
||||||
.where(dossier_labels: { procedure_label_id: values })
|
.where(dossier_labels: { label_id: values })
|
||||||
when 'groupe_instructeur'
|
when 'groupe_instructeur'
|
||||||
assert_supported_column(table, column)
|
assert_supported_column(table, column)
|
||||||
|
|
||||||
|
|
|
@ -128,9 +128,9 @@ class DossierProjectionService
|
||||||
|
|
||||||
id_value_h =
|
id_value_h =
|
||||||
DossierLabel
|
DossierLabel
|
||||||
.includes(:procedure_label)
|
.includes(:label)
|
||||||
.where(dossier_id: dossiers_ids)
|
.where(dossier_id: dossiers_ids)
|
||||||
.pluck('dossier_id, procedure_labels.name, procedure_labels.color')
|
.pluck('dossier_id, labels.name, labels.color')
|
||||||
.group_by { |dossier_id, _| dossier_id }
|
.group_by { |dossier_id, _| dossier_id }
|
||||||
|
|
||||||
fields[0][:id_value_h] = id_value_h.transform_values { |v| { value: v, type: :label } }
|
fields[0][:id_value_h] = id_value_h.transform_values { |v| { value: v, type: :label } }
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
module Maintenance
|
module Maintenance
|
||||||
class BackfillProcedureLabelsForProceduresTask < MaintenanceTasks::Task
|
class BackfillLabelsForProceduresTask < MaintenanceTasks::Task
|
||||||
# Cette tâche permet de créer un jeu de labels génériques pour les anciennes procédures
|
# Cette tâche permet de créer un jeu de labels génériques pour les anciennes procédures
|
||||||
# Plus d'informations sur l'implémentation des labels ici : https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/9787
|
# Plus d'informations sur l'implémentation des labels ici : https://github.com/demarches-simplifiees/demarches-simplifiees.fr/issues/9787
|
||||||
# 2024-10-15
|
# 2024-10-15
|
||||||
|
@ -12,13 +12,13 @@ module Maintenance
|
||||||
|
|
||||||
def collection
|
def collection
|
||||||
Procedure
|
Procedure
|
||||||
.includes(:procedure_labels)
|
.includes(:labels)
|
||||||
.where(procedure_labels: { id: nil })
|
.where(labels: { id: nil })
|
||||||
end
|
end
|
||||||
|
|
||||||
def process(procedure)
|
def process(procedure)
|
||||||
ProcedureLabel::GENERIC_LABELS.each do |label|
|
Label::GENERIC_LABELS.each do |label|
|
||||||
ProcedureLabel.create(name: label[:name], color: label[:color], procedure_id: procedure.id)
|
Label.create(name: label[:name], color: label[:color], procedure_id: procedure.id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -26,22 +26,22 @@
|
||||||
%p.fr-mb-1w
|
%p.fr-mb-1w
|
||||||
%small L’usager a supprimé son compte. Vous pouvez archiver puis supprimer le dossier.
|
%small L’usager a supprimé son compte. Vous pouvez archiver puis supprimer le dossier.
|
||||||
|
|
||||||
- if dossier.procedure.procedure_labels.present?
|
- if dossier.procedure.labels.present?
|
||||||
.fr-mb-3w
|
.fr-mb-3w
|
||||||
- if dossier.procedure_labels.present?
|
- if dossier.labels.present?
|
||||||
- dossier.procedure_labels.each do |label|
|
- dossier.labels.each do |label|
|
||||||
= tag_label(label.name, label.color)
|
= tag_label(label.name, label.color)
|
||||||
|
|
||||||
= render Dropdown::MenuComponent.new(wrapper: :span, button_options: { class: ['fr-btn--sm fr-btn--tertiary-no-outline fr-pl-1v']}, menu_options: { class: ['dropdown-label left-aligned'] }) do |menu|
|
= render Dropdown::MenuComponent.new(wrapper: :span, button_options: { class: ['fr-btn--sm fr-btn--tertiary-no-outline fr-pl-1v']}, menu_options: { class: ['dropdown-label left-aligned'] }) do |menu|
|
||||||
- if dossier.procedure_labels.empty?
|
- if dossier.labels.empty?
|
||||||
- menu.with_button_inner_html do
|
- menu.with_button_inner_html do
|
||||||
Ajouter un label
|
Ajouter un label
|
||||||
|
|
||||||
- menu.with_form do
|
- menu.with_form do
|
||||||
= form_with(url: dossier_labels_instructeur_dossier_path(dossier_id: dossier.id, procedure_id: dossier.procedure.id), method: :post, class: 'fr-p-3w', data: { controller: 'autosubmit', turbo: 'true' }) do |f|
|
= form_with(url: dossier_labels_instructeur_dossier_path(dossier_id: dossier.id, procedure_id: dossier.procedure.id), method: :post, class: 'fr-p-3w', data: { controller: 'autosubmit', turbo: 'true' }) do |f|
|
||||||
%fieldset.fr-fieldset.fr-mt-2w.fr-mb-0
|
%fieldset.fr-fieldset.fr-mt-2w.fr-mb-0
|
||||||
= f.collection_check_boxes :procedure_label_id, dossier.procedure.procedure_labels, :id, :name, include_hidden: false do |b|
|
= f.collection_check_boxes :label_id, dossier.procedure.labels, :id, :name, include_hidden: false do |b|
|
||||||
.fr-fieldset__element
|
.fr-fieldset__element
|
||||||
.fr-checkbox-group.fr-checkbox-group--sm.fr-mb-1w
|
.fr-checkbox-group.fr-checkbox-group--sm.fr-mb-1w
|
||||||
= b.check_box(checked: DossierLabel.find_by(dossier_id: dossier.id, procedure_label_id: b.value).present? )
|
= b.check_box(checked: DossierLabel.find_by(dossier_id: dossier.id, label_id: b.value).present? )
|
||||||
= b.label(class: "fr-label fr-tag fr-tag--sm fr-tag--#{b.object.color}") { b.text }
|
= b.label(class: "fr-label fr-tag fr-tag--sm fr-tag--#{b.object.color}") { b.text }
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class CreateProcedureLabels < ActiveRecord::Migration[7.0]
|
class CreateLabels < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
create_table :procedure_labels do |t|
|
create_table :labels do |t|
|
||||||
t.string :name
|
t.string :name
|
||||||
t.string :color
|
t.string :color
|
||||||
t.references :procedure, null: false, foreign_key: true
|
t.references :procedure, null: false, foreign_key: true
|
|
@ -4,7 +4,7 @@ class CreateDossierLabels < ActiveRecord::Migration[7.0]
|
||||||
def change
|
def change
|
||||||
create_table :dossier_labels do |t|
|
create_table :dossier_labels do |t|
|
||||||
t.references :dossier, null: false, foreign_key: true
|
t.references :dossier, null: false, foreign_key: true
|
||||||
t.references :procedure_label, null: false, foreign_key: true
|
t.references :label, null: false, foreign_key: true
|
||||||
|
|
||||||
t.timestamps
|
t.timestamps
|
||||||
end
|
end
|
||||||
|
|
26
db/schema.rb
26
db/schema.rb
|
@ -419,10 +419,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
|
||||||
create_table "dossier_labels", force: :cascade do |t|
|
create_table "dossier_labels", force: :cascade do |t|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "dossier_id", null: false
|
t.bigint "dossier_id", null: false
|
||||||
t.bigint "procedure_label_id", null: false
|
t.bigint "label_id", null: false
|
||||||
t.datetime "updated_at", null: false
|
t.datetime "updated_at", null: false
|
||||||
t.index ["dossier_id"], name: "index_dossier_labels_on_dossier_id"
|
t.index ["dossier_id"], name: "index_dossier_labels_on_dossier_id"
|
||||||
t.index ["procedure_label_id"], name: "index_dossier_labels_on_procedure_label_id"
|
t.index ["label_id"], name: "index_dossier_labels_on_label_id"
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "dossier_operation_logs", force: :cascade do |t|
|
create_table "dossier_operation_logs", force: :cascade do |t|
|
||||||
|
@ -829,6 +829,15 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
|
||||||
t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true
|
t.index ["email", "dossier_id"], name: "index_invites_on_email_and_dossier_id", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "labels", force: :cascade do |t|
|
||||||
|
t.string "color"
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.string "name"
|
||||||
|
t.bigint "procedure_id", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["procedure_id"], name: "index_labels_on_procedure_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "maintenance_tasks_runs", force: :cascade do |t|
|
create_table "maintenance_tasks_runs", force: :cascade do |t|
|
||||||
t.text "arguments"
|
t.text "arguments"
|
||||||
t.text "backtrace"
|
t.text "backtrace"
|
||||||
|
@ -878,15 +887,6 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
|
||||||
t.index ["from"], name: "index_path_rewrites_on_from", unique: true
|
t.index ["from"], name: "index_path_rewrites_on_from", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "procedure_labels", force: :cascade do |t|
|
|
||||||
t.string "color"
|
|
||||||
t.datetime "created_at", null: false
|
|
||||||
t.string "name"
|
|
||||||
t.bigint "procedure_id", null: false
|
|
||||||
t.datetime "updated_at", null: false
|
|
||||||
t.index ["procedure_id"], name: "index_procedure_labels_on_procedure_id"
|
|
||||||
end
|
|
||||||
|
|
||||||
create_table "procedure_presentations", id: :serial, force: :cascade do |t|
|
create_table "procedure_presentations", id: :serial, force: :cascade do |t|
|
||||||
t.jsonb "a_suivre_filters", default: [], null: false, array: true
|
t.jsonb "a_suivre_filters", default: [], null: false, array: true
|
||||||
t.jsonb "archives_filters", default: [], null: false, array: true
|
t.jsonb "archives_filters", default: [], null: false, array: true
|
||||||
|
@ -1299,7 +1299,7 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
|
||||||
add_foreign_key "dossier_corrections", "commentaires"
|
add_foreign_key "dossier_corrections", "commentaires"
|
||||||
add_foreign_key "dossier_corrections", "dossiers"
|
add_foreign_key "dossier_corrections", "dossiers"
|
||||||
add_foreign_key "dossier_labels", "dossiers"
|
add_foreign_key "dossier_labels", "dossiers"
|
||||||
add_foreign_key "dossier_labels", "procedure_labels"
|
add_foreign_key "dossier_labels", "labels"
|
||||||
add_foreign_key "dossier_operation_logs", "bill_signatures"
|
add_foreign_key "dossier_operation_logs", "bill_signatures"
|
||||||
add_foreign_key "dossier_transfer_logs", "dossiers"
|
add_foreign_key "dossier_transfer_logs", "dossiers"
|
||||||
add_foreign_key "dossiers", "batch_operations"
|
add_foreign_key "dossiers", "batch_operations"
|
||||||
|
@ -1320,8 +1320,8 @@ ActiveRecord::Schema[7.0].define(version: 2024_10_14_084333) do
|
||||||
add_foreign_key "groupe_instructeurs", "procedures"
|
add_foreign_key "groupe_instructeurs", "procedures"
|
||||||
add_foreign_key "initiated_mails", "procedures"
|
add_foreign_key "initiated_mails", "procedures"
|
||||||
add_foreign_key "instructeurs", "users"
|
add_foreign_key "instructeurs", "users"
|
||||||
|
add_foreign_key "labels", "procedures"
|
||||||
add_foreign_key "merge_logs", "users"
|
add_foreign_key "merge_logs", "users"
|
||||||
add_foreign_key "procedure_labels", "procedures"
|
|
||||||
add_foreign_key "procedure_presentations", "assign_tos"
|
add_foreign_key "procedure_presentations", "assign_tos"
|
||||||
add_foreign_key "procedure_revision_types_de_champ", "procedure_revision_types_de_champ", column: "parent_id"
|
add_foreign_key "procedure_revision_types_de_champ", "procedure_revision_types_de_champ", column: "parent_id"
|
||||||
add_foreign_key "procedure_revision_types_de_champ", "procedure_revisions", column: "revision_id"
|
add_foreign_key "procedure_revision_types_de_champ", "procedure_revisions", column: "revision_id"
|
||||||
|
|
|
@ -515,8 +515,8 @@ describe Administrateurs::ProceduresController, type: :controller do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "create generic labels" do
|
it "create generic labels" do
|
||||||
expect(subject.procedure_labels.size).to eq(3)
|
expect(subject.labels.size).to eq(3)
|
||||||
expect(subject.procedure_labels.first.name).to eq('à relancer')
|
expect(subject.labels.first.name).to eq('à relancer')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -684,9 +684,9 @@ describe Administrateurs::ProceduresController, type: :controller do
|
||||||
expect(Procedure.last.cloned_from_library).to be_falsey
|
expect(Procedure.last.cloned_from_library).to be_falsey
|
||||||
expect(Procedure.last.notice.attached?).to be_truthy
|
expect(Procedure.last.notice.attached?).to be_truthy
|
||||||
expect(Procedure.last.deliberation.attached?).to be_truthy
|
expect(Procedure.last.deliberation.attached?).to be_truthy
|
||||||
expect(Procedure.last.procedure_labels.present?).to be_truthy
|
expect(Procedure.last.labels.present?).to be_truthy
|
||||||
expect(Procedure.last.procedure_labels.first.procedure_id).to eq(Procedure.last.id)
|
expect(Procedure.last.labels.first.procedure_id).to eq(Procedure.last.id)
|
||||||
expect(procedure.procedure_labels.first.procedure_id).to eq(procedure.id)
|
expect(procedure.labels.first.procedure_id).to eq(procedure.id)
|
||||||
|
|
||||||
expect(flash[:notice]).to have_content 'Démarche clonée. Pensez à vérifier la présentation et choisir le service à laquelle cette démarche est associée.'
|
expect(flash[:notice]).to have_content 'Démarche clonée. Pensez à vérifier la présentation et choisir le service à laquelle cette démarche est associée.'
|
||||||
end
|
end
|
||||||
|
@ -709,7 +709,7 @@ describe Administrateurs::ProceduresController, type: :controller do
|
||||||
|
|
||||||
it 'creates a new procedure and redirect to it' do
|
it 'creates a new procedure and redirect to it' do
|
||||||
expect(response).to redirect_to admin_procedure_path(id: Procedure.last.id)
|
expect(response).to redirect_to admin_procedure_path(id: Procedure.last.id)
|
||||||
expect(Procedure.last.procedure_labels.present?).to be_truthy
|
expect(Procedure.last.labels.present?).to be_truthy
|
||||||
expect(flash[:notice]).to have_content 'Démarche clonée. Pensez à vérifier la présentation et choisir le service à laquelle cette démarche est associée.'
|
expect(flash[:notice]).to have_content 'Démarche clonée. Pensez à vérifier la présentation et choisir le service à laquelle cette démarche est associée.'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1523,7 +1523,7 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
let(:procedure) { create(:procedure, :with_labels, instructeurs: [instructeur]) }
|
let(:procedure) { create(:procedure, :with_labels, instructeurs: [instructeur]) }
|
||||||
let!(:dossier) { create(:dossier, :en_construction, procedure:) }
|
let!(:dossier) { create(:dossier, :en_construction, procedure:) }
|
||||||
context 'it create dossier labels' do
|
context 'it create dossier labels' do
|
||||||
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, procedure_label_id: [ProcedureLabel.first.id] }, format: :turbo_stream }
|
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [Label.first.id] }, format: :turbo_stream }
|
||||||
it 'works' do
|
it 'works' do
|
||||||
subject
|
subject
|
||||||
dossier.reload
|
dossier.reload
|
||||||
|
@ -1536,10 +1536,10 @@ describe Instructeurs::DossiersController, type: :controller do
|
||||||
|
|
||||||
context 'it remove dossier labels' do
|
context 'it remove dossier labels' do
|
||||||
before do
|
before do
|
||||||
DossierLabel.create(dossier_id: dossier.id, procedure_label_id: dossier.procedure.procedure_labels.first.id)
|
DossierLabel.create(dossier_id: dossier.id, label_id: dossier.procedure.labels.first.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, procedure_label_id: [] }, format: :turbo_stream }
|
subject { post :dossier_labels, params: { procedure_id: procedure.id, dossier_id: dossier.id, label_id: [] }, format: :turbo_stream }
|
||||||
|
|
||||||
it 'works' do
|
it 'works' do
|
||||||
expect(dossier.dossier_labels.count).to eq(1)
|
expect(dossier.dossier_labels.count).to eq(1)
|
||||||
|
|
|
@ -643,19 +643,19 @@ describe Instructeurs::ProceduresController, type: :controller do
|
||||||
let!(:dossier) { create(:dossier, :en_construction, procedure:, groupe_instructeur: gi_2) }
|
let!(:dossier) { create(:dossier, :en_construction, procedure:, groupe_instructeur: gi_2) }
|
||||||
let!(:dossier_2) { create(:dossier, :en_construction, procedure:, groupe_instructeur: gi_2) }
|
let!(:dossier_2) { create(:dossier, :en_construction, procedure:, groupe_instructeur: gi_2) }
|
||||||
let(:statut) { 'tous' }
|
let(:statut) { 'tous' }
|
||||||
let(:procedure_label_id) { procedure.find_column(label: 'Labels') }
|
let(:label_id) { procedure.find_column(label: 'Labels') }
|
||||||
let!(:procedure_presentation) do
|
let!(:procedure_presentation) do
|
||||||
ProcedurePresentation.create!(assign_to: AssignTo.first)
|
ProcedurePresentation.create!(assign_to: AssignTo.first)
|
||||||
end
|
end
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
DossierLabel.create(dossier_id: dossier.id, procedure_label_id: dossier.procedure.procedure_labels.first.id)
|
DossierLabel.create(dossier_id: dossier.id, label_id: dossier.procedure.labels.first.id)
|
||||||
DossierLabel.create(dossier_id: dossier.id, procedure_label_id: dossier.procedure.procedure_labels.second.id)
|
DossierLabel.create(dossier_id: dossier.id, label_id: dossier.procedure.labels.second.id)
|
||||||
DossierLabel.create(dossier_id: dossier_2.id, procedure_label_id: dossier.procedure.procedure_labels.last.id)
|
DossierLabel.create(dossier_id: dossier_2.id, label_id: dossier.procedure.labels.last.id)
|
||||||
|
|
||||||
procedure_presentation.update(displayed_columns: [
|
procedure_presentation.update(displayed_columns: [
|
||||||
procedure_label_id.id
|
label_id.id
|
||||||
])
|
])
|
||||||
|
|
||||||
subject
|
subject
|
||||||
|
|
|
@ -294,7 +294,7 @@ FactoryBot.define do
|
||||||
|
|
||||||
trait :with_labels do
|
trait :with_labels do
|
||||||
after(:create) do |procedure, _evaluator|
|
after(:create) do |procedure, _evaluator|
|
||||||
procedure.create_generic_procedure_labels
|
procedure.create_generic_labels
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -51,7 +51,7 @@ describe ColumnsConcern do
|
||||||
{ label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true },
|
{ label: 'Groupe instructeur', table: 'groupe_instructeur', column: 'id', displayable: true, type: :enum, scope: '', value_column: :value, filterable: true },
|
||||||
{ label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
|
{ label: 'Avis oui/non', table: 'avis', column: 'question_answer', displayable: true, type: :text, scope: '', value_column: :value, filterable: false },
|
||||||
{ label: 'France connecté ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false },
|
{ label: 'France connecté ?', table: 'self', column: 'user_from_france_connect?', displayable: false, type: :text, scope: '', value_column: :value, filterable: false },
|
||||||
{ label: "Labels", table: "dossier_labels", column: "procedure_label_id", displayable: true, scope: '', value_column: :value, filterable: true },
|
{ label: "Labels", table: "dossier_labels", column: "label_id", displayable: true, scope: '', value_column: :value, filterable: true },
|
||||||
{ label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
{ label: 'SIREN', table: 'etablissement', column: 'entreprise_siren', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||||
{ label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
{ label: 'Forme juridique', table: 'etablissement', column: 'entreprise_forme_juridique', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||||
{ label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
{ label: 'Nom commercial', table: 'etablissement', column: 'entreprise_nom_commercial', displayable: true, type: :text, scope: '', value_column: :value, filterable: true },
|
||||||
|
|
|
@ -174,8 +174,8 @@ describe "procedure filters" do
|
||||||
|
|
||||||
describe 'dossier labels' do
|
describe 'dossier labels' do
|
||||||
scenario "should be able to filter by dossier labels", js: true do
|
scenario "should be able to filter by dossier labels", js: true do
|
||||||
DossierLabel.create!(dossier_id: new_unfollow_dossier.id, procedure_label_id: procedure.procedure_labels.first.id)
|
DossierLabel.create!(dossier_id: new_unfollow_dossier.id, label_id: procedure.labels.first.id)
|
||||||
add_filter('Labels', procedure.procedure_labels.first.name, type: :enum)
|
add_filter('Labels', procedure.labels.first.name, type: :enum)
|
||||||
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
expect(page).to have_link(new_unfollow_dossier.id.to_s)
|
||||||
expect(page).not_to have_link(new_unfollow_dossier_2.id.to_s)
|
expect(page).not_to have_link(new_unfollow_dossier_2.id.to_s)
|
||||||
end
|
end
|
||||||
|
|
|
@ -244,7 +244,7 @@ describe 'instructeurs/dossiers/show', type: :view do
|
||||||
|
|
||||||
context "Dossier with labels" do
|
context "Dossier with labels" do
|
||||||
before do
|
before do
|
||||||
DossierLabel.create(dossier_id: dossier.id, procedure_label_id: dossier.procedure.procedure_labels.first.id)
|
DossierLabel.create(dossier_id: dossier.id, label_id: dossier.procedure.labels.first.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'displays labels and button without text to add label' do
|
it 'displays labels and button without text to add label' do
|
||||||
|
|
Loading…
Reference in a new issue