Sha256: 5ef11d94eb45817e8a368e8641c9b37c3b8c7bea2c1fe29886fbbff14093736e

Contents?: true

Size: 746 Bytes

Versions: 47

Compression:

Stored size: 746 Bytes

Contents

# frozen_string_literal: true

module Satis
  module Switch
    class Component < Satis::ApplicationComponent
      attr_reader :url, :form, :attribute, :icon, :options

      def initialize(form:, attribute:, **options, &block)
        super

        @form = form
        @attribute = attribute
        @options = options
        @block = block
        @icon = true
        @icon = options[:icon] if options.key?(:icon)
        @value = options.key?(:value) ? options[:value] : @form.object.send(attribute)
        @value = @value == '0' || !@value ? false : true
        options[:input_html] ||= {}
        options[:input_html] = { data: { 'satis-switch-target' => 'hiddenInput' } }.deep_merge(options[:input_html])
      end
    end
  end
end

Version data entries

47 entries across 47 versions & 1 rubygems

Version Path
satis-2.1.47 app/components/satis/switch/component.rb
satis-2.1.46 app/components/satis/switch/component.rb
satis-2.1.45 app/components/satis/switch/component.rb
satis-2.1.44 app/components/satis/switch/component.rb
satis-2.1.43 app/components/satis/switch/component.rb
satis-2.1.42 app/components/satis/switch/component.rb
satis-2.1.41 app/components/satis/switch/component.rb
satis-2.1.40 app/components/satis/switch/component.rb
satis-2.1.39 app/components/satis/switch/component.rb
satis-2.1.38 app/components/satis/switch/component.rb
satis-2.1.37 app/components/satis/switch/component.rb
satis-2.1.36 app/components/satis/switch/component.rb
satis-2.1.35 app/components/satis/switch/component.rb
satis-2.1.33 app/components/satis/switch/component.rb
satis-2.1.31 app/components/satis/switch/component.rb
satis-2.1.30 app/components/satis/switch/component.rb
satis-2.1.29 app/components/satis/switch/component.rb
satis-2.1.28 app/components/satis/switch/component.rb
satis-2.1.27 app/components/satis/switch/component.rb
satis-2.1.26 app/components/satis/switch/component.rb