Class: YuiRestClient::Widgets::Tree

Inherits:
Base
  • Object
show all
Defined in:
lib/yui_rest_client/widgets/tree.rb

Overview

Class representing a tree in UI. It can be YTree.

Instance Method Summary collapse

Methods inherited from Base

#action, #collect_all, #debug_label, #enabled?, #exists?, #initialize, #property

Methods included from YuiRestClient::Waitable

#wait_until, #wait_while

Constructor Details

This class inherits a constructor from YuiRestClient::Widgets::Base

Instance Method Details

#itemsArray<String>

Returns the list of items available to select from tree. Each item is represented by its path from root node to leaf in the tree, in other words, a list of nodes separated by special simbol ‘|’

Examples:

Get items from tree with id “test_id”

{
  "class": "YTree",
  "debug_label": "node_0",
  "hstretch": true,
  "hweight": 30,
  "icon_base_path": "",
  "id": "test_id",
  "items": [
    {
      "children": [
        {
          "icon_name": "icon",
          "label": "node1_1"
        },
        {
          "children": [
            {
              "label": "node1_2_1"
            },
            {
              "label": "node1_2_2",
              "selected": true
            }
          ],
          "icon_name": "icon",
          "label": "node1_2"
        }
      ],
      "icon_name": "icon",
      "label": "node1",
    },
    {
      "icon_name": "icon",
      "label": "node2"
    }
  ],
  "items_count": 2,
  "label": "node_0",
  "notify": true,
  "vstretch": true
}
app.tree(id: 'test_id').items
# node1
# node1|node1_1
# node1|node1_2
# node1|node1_2|node1_2_1
# node1|node1_2|node1_2_2
# node2

Returns:

  • (Array<String>)

    array of strings



61
62
63
# File 'lib/yui_rest_client/widgets/tree.rb', line 61

def items
  get_nodes(property(:items))
end

#select(item) ⇒ Object

Sends action to select an item from the tree in UI.

Examples:

Select tree node ‘test_node’ from tree with id ‘test_id’

app.tree(id: 'test_id').select('test_node')

Parameters:

  • item (String)

    value to select from items.



69
70
71
72
# File 'lib/yui_rest_client/widgets/tree.rb', line 69

def select(item)
  action(action: Actions::SELECT, value: item)
  self
end

#selected_itemString

Returns the item currently selected/highlighted in the tree. Item is represented by its path from root node to leaf in the tree, in other words, a list of nodes separated by special simbol ‘|’

Examples:

Get selected item from tree with id “test_id”

{
  "class": "YTree",
  "debug_label": "node_0",
  "hstretch": true,
  "hweight": 30,
  "icon_base_path": "",
  "id": "test_id",
  "items": [
    {
      "children": [
        {
          "icon_name": "icon",
          "label": "node1_1"
        },
        {
          "children": [
            {
              "label": "node_1_2_1"
            },
            {
              "label": "node_1_2_2",
              "selected": true
            }
          ],
          "icon_name": "icon",
          "label": "node1_2"
        }
      ],
      "icon_name": "icon",
      "label": "node1",
    },
    {
      "icon_name": "icon",
      "label": "node2"
    }
  ],
  "items_count": 2,
  "label": "node_0",
  "notify": true,
  "vstretch": true
}
app.tree(id: 'test_id').selected_item
# node1|node1_2|node1_2_2

Returns:

  • (String)

    item selected/highlighted in the tree



123
124
125
# File 'lib/yui_rest_client/widgets/tree.rb', line 123

def selected_item
  get_selected_node(property(:items))
end