32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'app/helpers/skyline/ref_object_helper.rb', line 32
def referable_field_browser(form_builder, field, browser, options = {})
options.reverse_merge! :object => form_builder.object.send(field) || form_builder.object.send("build_#{field}"),
:container => nil,
:skip_class => false
if !options[:container]
options[:container] = form_builder.dom_id(field)
css_class = ref_object_css_class(options[:object].referable)
else
css_class = ""
end
c = []
if options[:object].andand.marked_for_destruction?
options[:object].referable_type = nil
options[:object].referable_id = nil
end
form_builder.fields_for "#{field}_attributes", options[:object] do |linked_form|
c << linked_form.hidden_field(:id) unless linked_form.object.new_record?
c << linked_form.hidden_field(:referable_type, :class => "referable_type")
c << linked_form.hidden_field(:referable_id, :class => "referable_id")
c << linked_form.hidden_field(:_destroy, :class => "referable_delete", :value => 0)
linked_form.fields_for "referable_attributes", linked_form.object.referable do |referable_form|
c << hidden_field_tag(referable_form.object_name + "[uri]", referable_form.object.respond_to?(:uri) ? referable_form.object.uri : "", :class => "link_custom_url")
end
deselect_button = link_to_function(button_text(:delete), "Application.Browser.unlink('#{options[:container]}');", :class => "button small red delete").html_safe
browse_button = link_to_function(button_text(:browse), "Application.Browser.browse#{browser.to_s.camelcase}For('#{options[:container]}');", :class => "button small").html_safe
c << content_tag("div", {:class => "not-linked"}) do
nl = []
nl << content_tag("span",t(:nothing_selected, :scope => [:browser,browser]), {:class => "title"}, false)
nl << browse_button
nl.join.html_safe
end
c << content_tag("div", {:class => "linked"}) do
l = []
referable_title = content_tag("span", ref_object_title(linked_form.object.andand.referable) + " ", :id => linked_form.dom_id(:title), :class => "title referable_title")
l << t(:links_to, :scope => [:browser,browser], :referable_title => referable_title)
l << deselect_button
l << " "
l << browse_button
l.join.html_safe
end
c = content_tag("div", c.join.html_safe, :class => "relatesTo #{"linked" if linked_form.object.present? && !linked_form.object.andand.marked_for_destruction?}")
end
content_tag("div", c, :id => form_builder.dom_id(field), :class => css_class) + form_builder.fieldset_errors(field)
end
|