Class: YuiRestClient::Widgets::Table
- Defined in:
- lib/yui_rest_client/widgets/table.rb
Overview
Class representing a table in the UI. It can be YTable
Instance Method Summary collapse
-
#empty? ⇒ Boolean
Returns whether the table contains any row or not.
-
#header ⇒ Array
Returns the list of column names.
-
#items ⇒ Array
Returns the list of items available to select from the table.
-
#select(value: nil, column: nil, row: nil) ⇒ Table
Sends action to select a row in a table.
-
#selected_items ⇒ Array
Returns the list of items currently selected from the table.
Methods inherited from Base
#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property
Methods included from YuiRestClient::Waitable
Constructor Details
This class inherits a constructor from YuiRestClient::Widgets::Base
Instance Method Details
#empty? ⇒ Boolean
Returns whether the table contains any row or not
25 26 27 |
# File 'lib/yui_rest_client/widgets/table.rb', line 25 def empty? property(:items).nil? end |
#header ⇒ Array
Returns the list of column names.
75 76 77 |
# File 'lib/yui_rest_client/widgets/table.rb', line 75 def header property(:header) end |
#items ⇒ Array
Returns the list of items available to select from the table.
67 68 69 |
# File 'lib/yui_rest_client/widgets/table.rb', line 67 def items property(:items).map { |x| x[:labels] } end |
#select(value: nil, column: nil, row: nil) ⇒ Table
Sends action to select a row in a table. Row can be selected either by cell value in the column (first column will be used by default), or by row number directly. If both are provided, value will be used. NOTE: row number corresponds to the position of the item in the list of column values which might differ to the display order.
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/yui_rest_client/widgets/table.rb', line 92 def select(value: nil, column: nil, row: nil) params = { action: Actions::SELECT } if !value.nil? params.merge!(value: value) params.merge!(column: get_index(column)) unless column.nil? elsif !row.nil? params.merge!(row: row) end action(params) self end |
#selected_items ⇒ Array
Returns the list of items currently selected from the table.
143 144 145 |
# File 'lib/yui_rest_client/widgets/table.rb', line 143 def selected_items property(:items).map { |x| x[:labels] if x[:selected] }.compact end |