aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZog2018-04-10 11:34:46 +0200
committerZog2018-04-10 11:34:46 +0200
commitfd6939e9871bfbc6d1066c0b7370acaf42b28efc (patch)
tree3b4991a9409424bd8b95cd1f0cd2ef98c3622b9d
parent1e641dab55ccb40c9aade97eb6c139116dd9fdfa (diff)
downloadchouette-core-fd6939e9871bfbc6d1066c0b7370acaf42b28efc.tar.bz2
Refs #6483; Only use VJ-bound Custom fields6483-fix-vjs-editor
-rw-r--r--app/controllers/vehicle_journeys_controller.rb2
-rw-r--r--app/models/concerns/custom_fields_support.rb4
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