Class: Components::AccessIndicator
- Inherits:
-
Base
- Object
- Base
- Components::AccessIndicator
- Defined in:
- app/components/access_indicator.rb
Instance Method Summary collapse
-
#initialize(object:, icon: true, text: false) ⇒ AccessIndicator
constructor
A new instance of AccessIndicator.
- #render? ⇒ Boolean
- #view_template ⇒ Object
Constructor Details
#initialize(object:, icon: true, text: false) ⇒ AccessIndicator
Returns a new instance of AccessIndicator.
5 6 7 8 9 |
# File 'app/components/access_indicator.rb', line 5 def initialize(object:, icon: true, text: false) @object = object @icon = icon @text = text end |
Instance Method Details
#render? ⇒ Boolean
11 12 13 |
# File 'app/components/access_indicator.rb', line 11 def render? SiteSettings.multiuser_enabled? && !@object.remote? && (current_user&.is_moderator? || current_user&.owns?(@object)) end |
#view_template ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/access_indicator.rb', line 15 def view_template span do if @object.private? span(class: "text-danger") { Icon(icon: "lock-fill", label: t("general.private")) } if @icon if @text whitespace span { t("general.private") } end elsif @object.public? span(class: "text-success") { Icon(icon: "eye-fill", label: t("general.public")) } if @icon if @text whitespace span { t("general.public") } end else span(class: "text-info") { Icon(icon: "unlock", label: t("general.shared")) } if @icon if @text whitespace span { t("general.shared") } end end end end |