Sha256: 15cb435481e4572f54b77d1aa206b7996717984d285a4e388c7f94b86214380b

Contents?: true

Size: 882 Bytes

Versions: 6

Compression:

Stored size: 882 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", rel: 'popover'.freeze,
                            'data-content' => metadata_help, 'data-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

6 entries across 6 versions & 1 rubygems

Version Path
sufia-6.7.0 app/inputs/with_help_icon.rb
sufia-6.6.1 app/inputs/with_help_icon.rb
sufia-6.6.0 app/inputs/with_help_icon.rb
sufia-6.5.0 app/inputs/with_help_icon.rb
sufia-6.4.0 app/inputs/with_help_icon.rb
sufia-6.3.0 app/inputs/with_help_icon.rb