refactor(export): add procedure attr to export service
This commit is contained in:
parent
561b83781e
commit
87e5e6faeb
1 changed files with 4 additions and 4 deletions
|
@ -1,5 +1,5 @@
|
||||||
class ProcedureExportService
|
class ProcedureExportService
|
||||||
attr_reader :dossiers
|
attr_reader :procedure, :dossiers
|
||||||
|
|
||||||
def initialize(procedure, dossiers)
|
def initialize(procedure, dossiers)
|
||||||
@procedure = procedure
|
@procedure = procedure
|
||||||
|
@ -40,12 +40,12 @@ class ProcedureExportService
|
||||||
end
|
end
|
||||||
|
|
||||||
def champs_repetables_options
|
def champs_repetables_options
|
||||||
revision = @procedure.active_revision
|
revision = procedure.active_revision
|
||||||
champs_by_stable_id = dossiers
|
champs_by_stable_id = dossiers
|
||||||
.flat_map { |dossier| (dossier.champs + dossier.champs_private).filter(&:repetition?) }
|
.flat_map { |dossier| (dossier.champs + dossier.champs_private).filter(&:repetition?) }
|
||||||
.group_by(&:stable_id)
|
.group_by(&:stable_id)
|
||||||
|
|
||||||
@procedure.types_de_champ_for_procedure_presentation.repetition
|
procedure.types_de_champ_for_procedure_presentation.repetition
|
||||||
.map { |type_de_champ_repetition| [type_de_champ_repetition, type_de_champ_repetition.types_de_champ_for_revision(revision).to_a] }
|
.map { |type_de_champ_repetition| [type_de_champ_repetition, type_de_champ_repetition.types_de_champ_for_revision(revision).to_a] }
|
||||||
.filter { |(_, types_de_champ)| types_de_champ.present? }
|
.filter { |(_, types_de_champ)| types_de_champ.present? }
|
||||||
.map do |(type_de_champ_repetition, types_de_champ)|
|
.map do |(type_de_champ_repetition, types_de_champ)|
|
||||||
|
@ -85,7 +85,7 @@ class ProcedureExportService
|
||||||
end
|
end
|
||||||
|
|
||||||
def spreadsheet_columns(format)
|
def spreadsheet_columns(format)
|
||||||
types_de_champ = @procedure.types_de_champ_for_procedure_presentation.not_repetition.to_a
|
types_de_champ = procedure.types_de_champ_for_procedure_presentation.not_repetition.to_a
|
||||||
|
|
||||||
Proc.new do |instance|
|
Proc.new do |instance|
|
||||||
instance.send(:"spreadsheet_columns_#{format}", types_de_champ: types_de_champ)
|
instance.send(:"spreadsheet_columns_#{format}", types_de_champ: types_de_champ)
|
||||||
|
|
Loading…
Reference in a new issue