Class: Spina::Admin::Conferences::Blog::TranslationsComponent
- Inherits:
-
ApplicationComponent
- Object
- Spina::ApplicationComponent
- ApplicationComponent
- Spina::Admin::Conferences::Blog::TranslationsComponent
- Defined in:
- app/components/spina/admin/conferences/blog/translations_component.rb
Overview
Instance Method Summary collapse
- #existing_locales ⇒ Object
- #generate_edit_link(locale) ⇒ Object
-
#initialize(model, label: nil) ⇒ TranslationsComponent
constructor
A new instance of TranslationsComponent.
- #missing_locales ⇒ Object
- #render? ⇒ Boolean
Constructor Details
#initialize(model, label: nil) ⇒ TranslationsComponent
Returns a new instance of TranslationsComponent.
11 12 13 14 |
# File 'app/components/spina/admin/conferences/blog/translations_component.rb', line 11 def initialize(model, label: nil) @model = model @label = label end |
Instance Method Details
#existing_locales ⇒ Object
24 25 26 27 28 |
# File 'app/components/spina/admin/conferences/blog/translations_component.rb', line 24 def existing_locales @existing_locales ||= @model.translations.pluck(:locale).map(&:to_sym).sort_by do |locale| spina_locales.index(locale) end end |
#generate_edit_link(locale) ⇒ Object
30 31 32 33 |
# File 'app/components/spina/admin/conferences/blog/translations_component.rb', line 30 def generate_edit_link(locale) return helpers.spina.edit_admin_conferences_blog_category_path(@model.id, locale: locale) if @model.is_a? Category return helpers.spina.edit_admin_conferences_blog_post_path(@model.id, locale: locale) if @model.is_a? Post end |
#missing_locales ⇒ Object
20 21 22 |
# File 'app/components/spina/admin/conferences/blog/translations_component.rb', line 20 def missing_locales spina_locales - existing_locales end |
#render? ⇒ Boolean
16 17 18 |
# File 'app/components/spina/admin/conferences/blog/translations_component.rb', line 16 def render? spina_locales.many? end |