Sha256: f7249814c7ad358fb24b0ed1fe90e2c13427c56cff46c33f3abbaad17555d6f6

Contents?: true

Size: 1.03 KB

Versions: 20

Compression:

Stored size: 1.03 KB

Contents

module Avo
  module Concerns
    module HasControls
      extend ActiveSupport::Concern
      include Avo::Resources::Controls

      included do
        class_attribute :show_controls
        class_attribute :edit_controls
        class_attribute :index_controls
        class_attribute :row_controls
      end

      def render_show_controls
        [BackButton.new, DeleteButton.new, DetachButton.new, ActionsList.new, EditButton.new]
      end

      def render_edit_controls
        [BackButton.new(label: I18n.t("avo.cancel").capitalize), DeleteButton.new, ActionsList.new, SaveButton.new(resource: self)]
      end

      def render_index_controls(item:)
        [AttachButton.new(item: item), ActionsList.new(as_index_control: true), CreateButton.new(item: item)]
      end

      def render_row_controls(item:)
        [
          OrderControls.new,
          ShowButton.new(item: item),
          EditButton.new(item: item),
          DetachButton.new(item: item),
          DeleteButton.new(item: item)
        ]
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
avo-3.9.2 lib/avo/concerns/has_controls.rb
avo-3.9.1 lib/avo/concerns/has_controls.rb
avo-3.8.2 lib/avo/concerns/has_controls.rb
avo-3.9.0 lib/avo/concerns/has_controls.rb
avo-3.8.1 lib/avo/concerns/has_controls.rb
avo-3.8.0 lib/avo/concerns/has_controls.rb
avo-3.6.4 lib/avo/concerns/has_controls.rb
avo-3.6.3 lib/avo/concerns/has_controls.rb
avo-3.6.2 lib/avo/concerns/has_controls.rb
avo-3.6.1 lib/avo/concerns/has_controls.rb
avo-3.6.0 lib/avo/concerns/has_controls.rb
avo-3.5.8 lib/avo/concerns/has_controls.rb
avo-3.5.7 lib/avo/concerns/has_controls.rb
avo-3.5.6 lib/avo/concerns/has_controls.rb
avo-3.5.6.beta1 lib/avo/concerns/has_controls.rb
avo-3.5.5 lib/avo/concerns/has_controls.rb
avo-3.5.4 lib/avo/concerns/has_controls.rb
avo-3.5.3 lib/avo/concerns/has_controls.rb
avo-3.5.2 lib/avo/concerns/has_controls.rb
avo-3.5.1 lib/avo/concerns/has_controls.rb