Skip to content

Commit

Permalink
ROLES: Sortierung der Rollentypen im Auswahlmenü #552
Browse files Browse the repository at this point in the history
  • Loading branch information
Largo committed May 22, 2024
1 parent 0e98e4a commit 37752b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
* Einloggen mit Mitglied-Nr. oder Haupt-E-Mail-Adresse möglich (hitobito_sac_cas#119)
* Anmeldeformular zeigt für bestehende Mitglieder Beitragskategorie der Mitgliedschaft an (hitobito_sac_cas#119)
* Beim Etikettendruck wird bei jeder Person das Land immer gedruckt. Falls bei einer Person kein Land abgespeichert ist, wird Schweiz gedruckt (hitobito_sac_cas#426)
* Die Rollentypen werden nun alphabetisch sortiert im Auswahlmenü mit ausnahme der Rolle "Andere" (hitobito_sac_cas#552)
4 changes: 4 additions & 0 deletions app/decorators/sac_cas/group_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,8 @@ def has_youth_organization?
object.social_accounts.any? { |account| account.label == 'Homepage JO' }
end

# Sort roles alphabetically, but make "Andere" show up last.
def role_types
klass.role_types.sort_by { |role| [role.name.end_with?('::Andere') ? 1 : 0, role.label] }
end
end
12 changes: 12 additions & 0 deletions spec/decorators/group_decorator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ def make_person(group)
Fabricate(:person, birthday: 25.years.ago, primary_group_id: group.id)
end

describe '#possible_roles' do
context 'Sektion Funktionaere Roles' do
let(:group) { groups(:bluemlisalp_funktionaere) }
it 'puts andere to the end of the list' do
expected_role_list = ['Administration', 'Administration (nur lesend)',
'Kulturbeauftragte*r', 'Mitgliederverwaltung',
'Präsidium', 'Umweltbeauftragte*r', 'Andere']
expect(decorator.role_types.map(&:label)).to eq(expected_role_list)
end
end
end

describe '#members_count' do
context 'for Sektion' do
let(:group) { groups(:bluemlisalp) }
Expand Down

0 comments on commit 37752b2

Please sign in to comment.