diff options
| -rw-r--r-- | app/controllers/vehicle_journeys_controller.rb | 2 | ||||
| -rw-r--r-- | app/models/concerns/custom_fields_support.rb | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/app/controllers/vehicle_journeys_controller.rb b/app/controllers/vehicle_journeys_controller.rb index 821ea83ff..220f2d29e 100644 --- a/app/controllers/vehicle_journeys_controller.rb +++ b/app/controllers/vehicle_journeys_controller.rb @@ -154,7 +154,7 @@ class VehicleJourneysController < ChouetteController private def load_custom_fields - @custom_fields = referential.workgroup&.custom_fields_definitions || {} + @custom_fields = Chouette::VehicleJourney.custom_fields_definitions(referential.workgroup) @extra_headers = Rails.application.config.vehicle_journeys_extra_headers.dup.delete_if do |header| header[:type] == :custom_field and not @custom_fields.has_key?(header[:name].to_s) diff --git a/app/models/concerns/custom_fields_support.rb b/app/models/concerns/custom_fields_support.rb index 017f496a8..1d546bdde 100644 --- a/app/models/concerns/custom_fields_support.rb +++ b/app/models/concerns/custom_fields_support.rb @@ -11,6 +11,10 @@ module CustomFieldsSupport fields end + def self.custom_fields_definitions workgroup=:all + Hash[*custom_fields(workgroup).map{|cf| [cf.code, cf]}.flatten] + end + def method_missing method_name, *args if method_name =~ /custom_field_*/ && method_name.to_sym != :custom_field_values && !@custom_fields_initialized initialize_custom_fields |
