From 7f33dd2841069d334cc06e873f005789b232467f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Hal=C3=A1sz?= Date: Fri, 20 Sep 2019 11:03:45 +0200 Subject: [PATCH] Add the selected accessor to TreeNode::Node and clean up its to_h --- app/presenters/tree_node/node.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/presenters/tree_node/node.rb b/app/presenters/tree_node/node.rb index d9f908df213..13f3fa9da52 100644 --- a/app/presenters/tree_node/node.rb +++ b/app/presenters/tree_node/node.rb @@ -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) @@ -45,7 +45,7 @@ def escape(string) end def to_h - node = { + { :key => key, :text => escape(text), :tooltip => escape(tooltip), @@ -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