Sha256: 2016f0fa193ea825e2e42404b7a23e4daff7950fcaedc24493116c02349b3ee0
Contents?: true
Size: 1023 Bytes
Versions: 14
Compression:
Stored size: 1023 Bytes
Contents
# frozen_string_literal: true module Hyrax class PermissionBadge include ActionView::Helpers::TagHelper VISIBILITY_LABEL_CLASS = { authenticated: "badge-info", embargo: "badge-warning", lease: "badge-warning", open: "badge-success", restricted: "badge-danger" }.freeze # @param visibility [String] the current visibility def initialize(visibility) @visibility = visibility end # Draws a span tag with styles for a bootstrap label def render tag.span(text, class: "badge #{dom_label_class}") end private def dom_label_class VISIBILITY_LABEL_CLASS.fetch(@visibility&.to_sym, 'badge-info') end def text if registered? Institution.name else visibility_key = @visibility || 'unknown' I18n.t("hyrax.visibility.#{visibility_key}.text") end end def registered? @visibility == Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_AUTHENTICATED end end end
Version data entries
14 entries across 14 versions & 1 rubygems