Skip to content

Commit

Permalink
Merge pull request #6221 from skateman/node-selected
Browse files Browse the repository at this point in the history
Add the selected accessor to TreeNode::Node and clean up its to_h
  • Loading branch information
mzazrivec authored Sep 20, 2019
2 parents 56fc497 + 7f33dd2 commit bce805c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/presenters/tree_node/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module TreeNode
class Node
attr_reader :tree

attr_accessor :checkable, :checked, :color, :expanded, :hide_checkbox, :icon_background, :klass, :selectable, :tooltip
attr_accessor :checkable, :checked, :color, :expanded, :hide_checkbox, :icon_background, :klass, :selectable, :selected, :tooltip
attr_writer :icon, :image

def initialize(object, parent_id, tree)
Expand Down Expand Up @@ -45,7 +45,7 @@ def escape(string)
end

def to_h
node = {
{
:key => key,
:text => escape(text),
:tooltip => escape(tooltip),
Expand All @@ -60,10 +60,9 @@ def to_h
:state => {
:checked => checked,
:expanded => expanded,
:selected => selected
}.compact
}

node.delete_if { |_, v| v.nil? }
}.compact
end

class << self
Expand Down

0 comments on commit bce805c

Please sign in to comment.