Class: YuiRestClient::Widgets::Combobox

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

Overview

Class representing a ComboBox in the UI. It can be YComboBox.

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

#editable?Boolean

Allows to check if combobox is editable and allows setting .

Examples:

Check if combobox with id ‘test’ editable

app.combobox(id: 'test').editable? # true

Returns:

  • (Boolean)

    true if widget enabled, false otherwise.



90
91
92
# File 'lib/yui_rest_client/widgets/combobox.rb', line 90

def editable?
  property(:editable) == true
end

#itemsArray<String>

Returns the list of items available to select from combobox.

Examples:

Get items from combobox with id “nfs_version”

{
  "class": "YComboBox",
  "debug_label": "NFS Version",
  "icon_base_path": "",
  "id": "nfs_version",
  "items": [
    {
      "label": "Any (Highest Available)",
      "selected": true
    },
    {
      "label": "Force NFSv3"
    }
  ],
  "items_count": 5,
  "label": "NFS &Version",
  "value": "Any (Highest Available)"
}
app.combobox(id: 'nfs_version').items
# Any (Highest Available)
# Force NFSv3

Returns:

  • (Array<String>)

    array of strings.



32
33
34
# File 'lib/yui_rest_client/widgets/combobox.rb', line 32

def items
  property(:items).map { |x| x[:label] }
end

#select(item) ⇒ Combobox

Sends action to select the item in combobox. List of items can be retrieved from JSON “items”->“label” manually or by using ‘combobox(filter).items’.

Examples:

Select “Force NFSv3” item in combobox with id “nfs_version”

app.combobox(id: 'nfs_version').select('Force NFSv3')

Parameters:

  • item (String)

    item to select in combobox.

Returns:

  • (Combobox)

    in case action is successful

Raises:

  • YuiRestClient::Error::ItemNotFoundInWidgetError in case value is not found in combobox.



43
44
45
46
# File 'lib/yui_rest_client/widgets/combobox.rb', line 43

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

#set(value) ⇒ Combobox

Sends action to set string to the editable combobox. To check if combobox is editable, call editable?

Examples:

Set “Custom Version” item in combobox with id “nfs_version”

app.combobox(id: 'nfs_version').select('Custom Version')

Parameters:

  • item (String)

    value to set in the combobox.

Returns:

  • (Combobox)

    in case action is successful

Raises:

  • YuiRestClient::Error::ItemNotFoundInWidgetError in case value is not found in combobox.



81
82
83
84
# File 'lib/yui_rest_client/widgets/combobox.rb', line 81

def set(value)
  action(action: Actions::ENTER_TEXT, value: value)
  self
end

#valueObject

Returns selected item in combobox.

Examples:

Get selected item in combobox with id “nfs_version”

{
  "class": "YComboBox",
  "debug_label": "NFS Version",
  "icon_base_path": "",
  "id": "nfs_version",
  "items": [
    {
      "label": "Any (Highest Available)",
      "selected": true
    },
    {
      "label": "Force NFSv3"
    }
  ],
  "items_count": 5,
  "label": "NFS &Version",
  "value": "Any (Highest Available)"
}
app.combobox(id: 'nfs_version').value


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

def value
  property(:value)
end