Class: Www::TowelWarmerFiltersComponent

Inherits:
ApplicationComponent show all
Includes:
TowelWarmerFilterSlugs
Defined in:
app/components/www/towel_warmer_filters_component.rb

Overview

Www::TowelWarmerFiltersComponent

Renders the filter bar for towel warmer product grid with SEO-friendly URLs.
Uses a Stimulus controller to build path-based URLs when filters change.

URL Structure: /towel-warmer/finish/style/connection/mounting/size

Examples:

Basic usage

<%= render Www::TowelWarmerFiltersComponent.new(
  finish_options: @finish_options,
  style_options: @style_options,
  connection_options: @connection_options,
  mounting_options: @mounting_options,
  size_options: @size_options,
  sort_options: @sort_options,
  active_filters: @active_filters
) %>

See Also:

Constant Summary

Constants included from TowelWarmerFilterSlugs

TowelWarmerFilterSlugs::COMPOSITE_FINISH_SLUGS, TowelWarmerFilterSlugs::CONNECTION_LABELS, TowelWarmerFilterSlugs::CONNECTION_SLUGS, TowelWarmerFilterSlugs::FINISH_SLUGS, TowelWarmerFilterSlugs::MOUNTING_LABELS, TowelWarmerFilterSlugs::MOUNTING_SLUGS, TowelWarmerFilterSlugs::RANSACK_TO_SLUG, TowelWarmerFilterSlugs::SIZE_LABELS, TowelWarmerFilterSlugs::SIZE_SLUGS, TowelWarmerFilterSlugs::SLUG_TO_RANSACK, TowelWarmerFilterSlugs::STYLE_LABELS, TowelWarmerFilterSlugs::STYLE_SLUGS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TowelWarmerFilterSlugs

available_filter_counts, build_filter_path, filter_options_with_slugs, parse_filter_segments, size_filter_counts

Methods inherited from ApplicationComponent

#cms_link, #fetch_or_fallback, #image_asset_tag, #image_tag, #number_to_currency, #number_with_delimiter, #post_path, #post_url, #strip_tags

Constructor Details

#initialize(finish_options:, style_options:, connection_options:, mounting_options:, size_options:, sort_options:, active_filters: {}, current_sort: '') ⇒ TowelWarmerFiltersComponent

Returns a new instance of TowelWarmerFiltersComponent.

Parameters:

  • finish_options (Array<Array>)

    Options for finish select [[label, slug], ...]

  • style_options (Array<Array>)

    Options for style select

  • connection_options (Array<Array>)

    Options for connection select

  • mounting_options (Array<Array>)

    Options for mounting select

  • size_options (Array<Array>)

    Options for size select (Compact/Standard/Large)

  • sort_options (Array<Array>)

    Options for sort select

  • active_filters (Hash) (defaults to: {})

    Currently active Ransack filter params

  • current_sort (String) (defaults to: '')

    Currently active sort value from query string



42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/components/www/towel_warmer_filters_component.rb', line 42

def initialize(finish_options:, style_options:, connection_options:,
               mounting_options:, size_options:, sort_options:, active_filters: {}, current_sort: '')
  @finish_options = finish_options
  @style_options = style_options
  @connection_options = connection_options
  @mounting_options = mounting_options
  @size_options = size_options
  @sort_options = sort_options
  @active_filters = active_filters || {}
  @current_sort = current_sort.to_s
  super()
end

Instance Attribute Details

#active_filtersObject (readonly)

Returns the value of attribute active_filters.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def active_filters
  @active_filters
end

#connection_optionsObject (readonly)

Returns the value of attribute connection_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def connection_options
  @connection_options
end

#current_sortObject (readonly)

Returns the value of attribute current_sort.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def current_sort
  @current_sort
end

#finish_optionsObject (readonly)

Returns the value of attribute finish_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def finish_options
  @finish_options
end

#mounting_optionsObject (readonly)

Returns the value of attribute mounting_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def mounting_options
  @mounting_options
end

#size_optionsObject (readonly)

Returns the value of attribute size_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def size_options
  @size_options
end

#sort_optionsObject (readonly)

Returns the value of attribute sort_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def sort_options
  @sort_options
end

#style_optionsObject (readonly)

Returns the value of attribute style_options.



28
29
30
# File 'app/components/www/towel_warmer_filters_component.rb', line 28

def style_options
  @style_options
end