Sha256: 700f1be471c16a472c02cccbb39a905c8948aafb0a7879db7345dbc843d75ca8

Contents?: true

Size: 934 Bytes

Versions: 42

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

class Avo::Index::Ordering::ButtonComponent < Avo::Index::Ordering::BaseComponent
  attr_accessor :resource
  attr_accessor :reflection
  attr_accessor :direction
  attr_accessor :svg

  def initialize(resource:, direction:, svg: nil,  reflection: nil)
    @resource = resource
    @reflection = reflection
    @direction = direction
    @svg = svg
  end

  def render?
    order_actions[direction].present?
  end

  def order_path(args)
    if reflection.present?
      path = "#{::Avo::App.root_path}/resources/#{reflection_parent_resource.route_key}/#{params[:id]}/#{field.id}/#{resource.model.id}/order"
    else
      path = "#{::Avo::App.root_path}/resources/#{resource.route_key}/#{resource.model.id}/order"
    end

    if args.present?
      string_args = args.map do |key, value|
        "#{key}=#{value}"
      end.join('&')

      path = "#{path}?#{string_args}"
    end

    path
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
avo-1.25.2 app/components/avo/index/ordering/button_component.rb
avo-2.9.2.pre1 app/components/avo/index/ordering/button_component.rb
avo-2.9.1.pre5 app/components/avo/index/ordering/button_component.rb
avo-2.9.1.pre3 app/components/avo/index/ordering/button_component.rb
avo-2.9.1.pre2 app/components/avo/index/ordering/button_component.rb
avo-2.9.1.pre1 app/components/avo/index/ordering/button_component.rb
avo-2.9.0 app/components/avo/index/ordering/button_component.rb
avo-2.8.0 app/components/avo/index/ordering/button_component.rb
avo-2.7.1.pre.1 app/components/avo/index/ordering/button_component.rb
avo-2.7.0 app/components/avo/index/ordering/button_component.rb
avo-2.6.1.pre.2 app/components/avo/index/ordering/button_component.rb
avo-2.6.1.pre.1 app/components/avo/index/ordering/button_component.rb
avo-2.6.0 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.7 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.6 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.5 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.4 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.3 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.2 app/components/avo/index/ordering/button_component.rb
avo-2.5.2.pre.1 app/components/avo/index/ordering/button_component.rb