Class: Jav::FiltersComponent

Inherits:
ViewComponent::Base
  • Object
show all
Includes:
ApplicationHelper
Defined in:
app/components/jav/filters_component.rb

Instance Method Summary collapse

Methods included from ApplicationHelper

#a_button, #a_link, #button_classes, #decode_filter_params, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #render_license_warning, #render_license_warnings, #root_path_without_url, #svg, #white_panel_classes

Constructor Details

#initialize(filters: [], resource: nil, applied_filters: [], parent_model: nil) ⇒ FiltersComponent

Returns a new instance of FiltersComponent.



6
7
8
9
10
11
12
# File 'app/components/jav/filters_component.rb', line 6

def initialize(filters: [], resource: nil, applied_filters: [], parent_model: nil)
  super
  @filters = filters
  @resource = resource
  @applied_filters = applied_filters
  @parent_model = parent_model
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'app/components/jav/filters_component.rb', line 14

def render?
  @filters.present?
end

#reset_pathObject



18
19
20
21
22
23
24
25
# File 'app/components/jav/filters_component.rb', line 18

def reset_path
  # If come from a association page
  if @parent_model.present?
    helpers.related_resources_path(@parent_model, @parent_model, filters: nil, reset_filter: true, keep_query_params: true)
  else
    helpers.resources_path(resource: @resource, filters: nil, reset_filter: true, keep_query_params: true)
  end
end