Class: HakumiComponents::Tree::Node
- Inherits:
-
Object
- Object
- HakumiComponents::Tree::Node
- Extended by:
- T::Sig
- Defined in:
- app/components/hakumi_components/tree/node.rb
Constant Summary collapse
- TreeScalar =
T.type_alias { T.nilable(Types::ValidationPrimitive) }
- TreeIcon =
T.type_alias { T.nilable(Types::HtmlKey) }
- InputKey =
T.type_alias { Types::HtmlKey }
- RawRecord =
T.type_alias { T::Hash[InputKey, T.untyped] }
- RawChildren =
T.type_alias { T::Array[T.any(Node, RawInput)] }
- RawValue =
T.type_alias { T.nilable(T.any(TreeScalar, T::Array[T.untyped], RawRecord)) }
- RawInput =
T.type_alias { T::Hash[Types::HtmlKey, RawValue] }
Instance Attribute Summary collapse
-
#async ⇒ Object
readonly
Returns the value of attribute async.
-
#checkable ⇒ Object
readonly
Returns the value of attribute checkable.
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#disable_checkbox ⇒ Object
readonly
Returns the value of attribute disable_checkbox.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#leaf ⇒ Object
readonly
Returns the value of attribute leaf.
-
#loading ⇒ Object
readonly
Returns the value of attribute loading.
-
#selectable ⇒ Object
readonly
Returns the value of attribute selectable.
-
#switcher_icon ⇒ Object
readonly
Returns the value of attribute switcher_icon.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key:, title:, children: [], disabled: false, selectable: true, checkable: true, disable_checkbox: false, icon: nil, switcher_icon: nil, async: false, loading: false, leaf: false) ⇒ Node
constructor
A new instance of Node.
- #with_defaults(default_disabled: false, default_icon: nil, default_switcher_icon: nil) ⇒ Object
Constructor Details
#initialize(key:, title:, children: [], disabled: false, selectable: true, checkable: true, disable_checkbox: false, icon: nil, switcher_icon: nil, async: false, loading: false, leaf: false) ⇒ Node
Returns a new instance of Node.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/components/hakumi_components/tree/node.rb', line 33 def initialize( key:, title:, children: [], disabled: false, selectable: true, checkable: true, disable_checkbox: false, icon: nil, switcher_icon: nil, async: false, loading: false, leaf: false ) @key = T.let(key, String) @title = T.let(title, String) @children = T.let(children, T::Array[Node]) @disabled = T.let(disabled, T::Boolean) @selectable = T.let(selectable, T::Boolean) @checkable = T.let(checkable, T::Boolean) @disable_checkbox = T.let(disable_checkbox, T::Boolean) @icon = T.let(icon, TreeIcon) @switcher_icon = T.let(switcher_icon, TreeIcon) @async = T.let(async, T::Boolean) @loading = T.let(loading, T::Boolean) @leaf = T.let(leaf, T::Boolean) end |
Instance Attribute Details
#async ⇒ Object (readonly)
Returns the value of attribute async.
89 90 91 |
# File 'app/components/hakumi_components/tree/node.rb', line 89 def async @async end |
#checkable ⇒ Object (readonly)
Returns the value of attribute checkable.
77 78 79 |
# File 'app/components/hakumi_components/tree/node.rb', line 77 def checkable @checkable end |
#children ⇒ Object (readonly)
Returns the value of attribute children.
68 69 70 |
# File 'app/components/hakumi_components/tree/node.rb', line 68 def children @children end |
#disable_checkbox ⇒ Object (readonly)
Returns the value of attribute disable_checkbox.
80 81 82 |
# File 'app/components/hakumi_components/tree/node.rb', line 80 def disable_checkbox @disable_checkbox end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
71 72 73 |
# File 'app/components/hakumi_components/tree/node.rb', line 71 def disabled @disabled end |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
83 84 85 |
# File 'app/components/hakumi_components/tree/node.rb', line 83 def icon @icon end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
62 63 64 |
# File 'app/components/hakumi_components/tree/node.rb', line 62 def key @key end |
#leaf ⇒ Object (readonly)
Returns the value of attribute leaf.
95 96 97 |
# File 'app/components/hakumi_components/tree/node.rb', line 95 def leaf @leaf end |
#loading ⇒ Object (readonly)
Returns the value of attribute loading.
92 93 94 |
# File 'app/components/hakumi_components/tree/node.rb', line 92 def loading @loading end |
#selectable ⇒ Object (readonly)
Returns the value of attribute selectable.
74 75 76 |
# File 'app/components/hakumi_components/tree/node.rb', line 74 def selectable @selectable end |
#switcher_icon ⇒ Object (readonly)
Returns the value of attribute switcher_icon.
86 87 88 |
# File 'app/components/hakumi_components/tree/node.rb', line 86 def switcher_icon @switcher_icon end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
65 66 67 |
# File 'app/components/hakumi_components/tree/node.rb', line 65 def title @title end |
Class Method Details
.coerce_all(raw_nodes, default_disabled: false, default_icon: nil, default_switcher_icon: nil) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/components/hakumi_components/tree/node.rb', line 105 def self.coerce_all(raw_nodes, default_disabled: false, default_icon: nil, default_switcher_icon: nil) raw_nodes.map do |raw_node| case raw_node when Node raw_node.with_defaults( default_disabled: default_disabled, default_icon: default_icon, default_switcher_icon: default_switcher_icon ) else from_raw( raw_node, default_disabled: default_disabled, default_icon: default_icon, default_switcher_icon: default_switcher_icon ) end end end |
Instance Method Details
#with_defaults(default_disabled: false, default_icon: nil, default_switcher_icon: nil) ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'app/components/hakumi_components/tree/node.rb', line 132 def with_defaults(default_disabled: false, default_icon: nil, default_switcher_icon: nil) Node.new( key: @key, title: @title, children: @children.map do |child| child.with_defaults( default_disabled: default_disabled, default_icon: default_icon, default_switcher_icon: default_switcher_icon ) end, disabled: default_disabled || @disabled, selectable: @selectable, checkable: @checkable, disable_checkbox: @disable_checkbox, icon: @icon || default_icon, switcher_icon: @switcher_icon || default_switcher_icon, async: @async, loading: @loading, leaf: @leaf ) end |