Class: SolidusAdmin::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ComponentsHelper, Turbo::FramesHelper
Defined in:
app/components/solidus_admin/base_component.rb

Overview

BaseComponent is the base class for all components in Solidus Admin.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from ComponentsHelper

#component

Class Method Details

.stimulus_idObject



25
26
27
28
29
30
# File 'app/components/solidus_admin/base_component.rb', line 25

def self.stimulus_id
  @stimulus_id ||= name.underscore
    .sub(/^solidus_admin\/(.*)\/component$/, '\1')
    .gsub("/", "--")
    .tr("_", "-")
end

Instance Method Details

#icon_tag(name, **attrs) ⇒ Object



9
10
11
# File 'app/components/solidus_admin/base_component.rb', line 9

def icon_tag(name, **attrs)
  render component("ui/icon").new(name: name, **attrs)
end

#missing_translation(key, options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'app/components/solidus_admin/base_component.rb', line 13

def missing_translation(key, options)
  keys = I18n.normalize_keys(options[:locale] || I18n.locale, key, options[:scope])

  logger.debug "  [#{self.class}] Missing translation: #{keys.join('.')}"

  if options[:locale] != :en
    t(key, **options, locale: :en)
  else
    "translation missing: #{keys.join('.')}"
  end
end

#solidus_adminObject



38
39
40
# File 'app/components/solidus_admin/base_component.rb', line 38

def solidus_admin
  @solidus_admin ||= SolidusAdmin::Engine.routes.url_helpers
end

#spreeObject



34
35
36
# File 'app/components/solidus_admin/base_component.rb', line 34

def spree
  @spree ||= Spree::Core::Engine.routes.url_helpers
end