Module: Avo::Concerns::HasResourceStimulusControllers
- Extended by:
- ActiveSupport::Concern
- Included in:
- FieldWrapperComponent, Fields::Common::HeadingComponent, Resources::Base
- Defined in:
- lib/avo/concerns/has_resource_stimulus_controllers.rb
Instance Method Summary collapse
- #add_stimulus_attributes_for(entity, attributes) ⇒ Object
- #get_stimulus_controllers ⇒ Object
- #stimulus_data_attributes ⇒ Object
Instance Method Details
#add_stimulus_attributes_for(entity, attributes) ⇒ Object
41 42 43 44 45 |
# File 'lib/avo/concerns/has_resource_stimulus_controllers.rb', line 41 def add_stimulus_attributes_for(entity, attributes) entity.get_stimulus_controllers.split(" ").each do |controller| attributes["#{controller}-target"] = "#{@field.id.to_s.underscore}_#{@field.type.to_s.underscore}_wrapper".camelize(:lower) end end |
#get_stimulus_controllers ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/avo/concerns/has_resource_stimulus_controllers.rb', line 10 def get_stimulus_controllers return "" if @view.nil? controllers = [] case @view.to_sym when :show controllers << "resource-show" when :new, :edit controllers << "resource-edit" when :index controllers << "resource-index" end controllers << self.class.stimulus_controllers controllers.join " " end |
#stimulus_data_attributes ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/avo/concerns/has_resource_stimulus_controllers.rb', line 29 def stimulus_data_attributes attributes = { controller: get_stimulus_controllers, } get_stimulus_controllers.split(" ").each do |controller| attributes["#{controller}-view-value"] = @view end attributes end |