Skip to content

Commit

Permalink
feat: add manager also to participation aside (hitobito_jubla#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
diegosteiner committed Sep 24, 2024
1 parent ea38fff commit 9e540f4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
25 changes: 25 additions & 0 deletions app/domain/youth/export/pdf/participation.rb
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/models/people_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 9 additions & 0 deletions app/views/event/participations/_asides_youth.html.haml
Original file line number Diff line number Diff line change
@@ -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'
12 changes: 12 additions & 0 deletions app/views/event/participations/_people_managers.html.haml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions app/views/person/managers/_list.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 9e540f4

Please sign in to comment.