class WAB::UI::List

Represents a list display.

Attributes

list_paths[RW]

Public Class Methods

new(kind, id, template, list_paths, transitions) click to toggle source
Calls superclass method WAB::UI::Display::new
# File lib/wab/ui/list.rb, line 10
def initialize(kind, id, template, list_paths, transitions)
  super(kind, id, template, transitions, 'ui.List')
  @list_paths = list_paths
end

Public Instance Methods

html_row() click to toggle source

Returns an HTML string to be used as a row in a table of a list of objects. Each column element should include the list_paths identifier as a path element attribute.

Each row can contain the buttons view_button, edit_button, and delete_button. These will be used to set up the transitions.

# File lib/wab/ui/list.rb, line 43
def html_row
  html = '<tr>'
  @list_paths.map { |path| html << %{<td class="obj-list" path="#{path}"></td>} }
  buttons = [
             { title: 'View', icon: 'icon icon-eye', cn: 'actions' },
             { title: 'Edit', icon: 'icon icon-pencil', cn: 'actions' },
             { title: 'Delete', icon: 'icon icon-trash-o', cn: 'actions delete' }
            ].map { |spec|
    html << %{<td class="#{spec[:cn]}"><span class="#{spec[:icon]}" title="#{spec[:title]}"></span></td>}
  }
  html << '</tr>'
end
html_table() click to toggle source

Returns an HTML string to be used as the table of a list of objects. The table must have an id attribute value of the name argument. Generally the column header should include the list_paths or more friendly alternatives. If a create button is desired then an element with the name joined with '.create_button' should be the id of the element.

# File lib/wab/ui/list.rb, line 28
def html_table
  html = %{<div class="table-wrapper"><h2 style="float: left; margin-top: 2px">#{@kind} List</h2><div class="btn" style="float: left" id="#{@name}.create_button"><span>Create</span></div><table class="obj-list-table" id="#{@name}.table"><tr>}
  # The column headers.
  @list_paths.map { |path| html << "<th>#{path.capitalize}</th>" }
  # Add the view, edit, and delete buttons header.
  html << %{<th colspan="3">Actions</th>}
  html << %{</tr></table></div>}
end
spec() click to toggle source
Calls superclass method WAB::UI::Display#spec
# File lib/wab/ui/list.rb, line 15
def spec
  ui_spec = super
  ui_spec[:table] = html_table
  ui_spec[:row] = html_row
  ui_spec
end