diff options
| -rw-r--r-- | app/helpers/compliance_controls_helper.rb | 13 |
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 |
