Merge pull request #10767 from demarches-simplifiees/fix_init_column_with_virtual_keyword
Tech: corrige l'utilisation de la donnée `virtual` des procedures presentations lors de l'initialisation de column
This commit is contained in:
commit
3e1bcb35d6
4 changed files with 11 additions and 4 deletions
|
@ -12,7 +12,7 @@ class Instructeurs::ColumnPickerComponent < ApplicationComponent
|
||||||
def displayable_columns_for_select
|
def displayable_columns_for_select
|
||||||
[
|
[
|
||||||
procedure.columns.filter(&:displayable).map { |column| [column.label, column.id] },
|
procedure.columns.filter(&:displayable).map { |column| [column.label, column.id] },
|
||||||
procedure_presentation.displayed_fields.map { Column.new(**_1.deep_symbolize_keys).id }
|
procedure_presentation.displayed_fields.map { Column.new(**_1.deep_symbolize_keys.except(:virtual)).id } # TODO: remove virtual after migration
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ProcedurePresentation < ApplicationRecord
|
||||||
def displayed_fields_for_headers
|
def displayed_fields_for_headers
|
||||||
[
|
[
|
||||||
Column.new(table: 'self', column: 'id', classname: 'number-col'),
|
Column.new(table: 'self', column: 'id', classname: 'number-col'),
|
||||||
*displayed_fields.map { Column.new(**_1.deep_symbolize_keys) },
|
*displayed_fields.map { Column.new(**_1.deep_symbolize_keys.except(:virtual)) }, # TODO: remove virtual after migration
|
||||||
Column.new(table: 'self', column: 'state', classname: 'state-col'),
|
Column.new(table: 'self', column: 'state', classname: 'state-col'),
|
||||||
*procedure.sva_svr_columns
|
*procedure.sva_svr_columns
|
||||||
]
|
]
|
||||||
|
|
|
@ -15,6 +15,9 @@ describe Instructeurs::ColumnPickerComponent, type: :component do
|
||||||
subject { component.displayable_columns_for_select }
|
subject { component.displayable_columns_for_select }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
procedure_presentation.displayed_fields.first['virtual'] = true
|
||||||
|
procedure_presentation.save
|
||||||
|
|
||||||
allow(procedure).to receive(:columns).and_return([
|
allow(procedure).to receive(:columns).and_return([
|
||||||
default_user_email,
|
default_user_email,
|
||||||
excluded_displayable_field
|
excluded_displayable_field
|
||||||
|
|
|
@ -14,7 +14,7 @@ describe ProcedurePresentation do
|
||||||
assign_to: assign_to,
|
assign_to: assign_to,
|
||||||
displayed_fields: [
|
displayed_fields: [
|
||||||
{ label: "test1", table: "user", column: "email" },
|
{ label: "test1", table: "user", column: "email" },
|
||||||
{ label: "test2", table: "type_de_champ", column: first_type_de_champ_id }
|
{ label: "test2", table: "type_de_champ", column: first_type_de_champ_id, virtual: false }
|
||||||
],
|
],
|
||||||
sort: { table: "user", column: "email", "order" => "asc" },
|
sort: { table: "user", column: "email", "order" => "asc" },
|
||||||
filters: filters)
|
filters: filters)
|
||||||
|
@ -23,7 +23,11 @@ describe ProcedurePresentation do
|
||||||
let(:filters) { { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } }
|
let(:filters) { { "a-suivre" => [], "suivis" => [{ "label" => "label1", "table" => "self", "column" => "created_at" }] } }
|
||||||
|
|
||||||
describe "#displayed_fields" do
|
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 }]) }
|
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, "virtual" => false }]) }
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#displayed_fields_for_headers" do
|
||||||
|
it { expect(procedure_presentation.displayed_fields_for_headers.map(&:label)).to eq(["Nº dossier", "test1", "test2", "Statut"]) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#sort" do
|
describe "#sort" do
|
||||||
|
|
Loading…
Reference in a new issue