Class: Uchi::Field::BelongsTo::Edit
Instance Attribute Summary
#form, #hint, #label
#field, #record, #repository
Instance Method Summary
collapse
Methods included from Helpers
#associated_record, #label_for_associated_record
#initialize
#initialize, #value
Instance Method Details
#associated_repository ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'app/components/uchi/field/belongs_to.rb', line 42
def associated_repository
@associated_repository ||= begin
model = if reflection.polymorphic?
associated_record&.class
else
reflection.klass
end
return nil if model.nil?
repository_class = Uchi::Repository.for_model(model)
repository_class.new
end
end
|
#attribute_name ⇒ Object
57
58
59
|
# File 'app/components/uchi/field/belongs_to.rb', line 57
def attribute_name
reflection.foreign_key
end
|
61
62
63
|
# File 'app/components/uchi/field/belongs_to.rb', line 61
def dom_id_for_filter_query_input
"#{form.object_name}_#{attribute_name}_belongs_to_filter_query"
end
|
#dom_id_for_toggle ⇒ Object
65
66
67
|
# File 'app/components/uchi/field/belongs_to.rb', line 65
def dom_id_for_toggle
"#{form.object_name}_#{attribute_name}_belongs_to_toggle"
end
|
#record_title(record) ⇒ Object
69
70
71
72
73
|
# File 'app/components/uchi/field/belongs_to.rb', line 69
def record_title(record)
return "" if record.nil?
associated_repository.title(record)
end
|