Class: UU::OS::GVC::DropDownButton

Inherits:
Button show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/gvc/drop_down_button.rb

Overview

Drop-down button component.

Instance Attribute Summary (collapse)

Attributes inherited from Button

#action_uri, #disabled, #icon_uri, #max_width, #min_width, #target, #text, #tooltip

Attributes included from Styleable

#style_class

Attributes inherited from Component

#attributes, #code, #component_type, #form, #height, #id, #name, #width

Instance Method Summary (collapse)

Methods included from Styleable

#add_style_class, #remove_style_class

Methods inherited from Component

#add_message, #focus, #messages

Constructor Details

- (DropDownButton) initialize(container, data = nil)

Creates new instance of DropDownButton component.

Parameters:

  • container (UU::OS::GVC::Container)

    Container where to insert new component.

  • data (String, Hash, Component) (defaults to: nil)

    Initialization data (optional).



47
48
49
50
51
52
53
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/drop_down_button.rb', line 47

def initialize(container, data = nil)
  super(container, data)
  json_data = attributes[:data]
  if !json_data.kind_of? MenuModel
    attributes[:data] = MenuModel.new(json_data)
  end
end

Instance Attribute Details

- (UU::OS::GVC::MenuModel) data

Represents the menu of the dropdown button. It's possible to add, insert or remove items from the model.

Examples:

# get current menu
data = dd_button.data # MenuModel object

# get number of items
data.number_of_rows # 5

# remove third item
data.remove_item(2)

# add a separator and then another item
data.add_item({})
data.add_item({ :text => "Another item", :actionUri => "ues:TER:ART:?UC123456" })

# set MenuModel with single item
dd_button.data = UU::OS::GVC::MenuModel.new([
  { :text => "The only choice", :actionUri => "http://google.com/", :disabled => false, :target => "NEW_WINDOW" }
])

Parameters:

Returns:



36
37
38
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/drop_down_button.rb', line 36

def data
  @data
end

- (Object) data_uri (readonly)

The URI to get the menu model data from. The component does not automatically load this URI. If it's required to access / modify MenuModel stored in this URI, it must be done by the developer that uses this component.



41
42
43
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/drop_down_button.rb', line 41

def data_uri
  @data_uri
end