Class: LinkedRails::Form::Field

Inherits:
Resource
  • Object
show all
Defined in:
app/models/linked_rails/form/field.rb,
app/models/linked_rails/form/field/date_input.rb,
app/models/linked_rails/form/field/file_input.rb,
app/models/linked_rails/form/field/text_input.rb,
app/models/linked_rails/form/field/color_input.rb,
app/models/linked_rails/form/field/email_input.rb,
app/models/linked_rails/form/field/radio_group.rb,
app/models/linked_rails/form/field/number_input.rb,
app/models/linked_rails/form/field/select_input.rb,
app/models/linked_rails/form/field/slider_input.rb,
app/models/linked_rails/form/field/checkbox_group.rb,
app/models/linked_rails/form/field/checkbox_input.rb,
app/models/linked_rails/form/field/location_input.rb,
app/models/linked_rails/form/field/markdown_input.rb,
app/models/linked_rails/form/field/password_input.rb,
app/models/linked_rails/form/field/resource_field.rb,
app/models/linked_rails/form/field/date_time_input.rb,
app/models/linked_rails/form/field/text_area_input.rb,
app/models/linked_rails/form/field/association_input.rb,
app/models/linked_rails/form/field/postal_range_input.rb,
app/models/linked_rails/form/field/toggle_button_group.rb,
app/serializers/linked_rails/form/field/select_input_serializer.rb,
app/serializers/linked_rails/form/field/resource_field_serializer.rb,
app/serializers/linked_rails/form/field/association_input_serializer.rb

Defined Under Namespace

Classes: AssociationInput, AssociationInputSerializer, CheckboxGroup, CheckboxInput, ColorInput, DateInput, DateTimeInput, EmailInput, FileInput, LocationInput, MarkdownInput, NumberInput, PasswordInput, PostalRangeInput, RadioGroup, ResourceField, ResourceFieldSerializer, SelectInput, SelectInputSerializer, SliderInput, TextAreaInput, TextInput, ToggleButtonGroup

Instance Attribute Summary collapse

Attributes inherited from Resource

#iri

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#anonymous_iri?

Methods included from Model

#build_child, #singular_resource?

Methods included from Model::Serialization

#preview_includes, #show_includes

Methods included from Model::Iri

#anonymous_iri, #anonymous_iri?, #iri, #iri_opts, #rdf_type, #reload, #root_relative_iri, #route_fragment

Methods included from Model::Enhancements

#enhanced_with?

Methods included from Model::Dirty

#previous_changes_by_predicate, #previously_changed_relations

Methods included from Model::Collections

#collection_for, #parent_collections

Instance Attribute Details

#datatypeObject



34
35
36
# File 'app/models/linked_rails/form/field.rb', line 34

def datatype
  @datatype || raise("No datatype found for #{key} in #{form.name}")
end

#default_valueObject

Returns the value of attribute default_value.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def default_value
  @default_value
end

#descriptionObject



38
39
40
# File 'app/models/linked_rails/form/field.rb', line 38

def description
  description_from_attribute || description_fallback
end

#formObject

Returns the value of attribute form.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def form
  @form
end

#groupObject

Returns the value of attribute group.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def group
  @group
end

#helper_textObject



42
43
44
# File 'app/models/linked_rails/form/field.rb', line 42

def helper_text
  helper_text_from_attribute || helper_text_fallback
end

#input_fieldObject

Returns the value of attribute input_field.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def input_field
  @input_field
end

#keyObject

Returns the value of attribute key.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def key
  @key
end

#label=(value) ⇒ Object (writeonly)

Sets the attribute label

Parameters:

  • the value to set the attribute label to.



6
7
8
# File 'app/models/linked_rails/form/field.rb', line 6

def label=(value)
  @label = value
end

#max_countObject

Returns the value of attribute max_count.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def max_count
  @max_count
end

#max_count_propObject

Returns the value of attribute max_count_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def max_count_prop
  @max_count_prop
end

#max_inclusiveObject

Returns the value of attribute max_inclusive.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def max_inclusive
  @max_inclusive
end

#max_inclusive_propObject

Returns the value of attribute max_inclusive_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def max_inclusive_prop
  @max_inclusive_prop
end

#max_lengthObject



46
47
48
# File 'app/models/linked_rails/form/field.rb', line 46

def max_length
  @max_length || validators[:max_length]
end

#max_length_propObject

Returns the value of attribute max_length_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def max_length_prop
  @max_length_prop
end

#min_countObject



50
51
52
# File 'app/models/linked_rails/form/field.rb', line 50

def min_count
  @min_count || (validators[:presence] ? 1 : nil)
end

#min_count_propObject

Returns the value of attribute min_count_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def min_count_prop
  @min_count_prop
end

#min_inclusiveObject

Returns the value of attribute min_inclusive.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def min_inclusive
  @min_inclusive
end

#min_inclusive_propObject

Returns the value of attribute min_inclusive_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def min_inclusive_prop
  @min_inclusive_prop
end

#min_lengthObject



54
55
56
# File 'app/models/linked_rails/form/field.rb', line 54

def min_length
  @min_length || validators[:min_length]
end

#min_length_propObject

Returns the value of attribute min_length_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def min_length_prop
  @min_length_prop
end

#model_attributeObject

Returns the value of attribute model_attribute.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def model_attribute
  @model_attribute
end

#model_classObject

Returns the value of attribute model_class.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def model_class
  @model_class
end

#pathObject



67
68
69
# File 'app/models/linked_rails/form/field.rb', line 67

def path
  @path || raise("No predicate found for #{key} in #{form.name}")
end

#patternObject



62
63
64
65
# File 'app/models/linked_rails/form/field.rb', line 62

def pattern
  p = @pattern || validators[:pattern]
  p.respond_to?(:call) ? p.call(nil) : p
end

#sh_inObject



75
76
77
78
79
# File 'app/models/linked_rails/form/field.rb', line 75

def sh_in
  return validators[:sh_in] if @sh_in.blank?

  @sh_in.respond_to?(:call) ? @sh_in.call : @sh_in
end

#sh_in_propObject

Returns the value of attribute sh_in_prop.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def sh_in_prop
  @sh_in_prop
end

#validatorsObject

Returns the value of attribute validators.



16
17
18
# File 'app/models/linked_rails/form/field.rb', line 16

def validators
  @validators
end

Class Method Details

.iriObject



111
112
113
# File 'app/models/linked_rails/form/field.rb', line 111

def iri
  Vocab.form[name.demodulize]
end

Instance Method Details

#nameObject



58
59
60
# File 'app/models/linked_rails/form/field.rb', line 58

def name
  label_from_attribute || label_fallback
end

#permission_required?Boolean

Returns:



71
72
73
# File 'app/models/linked_rails/form/field.rb', line 71

def permission_required?
  true
end