class TreeBuilderServiceDialogs < TreeBuilderAeCustomization
  has_kids_for DialogGroup, [:x_get_tree_dialog_group_kids, :type]
  has_kids_for DialogTab, [:x_get_tree_dialog_tab_kids, :type]
  has_kids_for Dialog, [:x_get_tree_dialog_kids, :type]

  private

  def tree_init_options(_tree_name)
    {:leaf => "Dialog", :open_all => true}
  end

  def root_options
    {
      :text    => t = _("All Dialogs"),
      :tooltip => t
    }
  end

  # Get root nodes count/array for explorer tree
  def x_get_tree_roots(count_only, _options)
    objects = Rbac.filtered(Dialog.all).sort_by { |a| a.label.downcase }
    count_only_or_objects(count_only, objects)
  end

  def x_get_tree_generic_dialog_kids(object, count_only, type, chk_dialog_type = false)
    objects =
      if chk_dialog_type == true && type == :dialogs
        []
      elsif count_only
        object.dialog_resources
      else
        object.ordered_dialog_resources.collect(&:resource).compact
      end
    count_only_or_objects(count_only, objects)
  end

  def x_get_tree_dialog_kids(object, count_only, type)
    x_get_tree_generic_dialog_kids(object, count_only, type, true)
  end

  def x_get_tree_dialog_tab_kids(object, count_only, type)
    x_get_tree_generic_dialog_kids(object, count_only, type)
  end

  def x_get_tree_dialog_group_kids(object, count_only, type)
    x_get_tree_generic_dialog_kids(object, count_only, type)
  end
end

class TreeBuilderServiceDialogs < TreeBuilderAeCustomization
  def tree_init_options(_tree_name)
    {:open_all => true}
  end

  def root_options
    {
      :text    => t = _("All Dialogs"),
      :tooltip => t
    }
  end

  # Get root nodes count/array for explorer tree
  def x_get_tree_roots(count_only, _options)
    objects = Rbac.filtered(Dialog.all).sort_by { |a| a.label.downcase }
    count_only_or_objects(count_only, objects)
  end
end

Remove dead code in TreeBuilderServiceDialogs.
Remove dead code in TreeBuilderServiceDialogs.
