Class: SolidusAdmin::BaseComponent

Inherits:
ViewComponent::Base
  • Object
show all
Extended by:
InheritableTranslations
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.

Defined Under Namespace

Modules: InheritableTranslations

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InheritableTranslations

build_i18n_backend

Methods included from ComponentsHelper

#component

Class Method Details

.stimulus_idObject



53
54
55
56
57
58
# File 'app/components/solidus_admin/base_component.rb', line 53

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

Instance Method Details

#icon_tag(name, **attrs) ⇒ Object



12
13
14
# File 'app/components/solidus_admin/base_component.rb', line 12

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

#missing_translation(key, options) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'app/components/solidus_admin/base_component.rb', line 41

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] || I18n.default_locale) != :en
    t(key, **options, locale: :en)
  else
    "translation missing: #{keys.join('.')}"
  end
end

#solidus_adminObject



66
67
68
# File 'app/components/solidus_admin/base_component.rb', line 66

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

#spreeObject



62
63
64
# File 'app/components/solidus_admin/base_component.rb', line 62

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