Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

Show and search the salutation in the people list

Guido Boykebeeb65e6a229
diff --git a/app/services/people/directory.rb b/app/services/people/directory.rb
index ba83ec2..185e375 100644
--- a/app/services/people/directory.rb
+++ b/app/services/people/directory.rb
@@ -14,8 +14,9 @@ module People
# * Contact half: rows without a link, and rows linked to someone who is no
# longer an active member (name from the row itself).
# * Search: one normalized substring match (PersonName.normalize, so "Muller"
- # finds nothing but "mueller" and "Müller" find each other) over name,
- # function, department, company and email. In Ruby, because the member half
+ # finds nothing but "mueller" and "Müller" find each other) over name
+ # (with the salutation in front: "Frau Müller"), function, department,
+ # company and email. In Ruby, because the member half
# reads its names from users; the list is sized for a few hundred rows per
# organisation. Pagination is a follow-up once an organisation passes that.
class Directory
@@ -38,12 +39,13 @@ module People
end
# The line under the name, in the list and in the link dialog: function
- # and company of the row, else a member's email. A contact without
- # either has none (nil). A contact never shows an email here: the row's
- # own email is a field of its page, not a label.
+ # and company of the row, else a member's email, else the salutation
+ # (two contacts called "Müller" are "Frau" and "Herr"). A contact without
+ # any has none (nil). A contact never shows an email here: the row's own
+ # email is a field of its page, not a label.
def detail
[person&.function, person&.company].compact_blank.join(' · ').presence ||
- (user&.email if member?)
+ (user&.email if member?) || person&.salutation
end
end
@@ -209,7 +211,8 @@ module People
end
def matches?(entry)
- haystack = [entry.plain_name, entry.person&.function, entry.person&.department, entry.person&.company,
+ addressed = [entry.person&.salutation, entry.plain_name].compact_blank.join(' ')
+ haystack = [addressed, entry.person&.function, entry.person&.department, entry.person&.company,
entry.person&.email, entry.user&.email]
haystack.any? { |value| value.present? && PersonName.normalize(value).include?(@query) }
end
diff --git a/spec/services/people/directory_spec.rb b/spec/services/people/directory_spec.rb
index 1fe82c6..d5db8ec 100644
--- a/spec/services/people/directory_spec.rb
+++ b/spec/services/people/directory_spec.rb
@@ -96,6 +96,18 @@ RSpec.describe People::Directory, :ci_guard do
end
end
+ # Often only "Frau Müller" is known: the name is "Müller", the salutation
+ # "Frau". A search for what one would say finds her, and only her.
+ it 'finds a person by salutation and name together' do
+ frau = create(:person, organisation: organisation, name: 'Müller', salutation: 'Frau', company: nil)
+ create(:person, organisation: organisation, name: 'Müller', salutation: 'Herr', company: nil)
+
+ found = described_class.new(viewer: admin, organisation: organisation, query: 'Frau Müller')
+
+ expect(found.entries.map(&:person)).to eq([frau])
+ expect(found.candidates.map(&:person)).to eq([frau])
+ end
+
# External review of 26.10.2026: a linked member is compared by the name
# the directory shows, not by the copy taken when the row was linked.
it 'finds duplicates of a member by the current account name' do
@@ -263,6 +275,18 @@ RSpec.describe People::Directory, :ci_guard do
expect(entry(kind: :member, user: user).detail).to eq('[email protected]')
expect(entry(kind: :contact, person: build(:person, email: '[email protected]', **bare)).detail).to be_nil
end
+
+ # Two contacts named "Müller" without function or company: the salutation
+ # tells them apart in the list and in the link dialog.
+ it 'is the salutation of a row without function and company' do
+ bare = { function: nil, company: nil }
+
+ expect(entry(kind: :contact, person: build(:person, salutation: 'Frau', **bare)).detail).to eq('Frau')
+ expect(entry(kind: :contact, person: build(:person, salutation: 'Frau', function: 'CTO', company: nil)).detail)
+ .to eq('CTO')
+ expect(entry(kind: :member, user: build(:user, email: '[email protected]'),
+ person: build(:person, salutation: 'Herr', **bare)).detail).to eq('[email protected]')
+ end
end
end