aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcedricnjanga2018-05-29 12:15:50 -0700
committerJohan Van Ryseghem2018-05-31 13:51:23 +0200
commitace3af7f5f3c413582b412e1f54356971107daa6 (patch)
tree29c3d98a06dd0f651cef5c1ec85afd7a268232be
parent3642e0741c96cf4855dc7731a22ac0b9fabea5f4 (diff)
downloadchouette-core-ace3af7f5f3c413582b412e1f54356971107daa6.tar.bz2
Refs #7029 Add translation to compliance control target attribute
-rw-r--r--app/helpers/compliance_controls_helper.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/app/helpers/compliance_controls_helper.rb b/app/helpers/compliance_controls_helper.rb
index abf909929..78d0ba0c2 100644
--- a/app/helpers/compliance_controls_helper.rb
+++ b/app/helpers/compliance_controls_helper.rb
@@ -9,13 +9,24 @@ module ComplianceControlsHelper
[t("compliance_controls.filters.subclasses.#{key}"), "-#{pattern}-"]
end
+ def display_control_attribute(key, value)
+ if key == "target"
+ parts = value.match(%r((?'object_type'\w+)#(?'attribute'\w+)))
+ object_type = ComplianceControl.tmf("subclasses.#{parts[:object_type]}")
+ target = I18n.t("activerecord.attributes.#{parts[:object_type]}.#{parts[:attribute]}")
+ "#{object_type} - #{target}"
+ else
+ value
+ end
+ end
+
def compliance_control_metadatas(compliance_control)
attributes = resource.class.dynamic_attributes
attributes.push(*resource.control_attributes.keys) if resource&.control_attributes&.keys
{}.tap do |hash|
attributes.each do |attribute|
- hash[ComplianceControl.human_attribute_name(attribute)] = resource.send(attribute)
+ hash[ComplianceControl.human_attribute_name(attribute)] = display_control_attribute(attribute, resource.send(attribute))
end
end
end