class WAB::UI::View

An object view display.

Public Class Methods

new(kind, id, template, transitions, display_class='ui.View') click to toggle source
Calls superclass method WAB::UI::Display::new
# File lib/wab/ui/view.rb, line 8
def initialize(kind, id, template, transitions, display_class='ui.View')
  super(kind, id, template, transitions, display_class)
end

Public Instance Methods

append_fields(html, path, template, readonly) click to toggle source
# File lib/wab/ui/view.rb, line 28
def append_fields(html, path, template, readonly)
  disabled = readonly ? ' disabled="disabled"' : ''
  readonly = readonly ? ' readonly' : ''
  template.each_pair { |id,value|
    next if :kind == id
    input = nil
    input_id = "#{path}.#{id}"
    text_input = %{<input class="form-field" id="#{input_id}" type="text" value="#{value}" #{readonly}>}

    if value.is_a?(String)
      count = value.count("\n")
      if 0 < count # a text area
        input = %{<textarea class="form-field" id="#{input_id}" rows="#{count}" #{readonly}>#{value.strip}</textarea>}
      else
        input = text_input
      end
    elsif value.is_a?(TrueClass)
      input = %{<input class="form-field" id="#{input_id}" type="checkbox"#{disabled} checked>}
    elsif value.is_a?(FalseClass)
      input = %{<input class="form-field" id="#{input_id}" type="checkbox"#{disabled}>}
    elsif value.is_a?(Integer) || WAB::Utils.pre_24_fixnum?(value) || value.is_a?(Number)
      input = %{<input class="form-field" id="#{input_id}" type="number" value="#{value}" #{readonly}>}
    elsif value.is_a?(Hash)
      append_fields(html, input_id, value)
    else
      input = text_input
    end
    html << %{<tr><td class="field-label">#{id.capitalize}</td><td>#{input}</td></tr>}
  }
  html
end
html() click to toggle source
# File lib/wab/ui/view.rb, line 18
def html
  html = %{<div class="obj-form-frame readonly"><table class="obj-form">}
  html = append_fields(html, @name, template, true)
  html << '</table>'
  html << %{<div class="btn" id="#{@name}.edit_button"><span>Edit</span></div>}
  html << %{<div class="btn" id="#{@name}.list_button"><span>List</span></div>}
  html << %{<div class="btn delete-btn" style="float:right;" id="#{@name}.delete_button"><span>Delete</span></div>}
  html << '</div>'
end
spec() click to toggle source
Calls superclass method WAB::UI::Display#spec
# File lib/wab/ui/view.rb, line 12
def spec
  ui_spec = super
  ui_spec[:html] = html
  ui_spec
end