Class: HDropDown

Inherits:
HDivTag show all
Defined in:
lib/hwidgets/hdropdown.rb

Instance Attribute Summary

Attributes inherited from HWidget

#tag

Instance Method Summary collapse

Methods inherited from HWidget

#_addJsSlot, #_set, #_setStyle, #addJsFunction, #appendChild, #appendChilds, #buildSignature, #closeTag, #connect, #copyConstructor, #get, #getChilds, #getElementBy, #getSystemProperty, #hotLog, #openTag, #replacePlaceholder, #reset, #set, #setChilds, #setCloseTag, #setClosedTag, #setEnablePlaceholder, #setInnerHTML, #setParent, #setPlaceholder, #setPlaceholders, #setProperties, #setSlots, #setStyle, #setStyles, #setSystemProperties, #setSystemProperty, #setTag, #storeSlots, #storeStyle, #strProperties, test, #unset, widgetSpace

Constructor Details

#initialize(sourceView: nil, caption: "select", items: [], **args) ⇒ HDropDown

Returns a new instance of HDropDown.



3
4
5
6
7
8
9
10
# File 'lib/hwidgets/hdropdown.rb', line 3

def initialize(sourceView: nil, caption: "select", items: [], **args)

  @sourceView = sourceView
  @caption = caption 
  @items = items

  return super(class: 'hdropdown', **args)
end

Instance Method Details

#a(innerHTML = '', icon: nil, **args) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/hwidgets/hdropdown.rb', line 16

def a(innerHTML = '', icon: nil, **args)

  a = HWidget.new("a", "", args)
  a << HWidget.new('span', class: icon) if icon
  a << HWidget.new('span', innerHTML)
  return a

end

#buttonObject



12
13
14
# File 'lib/hwidgets/hdropdown.rb', line 12

def button
  return HWidget.new("button", @caption, class: "dropbtn") 
end

#contentObject



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/hwidgets/hdropdown.rb', line 25

def content
  contentDiv = HDivTag.new(class: 'dropdown-content')
  @items.each do |item|
    action = item.delete(:action)
    link = self.a(item.delete(:name), icon: item.delete(:icon), **item)
    link.connect(:onclick, @sourceView, "rpcAction", args: {action: action}, 
                 id: @sourceView.oid, mode: 'none',
                 attributes: ":hdbTableView.ids(obj) => ids")

    contentDiv << link
  end
  return contentDiv
end

#htmlObject



39
40
41
42
# File 'lib/hwidgets/hdropdown.rb', line 39

def html
  self << self.button << self.content
  return super
end