From 9e540f4eb2bfbd02cadac7453b6b6381ef03e640 Mon Sep 17 00:00:00 2001 From: Diego Steiner Date: Tue, 24 Sep 2024 15:19:02 +0200 Subject: [PATCH] feat: add manager also to participation aside (hitobito_jubla#78) --- app/domain/youth/export/pdf/participation.rb | 25 +++++++++++++++++++ app/models/people_manager.rb | 8 ++++++ .../participations/_asides_youth.html.haml | 9 +++++++ .../participations/_people_managers.html.haml | 12 +++++++++ app/views/person/managers/_list.html.haml | 4 +++ 5 files changed, 58 insertions(+) create mode 100644 app/domain/youth/export/pdf/participation.rb create mode 100644 app/views/event/participations/_asides_youth.html.haml create mode 100644 app/views/event/participations/_people_managers.html.haml diff --git a/app/domain/youth/export/pdf/participation.rb b/app/domain/youth/export/pdf/participation.rb new file mode 100644 index 0000000..4af8abb --- /dev/null +++ b/app/domain/youth/export/pdf/participation.rb @@ -0,0 +1,25 @@ +# Copyright (c) 2012-2013, Jungwacht Blauring Schweiz. This file is part of +# hitobito and licensed under the Affero General Public License version 3 +# or later. See the COPYING file at the top-level directory or at +# https://github.com/hitobito/hitobito. + +module Youth::Export::Pdf + module Participation + class PersonAndEvent < Export::Pdf::Participation::PersonAndEvent + class Person < Export::Pdf::Participation::PersonAndEvent::Person + def render + super + render_people_managers + end + + def render_people_managers + return unless FeatureGate.enabled?('people.people_managers') + + person.people_managers&.each do |manager| + labeled_attr(manager, :manager) + end + end + end + end + end +end diff --git a/app/models/people_manager.rb b/app/models/people_manager.rb index 60f3b04..5d1e811 100644 --- a/app/models/people_manager.rb +++ b/app/models/people_manager.rb @@ -25,6 +25,14 @@ class PeopleManager < ActiveRecord::Base has_paper_trail on: [] + def email + manager.email + end + + def phone_number + manager.phone_numbers.first { _1.public } || manager.phone_numbers.first + end + def create_paper_trail_versions_for_create_event [manager_id, managed_id].each do |main_id| PaperTrail::RecordTrail.new(self).send(:build_version_on_create, diff --git a/app/views/event/participations/_asides_youth.html.haml b/app/views/event/participations/_asides_youth.html.haml new file mode 100644 index 0000000..f31ed09 --- /dev/null +++ b/app/views/event/participations/_asides_youth.html.haml @@ -0,0 +1,9 @@ +- # frozen_string_literal: true +- +- # Copyright (c) 2024, Schweizer Alpen-Club. This file is part of +- # hitobito and licensed under the Affero General Public License version 3 +- # or later. See the COPYING file at the top-level directory or at +- # https://github.com/hitobito/hitobito. + + += render 'people_managers' diff --git a/app/views/event/participations/_people_managers.html.haml b/app/views/event/participations/_people_managers.html.haml new file mode 100644 index 0000000..830428d --- /dev/null +++ b/app/views/event/participations/_people_managers.html.haml @@ -0,0 +1,12 @@ +- # frozen_string_literal: true +- +- # Copyright (c) 2024, Schweizer Alpen-Club. This file is part of +- # hitobito and licensed under the Affero General Public License version 3 +- # or later. See the COPYING file at the top-level directory or at +- # https://github.com/hitobito/hitobito. + + +- FeatureGate.if('people.people_managers') do + - if entry.person.people_managers.any? + %section + = render 'person/managers/list', person: entry.person diff --git a/app/views/person/managers/_list.html.haml b/app/views/person/managers/_list.html.haml index f1edfdc..dd7235e 100644 --- a/app/views/person/managers/_list.html.haml +++ b/app/views/person/managers/_list.html.haml @@ -13,5 +13,9 @@ %tr %td %strong= link_to(item.manager, item.manager, data: { turbo_frame: :_top }) + %div.d-flex.gap-2 + = mail_to(item.email) + = phone_to(item.phone_number.number, item.phone_number) if item.phone_number.present? + - if can?(:destroy_manager, item) %td=render 'people_managers/delete_link', path: person_manager_path(person_id: person.id, id: item.id)