Class: AspaceFormHelper::FormContext::ReadOnlyContext

Inherits:
AspaceFormHelper::FormContext show all
Defined in:
frontend/app/helpers/aspace_form_helper.rb

Constant Summary

Constant Summary

Constants inherited from AspaceFormHelper::FormContext

PROPERTIES_TO_EXCLUDE_FROM_READ_ONLY_VIEW

Instance Method Summary (collapse)

Methods inherited from AspaceFormHelper::FormContext

#[], #allowable_types_for, #clean_mixed_content, #combobox, #current_context, #current_id, #default_for, #define_template, #emit_template, #error_params, #exceptions_for_js, #fields_for, #form_context, #form_top, #h, #help_path_for, #hidden_input, #i18n_for, #id, #id_for, #id_for_javascript, #initialize, #jsonmodel_definition, #label, #label_and_boolean, #label_and_password, #label_and_readonly, #label_and_select, #label_and_textarea, #label_and_textfield, #list_for, #name_to_json_path, #obj, #parent_context, #password, #path, #path_to_i18n_key, #path_to_i18n_map, #possible_options_for, #preserve_newlines, #push, #read_only_view, #readonly_context, #required?, #set_index, #templates, #templates_for_js, #update_monitor_params

Constructor Details

This class inherits a constructor from AspaceFormHelper::FormContext

Instance Method Details

- (Object) checkbox(name, opts = {}, default = true, force_checked = false)



516
517
518
# File 'frontend/app/helpers/aspace_form_helper.rb', line 516

def checkbox(name, opts = {}, default = true, force_checked = false)
  ((obj[name] === true) || obj[name] === "true") ? "True" : "False"
end

- (Object) label_and_date(name, opts = {})



536
537
538
# File 'frontend/app/helpers/aspace_form_helper.rb', line 536

def label_and_date(name, opts = {})
  label_with_field(name, "#{obj[name]}")
end

- (Object) label_and_fourpartid



525
526
527
528
529
530
531
532
533
534
# File 'frontend/app/helpers/aspace_form_helper.rb', line 525

def label_and_fourpartid
  fourpart_html = "<div class='identifier-display'>"+
                    "<span class='identifier-display-part'>#{obj["id_0"]}</span>" +
                    "<span class='identifier-display-part'>#{obj["id_1"]}</span>" +
                    "<span class='identifier-display-part'>#{obj["id_2"]}</span>" +
                    "<span class='identifier-display-part'>#{obj["id_3"]}</span>" +
                  "</div>"

  label_with_field("id_0", fourpart_html)
end

- (Object) label_with_field(name, field_html, opts = {})



520
521
522
523
# File 'frontend/app/helpers/aspace_form_helper.rb', line 520

def label_with_field(name, field_html, opts = {})
  return "" if field_html.blank?
  super(name, field_html, opts.merge({:controls_class => "label-only"}))
end

- (Boolean) readonly?

Returns:

  • (Boolean)


478
479
480
# File 'frontend/app/helpers/aspace_form_helper.rb', line 478

def readonly?
  true
end

- (Object) select(name, options, opts = {})



482
483
484
485
486
487
488
489
490
491
492
493
# File 'frontend/app/helpers/aspace_form_helper.rb', line 482

def select(name, options, opts = {})
  return nil if obj[name].blank?

  # Attempt a match in the options to give dynamic enums a chance.
  match = options.find {|label, value| value == obj[name]}

  if match
    match[0]
  else
    I18n.t("#{i18n_for(name)}_#{obj[name]}", :default => obj[name])
  end
end

- (Object) textarea(name = nil, value = "", opts = {})



505
506
507
508
509
510
511
512
513
514
# File 'frontend/app/helpers/aspace_form_helper.rb', line 505

def textarea(name = nil, value = "", opts =  {})
  return "" if value.blank?
  opts[:escape] = true unless opts[:escape] == false
  opts[:base_url] ||= "/"
  value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == true
  Rails.logger.debug(value)
  value =  @parent.preserve_newlines(value) if opts[:clean] == true
  value = CGI::escapeHTML(value) if opts[:escape]
  value.html_safe
end

- (Object) textfield(name = nil, value = "", opts = {})



495
496
497
498
499
500
501
502
503
# File 'frontend/app/helpers/aspace_form_helper.rb', line 495

def textfield(name = nil, value = "", opts =  {})
  return "" if value.blank?
  opts[:escape] = true unless opts[:escape] == false
  opts[:base_url] ||= "/"
  value = clean_mixed_content(value, opts[:base_url]) if opts[:clean] == true
  value = @parent.preserve_newlines(value) if opts[:clean] == true
  value = CGI::escapeHTML(value) if opts[:escape]
  value.html_safe
end