|
class HtmlBuilder::ConditionalFormBlock
|
|
def initialize(template, form, tag_id, obj, field, condition = "value != ''")
|
|
@template = template
|
|
@form = form
|
|
@tag_id = tag_id
|
|
@obj = obj
|
|
@field = field
|
|
@condition = condition
|
|
end
|
|
|
|
def build(&block)
|
|
bl = HtmlBuilder::StackingForm.new(@template, @form, nil, {:id => @tag_id, :style => "display: none;"})
|
|
bl.inner_table = true
|
|
html = bl.build(&block)
|
|
|
|
#@field = [@field] unless @field.is_a? Array
|
|
#@field.each do |field|
|
|
field_id = (@template.convert_resource_model_to_resource_name(@obj.class) + "_" + @field.to_s).to_sym
|
|
#field_id = (@template.convert_resource_model_to_resource_name(@obj.class) + "_" + field.to_s).to_sym
|
|
#observe_field_id = (@template.convert_resource_model_to_resource_name(@obj.class) + "_" + @field.last.to_s).to_sym
|
|
html += @template.observe_field_trigger field_id do |page|
|
|
#page << "value = $('#{observe_field_id}').value;"
|
|
page << "if (#{@condition}) {"
|
|
page.visual_effect :appear, @tag_id
|
|
page << "} else {"
|
|
page.visual_effect :fade, @tag_id
|
|
page << "}"
|
|
end
|
|
#end
|
|
return html
|
|
end
|
|
end
|