Sha256: 814d037b4cf7f2c705096a2db25d0084a84e9e8dbc461615257fee6ad6d3ba3b

Contents?: true

Size: 1.14 KB

Versions: 18

Compression:

Stored size: 1.14 KB

Contents

module KirguduBase
	module DynamicPages
		class FormProperty < ::KirguduBase::DynamicPages::Property

			mergeable_attributes :input_type, :max_length, :read_only, :events

			fixable_attributes :events

			validates_presence_of :name, :input_type
			validates_inclusion_of :input_type, in: ::KirguduBase::DynamicPages::Enums::SUPPORTED_INPUT_TYPES, allow_nil: true
			validates_presence_of :data_source, if: :must_have_data_source?

			validates_inclusion_of :read_only, in: [:true, :false], allow_nil: true


			def initialize(options = {})
				self.input_type = :text_edit
				self.max_length = 0
				self.read_only = :false
				self.events = nil


				super(options)
			end


			attr_accessor :input_type
			attr_accessor :max_length
			attr_accessor :read_only
			attr_accessor :events


			def to_external_hash(options = {})
				options ||= {}
				options.merge!({

				               })

				super(options)
			end

			def events_for_json
				self.events ? self.events.map { |e| e.to_external_hash(nil) } : {}
			end


			def must_have_data_source?
				[:chosen_select, :select, :autocomplete_with_id, :autocomplete].include?(self.input_type)
			end

		end
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
kirgudu_base-0.0.21 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.19 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.18 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.17 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.16 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.15 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.14 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.13 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.12 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.11 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.10 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.9 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.8 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.7 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.6 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.5 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.4 app/models/kirgudu_base/dynamic_pages/form_property.rb
kirgudu_base-0.0.3 app/models/kirgudu_base/dynamic_pages/form_property.rb