Sha256: 284974b3919175098eab52b7d20f9ca92ff259a681c907da2263b5e177ff2ee0

Contents?: true

Size: 947 Bytes

Versions: 2

Compression:

Stored size: 947 Bytes

Contents

module WithHelpIcon
  def label(wrapper_options = nil)
    "#{super} #{link_to_help}"
  end

  protected

    def link_to_help
      template.link_to '#', id: "#{input_class}_help",
                            data: { toggle: 'popover'.freeze,
                                    content: metadata_help,
                                    'original-title': raw_label_text },
                            'aria-label': aria_label do
        help_icon
      end
    end

    def help_icon
      template.content_tag 'i', nil, "aria-hidden": true, class: "help-icon"
    end

    def metadata_help
      translate_from_namespace(:metadata_help) || attribute_name.to_s.humanize
    end

    def aria_label
      translate_from_namespace(:aria_label) || default_aria_label
    end

    def default_aria_label
      I18n.t("#{i18n_scope}.aria_label.#{lookup_model_names.join('.')}.default",
             title: attribute_name.to_s.humanize)
    end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
curation_concerns-0.5.0 app/inputs/with_help_icon.rb
curation_concerns-0.4.0 app/inputs/with_help_icon.rb