Sha256: 1356acb6a449e32f7592986479c86eef98f1345008bedd02351c2bafbc84d61e

Contents?: true

Size: 1.51 KB

Versions: 40

Compression:

Stored size: 1.51 KB

Contents

# frozen_string_literal: true

require 'active_support/concern'

module Satis
  module Forms
    module Concerns
      module Buttons
        extend ActiveSupport::Concern

        included do
          alias_method :button_button, :button
          alias_method :submit_button, :submit

          # A submit button
          def submit(value = nil, options = {})
            button_button(value,
                          options.reverse_merge(name: 'commit', type: :submit, class: 'button primary',
                                                value: 'commit'))
          end

          # A regular button
          def button(value = nil, options = {}, &block)
            options = options.reverse_merge(class: 'button')
            options[:name] ||= :commit
            options[:type] ||= :submit
            button_button(value, options, &block)
          end

          # A continue button
          def continue(value = nil, options = {}, &block)
            value ||= if !@object.persisted?
                        ct('create_continue')
                      else
                        ct('update_continue')
                      end
            button_button(value, options.reverse_merge(name: 'commit', value: 'continue', class: 'button secondary'),
                          &block)
          end

          # A reset button
          def reset(value = nil, options = {}, &block)
            button_button(value, options.reverse_merge(type: :reset, class: 'button'), &block)
          end
        end
      end
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
satis-2.1.47 lib/satis/forms/concerns/buttons.rb
satis-2.1.46 lib/satis/forms/concerns/buttons.rb
satis-2.1.45 lib/satis/forms/concerns/buttons.rb
satis-2.1.44 lib/satis/forms/concerns/buttons.rb
satis-2.1.43 lib/satis/forms/concerns/buttons.rb
satis-2.1.42 lib/satis/forms/concerns/buttons.rb
satis-2.1.41 lib/satis/forms/concerns/buttons.rb
satis-2.1.40 lib/satis/forms/concerns/buttons.rb
satis-2.1.39 lib/satis/forms/concerns/buttons.rb
satis-2.1.38 lib/satis/forms/concerns/buttons.rb
satis-2.1.37 lib/satis/forms/concerns/buttons.rb
satis-2.1.36 lib/satis/forms/concerns/buttons.rb
satis-2.1.35 lib/satis/forms/concerns/buttons.rb
satis-2.1.33 lib/satis/forms/concerns/buttons.rb
satis-2.1.31 lib/satis/forms/concerns/buttons.rb
satis-2.1.30 lib/satis/forms/concerns/buttons.rb
satis-2.1.29 lib/satis/forms/concerns/buttons.rb
satis-2.1.28 lib/satis/forms/concerns/buttons.rb
satis-2.1.27 lib/satis/forms/concerns/buttons.rb
satis-2.1.26 lib/satis/forms/concerns/buttons.rb