Skip to content
Snippets Groups Projects
organization_chart.rb 697 B
Newer Older
Arnaud Levy's avatar
Arnaud Levy committed
class Communication::Block::Template::OrganizationChart < Communication::Block::Template::Base
Arnaud Levy's avatar
Arnaud Levy committed
  def build_git_dependencies
    add_dependency persons
Arnaud Levy's avatar
Arnaud Levy committed
    persons.each do |person|
      add_dependency person.active_storage_blobs
    end
  end

  def persons_with_role
Arnaud Levy's avatar
Arnaud Levy committed
    @persons_with_role ||= elements.map { |element| person_with_role(element) }
                                   .compact
Arnaud Levy's avatar
Arnaud Levy committed
  end

Arnaud Levy's avatar
Arnaud Levy committed
  def persons
    @persons ||= persons_with_role.map { |hash| hash[:person] }
  end
Arnaud Levy's avatar
Arnaud Levy committed

  def person_with_role(element)
    person = block.university.people.find_by id: element['id']
    return if person.nil?
    {
      person: person,
      role: element['role']
    }.to_dot
  end
Arnaud Levy's avatar
Arnaud Levy committed
end