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.

feat(people): add the people page with a lane

Guido Boyke38f1ea7cfdd4
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index 41e757b..ff78fcf 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -317,6 +317,8 @@ jobs:
spec/requests/organisations/meeting_assistant_draft_context_spec.rb
spec/requests/organisations/meeting_assistant_seams_spec.rb
spec/requests/organisations/meetings_overview_create_spec.rb
+ spec/requests/organisations/people_spec.rb
+ spec/services/people/directory_spec.rb
spec/requests/organisations/note_editor_embed_spec.rb
spec/requests/organisations/onboarding_banner_spec.rb
spec/requests/organisations/panel_lane_markup_guard_spec.rb
diff --git a/CLAUDE.md b/CLAUDE.md
index a89dd5a..e7b1081 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -964,7 +964,8 @@ ends that, and a `bundle update` can bring one without anybody noticing.
### Locale-Struktur
* **Dateien**: View-Strings liegen pro Bereich in `config/locales/views/<bereich>.{de,en}.yml`
- (tickets, ansichten, zeiterfassung, meetings, inbox, wissen, dokumente, hilfe, organisation);
+ (tickets, ansichten, zeiterfassung, meetings, inbox, wissen, dokumente, hilfe, organisation,
+ personen);
Rest (common/shared/layouts/devise/admin/components) in `views.{de,en}.yml`. Unterordner werden
von Rails automatisch geladen. Cross-File-Duplikate mit abweichenden Werten bricht der Guard
(`spec/locales/no_duplicate_keys_guard_spec.rb`) — jeder Key hat genau EINEN Besitzer.
diff --git a/app/controllers/concerns/CLAUDE.md b/app/controllers/concerns/CLAUDE.md
index e30ad25..ba8f0b3 100644
--- a/app/controllers/concerns/CLAUDE.md
+++ b/app/controllers/concerns/CLAUDE.md
@@ -1,4 +1,4 @@
-# Karte: app/controllers/concerns (Stand: 2026-10-24)
+# Karte: app/controllers/concerns (Stand: 2026-10-26)
> Für die Ticket-**Domäne** (Attributsystem, Kanban, Actors, Fallen) gilt zusätzlich
> `docs/architektur/tickets_lesepfad.md`. Diese Karte hier beschreibt nur den **Stack**.
@@ -88,6 +88,10 @@ Meeting-Ansicht gehört der Liste ihres Projekts, ohne Projekt der Übersicht. D
nehmen `project: nil` als „organisationsweit“; Tickets und Wissen geben weiter ein Projekt mit.
Die Grundansicht der Spalten wählt `ViewConfiguration.for_list` (ohne Projekt nur `meetings`,
Route `meetings_view_configuration`, derselbe Controller wie die Projekt-Route).
+Die Personenliste (`Organisations::PeopleController`, 26.10.2026) ist die sechste Bahn:
+`ViewportSwitchable` + `People::Directory`, ohne Filterleiste und Spaltenwahl, dieselben
+Stimulus-Controller (`layout-toggle`, `index-page`, `list-row`, `lane-link`); Speichern und
+Löschen verlassen die Bahn (`_top`) und landen mit `?person_id=` wieder auf der Liste.
Der Entscheid für EINE kanonische Listen-Architektur steht aus; bis dahin gilt für neue
Listen-Features: am ähnlichsten Bestands-Feature orientieren und die Wahl im PR begründen.
Seit 10.09.2026 teilen Tickets und Knowledge immerhin die OBERFLÄCHE der Liste-mit-Bahn
diff --git a/app/controllers/organisations/people_controller.rb b/app/controllers/organisations/people_controller.rb
new file mode 100644
index 0000000..d8e3b0c
--- /dev/null
+++ b/app/controllers/organisations/people_controller.rb
@@ -0,0 +1,196 @@
+# frozen_string_literal: true
+
+# The people directory of an organisation (Person): members with their extra
+# details and contacts without a login, kept by consultant and customer
+# together. One page with a lane, the shape of "Alle Meetings"
+# (MeetingsOverviewController): the list on the left, the person or the form in
+# the lane frame on the right. The address carries the lane state:
+# ?person_id= for a person, ?new=person for the form.
+#
+# show, new and edit answer the lane frame (a row click, the "+", "Bearbeiten");
+# a full visit of them lands on the index with the same lane state. The index
+# answers a lane frame request with the lane alone (the restorer on Back, a
+# redirect inside the frame).
+#
+# Writes go through Actors::SavePerson / DestroyPerson and leave the frame
+# (_top): a save redraws the list and the lane on the index with the saved
+# person open, a refused save renders the index with the form again (422).
+#
+# Rights: PersonPolicy (view_people / manage_people, account admins without a
+# row). A denial answers 403 here, not the app's redirect: the page and its
+# frame have nothing to show, and a redirect inside the lane frame loops.
+module Organisations
+ class PeopleController < Organisations::BaseController
+ include ViewportSwitchable
+
+ DETAIL_FRAME_ID = 'person_display_frame'
+ LIST_FRAME_ID = 'people_results'
+ NEW_STATE = 'person'
+ # The list state the lane's forms and links carry, so a save keeps it.
+ LIST_PARAMS = %w[q kind].freeze
+
+ rescue_from Pundit::NotAuthorizedError, with: :render_forbidden
+
+ before_action :set_viewport_mode, only: :index
+ before_action :set_person, only: %i[show edit update destroy]
+
+ def index
+ authorize Person
+ @people = policy_scope(Person)
+ return render_lane_frame if lane_frame_request?
+
+ @entries = directory.entries
+ @lane_person = selected_person
+ @form_person = new_person if @lane_person.nil? && new_person_requested?
+ end
+
+ def show
+ authorize @person
+ return redirect_to(index_path(person_id: @person.id)) unless turbo_frame_request?
+
+ render_frame(:detail, person: @person)
+ end
+
+ def new
+ @person = new_person
+ authorize @person
+ return redirect_to(index_path(new: NEW_STATE)) unless turbo_frame_request?
+
+ render_frame(:form, person: @person)
+ end
+
+ def edit
+ authorize @person
+ return redirect_to(index_path(person_id: @person.id)) unless turbo_frame_request?
+
+ render_frame(:form, person: @person)
+ end
+
+ def create
+ authorize Person
+ save_person(id: nil, flash_key: 'controllers.people.create.success')
+ end
+
+ def update
+ authorize @person
+ save_person(id: @person.id, flash_key: 'controllers.people.update.success')
+ end
+
+ def destroy
+ authorize @person
+ result = Actors::DestroyPerson.call(person: @person, current_user: current_user)
+ if result.success?
+ redirect_to index_path, status: :see_other, notice: t('controllers.people.destroy.success')
+ else
+ redirect_to index_path(person_id: @person.id), status: :see_other, alert: result.errors.to_sentence
+ end
+ end
+
+ private
+
+ # The right first (403 without it, before anything is looked up), then
+ # through the policy scope: a person of another organisation, or one linked
+ # to a member the reader may not see, is no person at all (404).
+ def set_person
+ authorize Person, :index?
+ @person = policy_scope(Person).find(params[:id])
+ end
+
+ def save_person(id:, flash_key:)
+ result = Actors::SavePerson.call(organisation: current_organisation, params: person_params,
+ current_user: current_user, id: id)
+ if result.success?
+ redirect_to index_path(person_id: result.resource.id), status: :see_other, notice: t(flash_key)
+ else
+ render_refused_save(result, id)
+ end
+ end
+
+ # The index again, with the form open in the lane and the reason above it.
+ # A stale save shows the CURRENT values: the other side's change stays, and
+ # the reader sees what they would overwrite.
+ def render_refused_save(result, id)
+ @form_person = refused_form_person(result, id)
+ @form_message = result.code == :stale_object ? t('controllers.people.update.stale') : result.errors.to_sentence
+ @entries = directory.entries
+ set_viewport_mode
+ render :index, status: :unprocessable_content
+ end
+
+ def refused_form_person(result, id)
+ return policy_scope(Person).find(id) if result.code == :stale_object
+
+ result.resource || new_person
+ end
+
+ def person_params
+ params.require(:person).permit(*Actors::SavePerson::ATTRIBUTES, :user_id)
+ end
+
+ def directory
+ People::Directory.new(viewer: current_user, organisation: current_organisation,
+ query: params[:q], kind: params[:kind])
+ end
+
+ # A member row without a person row opens the form with the member chosen
+ # (?user_id=); SavePerson checks the choice again.
+ def new_person
+ current_organisation.people.build(user_id: params[:user_id].presence)
+ end
+
+ def new_person_requested?
+ params[:new] == NEW_STATE && policy(Person).create?
+ end
+
+ def selected_person
+ id = params[:person_id]
+ @people.find_by(id: id) if id.is_a?(String) && id.present?
+ end
+
+ def lane_frame_request?
+ turbo_frame_request? && request.headers['Turbo-Frame'] == DETAIL_FRAME_ID
+ end
+
+ # The lane alone, as a full visit of the same address shows it.
+ def render_lane_frame
+ person = selected_person
+ if person
+ render_frame(:detail, person: person)
+ elsif new_person_requested?
+ render_frame(:form, person: new_person)
+ else
+ render_frame(:empty)
+ end
+ end
+
+ def render_frame(state, person: nil, status: :ok)
+ render html: helpers.turbo_frame_tag(DETAIL_FRAME_ID) {
+ helpers.render(partial: 'organisations/people/lane', locals: { state: state, person: person, message: nil })
+ }, layout: false, status: status
+ end
+
+ def render_forbidden
+ skip_authorization
+ skip_policy_scope
+ if turbo_frame_request?
+ render html: helpers.turbo_frame_tag(request.headers['Turbo-Frame']) {
+ helpers.tag.p(t('shared.errors.not_authorized'), class: 'py-10 text-center text-sm text-muted')
+ }, layout: false, status: :forbidden
+ else
+ render plain: t('shared.errors.not_authorized'), status: :forbidden
+ end
+ end
+
+ def index_path(**lane)
+ organisation_people_path(current_organisation, list_state.merge(lane.stringify_keys).compact_blank)
+ end
+
+ # The list state of this request (the address, or the hidden fields of a
+ # lane form). Kept to strings: a list state is a word and a search.
+ def list_state
+ state = request.query_parameters.merge(request.request_parameters).slice(*LIST_PARAMS)
+ state.select { |_key, value| value.is_a?(String) && value.present? }
+ end
+ helper_method :list_state
+ end
+end
diff --git a/app/helpers/mobile_navigation_helper.rb b/app/helpers/mobile_navigation_helper.rb
index d0af149..bbd02d9 100644
--- a/app/helpers/mobile_navigation_helper.rb
+++ b/app/helpers/mobile_navigation_helper.rb
@@ -24,6 +24,7 @@ module MobileNavigationHelper
'memberships' => 'settings.members',
'organisation_settings' => 'navigation.management',
'overview_configurations' => 'mobile.page_titles.overview_configuration',
+ 'people' => 'navigation.people',
'power_search' => 'mobile.search',
'projects' => 'mobile.projects',
'prompt_personas' => 'views.organisations.ai_overview.pages.personas',
diff --git a/app/helpers/people_helper.rb b/app/helpers/people_helper.rb
new file mode 100644
index 0000000..16090ef
--- /dev/null
+++ b/app/helpers/people_helper.rb
@@ -0,0 +1,82 @@
+# frozen_string_literal: true
+
+# The people directory page (Organisations::PeopleController): the wiring of
+# its list and lane, and the words of a person's history.
+module PeopleHelper
+ # The page wrapper's data: the lane (layout-toggle, index-page) and the
+ # desktop/mobile switch, the same controllers as "Alle Meetings"
+ # (meeting_list_page_data), without its filter bar and column picker.
+ def people_page_data(viewport_mode:, selected:, form_open:)
+ detail_frame_id = Organisations::PeopleController::DETAIL_FRAME_ID
+ unresolved = people_unresolved_lane_params(selected: selected, form_open: form_open)
+ {
+ controller: 'layout-toggle index-page viewport',
+ layout_toggle_list_frame_ids_value: [Organisations::PeopleController::LIST_FRAME_ID].to_json,
+ layout_toggle_detail_frame_id_value: detail_frame_id,
+ layout_toggle_content_selector_value: '.person-content',
+ layout_toggle_selected_row_selector_value: '.selected-row[data-person-id]',
+ layout_toggle_selection_params_value: %w[person_id].to_json,
+ layout_toggle_list_filter_params_value: Organisations::PeopleController::LIST_PARAMS.to_json,
+ layout_toggle_storage_key_value: 'layoutState:people',
+ layout_toggle_unresolved_selection_value: (unresolved.to_json if unresolved.any?),
+ viewport_breakpoint_value: MeetingsHelper::LANE_FULL_PAGE_BELOW_PX,
+ viewport_current_mode_value: viewport_mode,
+ index_page_param_name_value: 'person_id',
+ index_page_frame_id_value: detail_frame_id,
+ index_page_content_selector_value: '.person-content',
+ index_page_placeholder_id_value: 'person-display-placeholder',
+ index_page_placeholder_class_value: 'ticket-placeholder px-4',
+ index_page_placeholder_title_value: t('views.organisations.people.index.placeholder_title'),
+ index_page_placeholder_body_value: t('views.organisations.people.index.placeholder_body'),
+ index_page_selected_row_selector_value: '.selected-row[data-person-id]',
+ index_page_skip_if_content_visible_value: 'true',
+ index_url: organisation_people_path(current_organisation),
+ lane_params: lane_params_json(selection: %w[person_id], form: %w[new])
+ }.compact
+ end
+
+ # Lane parameters of this visit the server did not open (an unknown or
+ # unreadable person_id, a form the reader may not open). layout-toggle takes
+ # them out of the address, so the page stays the list.
+ def people_unresolved_lane_params(selected:, form_open:)
+ unresolved = {}
+ person_id = params[:person_id]
+ unresolved['person_id'] = person_id if person_id.is_a?(String) && person_id.present? && selected.nil?
+ new_state = params[:new]
+ unresolved['new'] = new_state if new_state.is_a?(String) && new_state.present? && !form_open
+ unresolved
+ end
+
+ # The name a row or the lane shows: a member through the viewer's name
+ # display setting, a contact as written in the row.
+ def person_display_name(person: nil, user: nil)
+ user ||= person&.user
+ user ? viewer_display_name(user) : person.name
+ end
+
+ # Initials for a contact's avatar (no account, no picture).
+ def person_initials(name)
+ name.to_s.split.first(2).map { |part| part[0] }.join.upcase
+ end
+
+ # One line of the history: who did what. An update names the changed fields
+ # (never their values, PersonTrackable).
+ def person_history_line(activity)
+ actor = viewer_display_name(activity.actor)
+ case activity.action
+ when 'created' then t('views.organisations.people.history.created', actor: actor)
+ when 'updated'
+ fields = activity.attribute_changes.to_h.keys.map { |field| Person.human_attribute_name(field.delete_suffix('_id')) }
+ t('views.organisations.people.history.updated', actor: actor, fields: fields.to_sentence)
+ else t('views.organisations.people.history.other', actor: actor)
+ end
+ end
+
+ # The active members the reader may link a row to: visible on the members
+ # page and without a row of their own yet (plus the row's current member).
+ def linkable_members_for(person)
+ taken = Person.where(organisation: current_organisation).linked.where.not(id: person.id).select(:user_id)
+ member_ids = policy_scope(Membership).where(organisation: current_organisation, active: true).select(:user_id)
+ User.where(id: member_ids).where.not(id: taken).to_a.sort_by { |user| viewer_display_name(user).downcase }
+ end
+end
diff --git a/app/models/CLAUDE.md b/app/models/CLAUDE.md
index 6dd574d..65bcb35 100644
--- a/app/models/CLAUDE.md
+++ b/app/models/CLAUDE.md
@@ -1,4 +1,4 @@
-# Karte: app/models (Stand: 2026-10-24)
+# Karte: app/models (Stand: 2026-10-26)
~80 Modelle liegen flach in diesem Verzeichnis; Namespaces existieren nur für `admin/`,
`knowledge/`, `overview/`, `smart_folders/`, `time_sessions/`, `user/`. Die Domänen-Zugehörigkeit ist am
@@ -45,6 +45,20 @@ Verzeichnis-Layout nicht ablesbar — diese Karte gruppiert sie:
⚠️ Wer eine Beziehung SEHEN darf, entscheidet nur `TicketRelation.visible_to(user, org, token:)`:
beide Enden lesbar (`TicketPolicy::Scope`), mit Token zusätzlich in dessen Reichweite. Titel,
Nummer und Projekt eines Tickets ohne Leserecht erscheinen nirgends (Plan §4).
+* **Personen** (seit 26.10.2026): `person` (eine gemeinsame Personenliste je Organisation,
+ Tabelle `people`), `person_name` (der EINE Namens-Normalisierer, auch für
+ `MeetingParticipant.normalize_name`). Eine Zeile ist ein Kontakt ohne Konto oder die
+ Zusatzangaben eines Mitglieds (`user_id`, nur aktive Mitglieder derselben Org, eindeutig
+ je Org); `name` ist immer gefüllt. Eigenes Recht (`Permission::CATEGORIES[:people]`,
+ `view_people`/`manage_people`, gastrollen-tauglich), Kontoadmins ohne Zeile; die Policy
+ prüft die aktive Mitgliedschaft selbst. Lesen über `People::Directory`, Schreiben über
+ `Actors::SavePerson`/`DestroyPerson`.
+ ⚠️ `concerns/person_trackable.rb`: Aktivitäten tragen KEINE Personendaten (leere Parameter,
+ bei Änderungen nur Feldnamen), `skip_notifications` immer; ein Löschen hinterlässt genau eine
+ anonyme `person.deleted`-Zeile. ⚠️ `concerns/person_link_release.rb` steht in `membership`
+ UND `admin/membership`: wer eine Mitgliedschaft entfernt, behält die Zeile und verliert nur
+ die Verknüpfung. Darum läuft `erase_personal_data!` in beiden Löschwegen VOR
+ `memberships.destroy_all`; andersherum findet `erase_person_links!` nichts mehr.
* **Activity/Notifications**: `activity`, `user_activity`, `outbox_event`, `notification`,
`notification_preference`, `notification_subscription`, `email_log` — Services dazu unter
`app/services/notifications/` (eigene Karte dort)
diff --git a/app/services/CLAUDE.md b/app/services/CLAUDE.md
index a1ad84a..cc5e0e7 100644
--- a/app/services/CLAUDE.md
+++ b/app/services/CLAUDE.md
@@ -1,4 +1,4 @@
-# Karte: app/services (Stand: 2026-10-19)
+# Karte: app/services (Stand: 2026-10-26)
**Entry-Point-Konvention für NEUE Services: `Klass.call(**kwargs)`** (Klassenmethode; eine
Instanz-`#call`-Implementierung dahinter ist erlaubt). Pflicht: mindestens 1 Kommentarzeile
@@ -154,6 +154,10 @@ Verzeichnis-Übersicht (Auswahl):
ist `User#claim_first_visit!` (`UPDATE ... WHERE last_seen_at IS NULL`); die App führt
kein Devise `trackable`. ⚠️ Host aus `ActionMailer::Base.default_url_options`, nicht
aus dem Config-Objekt: das ist unter RSpec leer.
+* `people/` — `directory.rb`, das Lese-Objekt der Personenliste (seit 26.10.2026): Mitglieder
+ über `MembershipPolicy::Scope` (dieselbe Reichweite wie die Mitgliederseite), dazu die
+ Zeilen ohne aktives Mitglied als Kontakte; Suche in Ruby über `PersonName.normalize`.
+ Rechte nur über `PersonPolicy`, keine eigene Regel daneben.
* `notifications/` — Empfänger-Fanout, Broadcast, Scoring (eigene Karte im Ordner); dazu
`inbox_query.rb` + `serializer.rb`, der EINE Besitzer der Token-Inbox (Reichweite,
Argument-Vertrag, Zeilen-JSON), geteilt von `GET /api/v1/notifications` und dem
diff --git a/app/services/people/directory.rb b/app/services/people/directory.rb
index 2d9aea8..818bd57 100644
--- a/app/services/people/directory.rb
+++ b/app/services/people/directory.rb
@@ -48,12 +48,30 @@ module People
list.concat(member_entries) unless @kind == 'contacts'
list.concat(contact_entries) unless @kind == 'members'
list.select! { |entry| matches?(entry) } if @query.present?
- list.sort_by { |entry| [entry.sort_name, entry.person&.id.to_s, entry.user&.id.to_s] }
+ sorted(list)
+ end
+ end
+
+ # The other entries with the same normalized name as this person: rows and
+ # members that may be the same person (the duplicate hint, read only).
+ def duplicates_of(person)
+ return [] unless PersonPolicy.view_allowed?(@viewer, @organisation)
+
+ ActsAsTenant.with_tenant(@organisation) do
+ same = (member_entries + contact_entries).select do |entry|
+ entry.sort_name == person.normalized_name && entry.person&.id != person.id &&
+ !(entry.user && entry.user.id == person.user_id)
+ end
+ sorted(same)
end
end
private
+ def sorted(list)
+ list.sort_by { |entry| [entry.sort_name, entry.person&.id.to_s, entry.user&.id.to_s] }
+ end
+
def member_entries
memberships = MembershipPolicy::Scope.new(@viewer, Membership).resolve
.where(organisation: @organisation, active: true)
diff --git a/app/views/common/_navigation_application.html.erb b/app/views/common/_navigation_application.html.erb
index de108e0..d6586a1 100644
--- a/app/views/common/_navigation_application.html.erb
+++ b/app/views/common/_navigation_application.html.erb
@@ -130,8 +130,10 @@
operator flag plus use_assistant) which has nothing to do with reading
projects, so the block now opens for it too — and the search row carries the
gate that actually belongs to it. That predicate is exactly the old block
- condition, so nothing changes for anybody who had the block before. %>
- <% if user_signed_in? && (policy(Project).index? || policy(TimeSession).index? || assistant_available?) %>
+ condition, so nothing changes for anybody who had the block before.
+ The people directory is a right of its own (PersonPolicy) and opens the
+ block too: a customer role may hold it without any project. %>
+ <% if user_signed_in? && (policy(Project).index? || policy(TimeSession).index? || assistant_available? || policy(Person).index?) %>
<div class="w-full px-4 pt-3">
<div class="mb-2">
<% can_view_times = TimeSessionNavigationService.new(current_user, current_organisation).can_show_all_time_sessions_menu? %>
@@ -187,6 +189,10 @@
<% if can_view_meetings %>
<%= render 'common/navigation_item', name: t('navigation.all_meetings'), path: organisation_meetings_path(organisation_id: current_organisation.id), icon: 'bi bi-chat-quote', active: controller_name == 'meetings_overview' %>
<% end %>
+ <%# The people directory: a right of its own (PersonPolicy). %>
+ <% if policy(Person).index? %>
+ <%= render 'common/navigation_item', name: t('navigation.people'), path: organisation_people_path(organisation_id: current_organisation.id), icon: 'bi bi-people', active: controller_name == 'people' %>
+ <% end %>
</ul>
</div>
</div>
diff --git a/app/views/organisations/mobile_navigation/more.html.erb b/app/views/organisations/mobile_navigation/more.html.erb
index 798fc00..95c5846 100644
--- a/app/views/organisations/mobile_navigation/more.html.erb
+++ b/app/views/organisations/mobile_navigation/more.html.erb
@@ -6,14 +6,18 @@
<%= link_to t('mobile.switch'), select_organisation_path, class: 'mobile-text-action' %>
</div>
<% show_meetings = AccessCheck::ProjectAccessService.accessible_project_ids(current_user, current_organisation, action: :read, area: :meetings).any? %>
+ <% show_people = policy(Person).index? %>
<% show_billings = policy(TimeSessionGroup).index? %>
<% show_management = can_manage_organisation?(current_organisation) %>
- <% if show_meetings || show_billings || show_management %>
+ <% if show_meetings || show_people || show_billings || show_management %>
<h2 class="mobile-section-label"><%= t('mobile.organisation') %></h2>
<ul class="mobile-menu-list">
<% if show_meetings %>
<li><%= link_to safe_join([content_tag(:i, '', class: 'bi bi-chat-left', aria: { hidden: true }), content_tag(:span, t('navigation.all_meetings'))]), organisation_meetings_path(current_organisation) %></li>
<% end %>
+ <% if show_people %>
+ <li><%= link_to safe_join([content_tag(:i, '', class: 'bi bi-people', aria: { hidden: true }), content_tag(:span, t('navigation.people'))]), organisation_people_path(current_organisation) %></li>
+ <% end %>
<% if show_billings %>
<li><%= link_to safe_join([content_tag(:i, '', class: 'bi bi-coin', aria: { hidden: true }), content_tag(:span, t('mobile.billings'))]), organisation_time_session_groups_path(current_organisation) %></li>
<% end %>
diff --git a/app/views/organisations/people/_detail.html.erb b/app/views/organisations/people/_detail.html.erb
new file mode 100644
index 0000000..d739022
--- /dev/null
+++ b/app/views/organisations/people/_detail.html.erb
@@ -0,0 +1,97 @@
+<%# locals: (person:) %>
+<%# One person: the fields, the link state, who created the row, the
+ history, and rows that may be the same person (read only). Edit and
+ delete only for those who may write (PersonPolicy). %>
+<% fields = %i[function department company email phone] %>
+<div class="people-detail space-y-6">
+ <div class="flex flex-wrap items-start gap-3">
+ <% if person.user %>
+ <%= render Neo::Users::AvatarComponent.new(user: person.user, size: :medium) %>
+ <% else %>
+ <%= render Neo::Users::AvatarComponent.new(user: nil, size: :medium, fallback_initials: person_initials(person.name)) %>
+ <% end %>
+ <div class="min-w-0 flex-1">
+ <h2 class="text-[22px] leading-snug font-bold text-heading"><%= person_display_name(person: person) %></h2>
+ <p class="text-sm text-muted">
+ <% if person.user %>
+ <%= t('views.organisations.people.show.linked_member', name: viewer_display_name(person.user)) %>
+ <% else %>
+ <%= t('views.organisations.people.show.no_account') %>
+ <% end %>
+ </p>
+ </div>
+ <% if policy(person).update? %>
+ <div class="flex shrink-0 items-center gap-2">
+ <%= render Neo::Buttons::ButtonComponent.new(variant: :secondary, size: :small, icon: 'pencil',
+ url: edit_organisation_person_path(@current_organisation, person)) do %>
+ <%= t('views.organisations.people.show.edit') %>
+ <% end %>
+ <%= render Neo::Buttons::ButtonComponent.new(
+ variant: :danger, size: :small, icon: 'trash',
+ form: { action: organisation_person_path(@current_organisation, person, list_state), method: :delete,
+ data: { turbo_frame: '_top' } },
+ confirm: t('views.organisations.people.show.delete_confirm'),
+ title: t('views.organisations.people.show.delete')
+ ) do %>
+ <%= t('views.organisations.people.show.delete') %>
+ <% end %>
+ </div>
+ <% end %>
+ </div>
+
+ <dl class="grid grid-cols-[max-content_1fr] gap-x-6 gap-y-2 text-sm">
+ <% fields.each do |field| %>
+ <% value = person.public_send(field) %>
+ <% next if value.blank? %>
+ <dt class="text-muted"><%= Person.human_attribute_name(field) %></dt>
+ <dd class="min-w-0 break-words text-heading">
+ <% if field == :email %>
+ <%= mail_to value %>
+ <% elsif field == :phone %>
+ <%= link_to value, "tel:#{value.gsub(/[^\d+]/, '')}" %>
+ <% else %>
+ <%= value %>
+ <% end %>
+ </dd>
+ <% end %>
+ </dl>
+
+ <% if person.notes.present? %>
+ <section>
+ <h3 class="mb-1 text-sm font-semibold text-heading"><%= Person.human_attribute_name(:notes) %></h3>
+ <p class="width-text whitespace-pre-line text-sm text-heading"><%= person.notes %></p>
+ </section>
+ <% end %>
+
+ <% duplicates = People::Directory.new(viewer: current_user, organisation: @current_organisation).duplicates_of(person) %>
+ <% if duplicates.any? %>
+ <section class="rounded-lg border border-cream-300 bg-cream-50 p-3">
+ <h3 class="mb-1 text-sm font-semibold text-heading"><%= t('views.organisations.people.show.duplicates_title') %></h3>
+ <ul class="space-y-1 text-sm">
+ <% duplicates.each do |entry| %>
+ <li>
+ <% if entry.person %>
+ <%= link_to person_display_name(person: entry.person, user: entry.user), organisation_person_path(@current_organisation, entry.person) %>
+ <% else %>
+ <%= viewer_display_name(entry.user) %>
+ <% end %>
+ <span class="text-muted">
+ (<%= entry.member? ? t('views.organisations.people.index.member_badge') : t('views.organisations.people.show.contact_label') %>)
+ </span>
+ </li>
+ <% end %>
+ </ul>
+ </section>
+ <% end %>
+
+ <p class="text-xs text-muted">
+ <% if person.creator %>
+ <%= t('views.organisations.people.show.created_by', name: viewer_display_name(person.creator),
+ date: l(person.created_at.to_date, format: :default)) %>
+ <% else %>
+ <%= t('views.organisations.people.show.created_at', date: l(person.created_at.to_date, format: :default)) %>
+ <% end %>
+ </p>
+
+ <%= render 'organisations/people/history', person: person %>
+</div>
diff --git a/app/views/organisations/people/_form.html.erb b/app/views/organisations/people/_form.html.erb
new file mode 100644
index 0000000..f150499
--- /dev/null
+++ b/app/views/organisations/people/_form.html.erb
@@ -0,0 +1,67 @@
+<%# locals: (person:, message: nil) %>
+<%# The form in the lane, new and edit. It leaves the frame (_top): a save
+ lands on the list with the person open, a refused save renders the page
+ again with this form and its reason. lock_version travels along, so a save
+ over someone else's change is refused instead of overwriting it. The list
+ state rides in hidden fields, so the list after a save keeps it. %>
+<% url = person.persisted? ? organisation_person_path(@current_organisation, person) : organisation_people_path(@current_organisation) %>
+<% input_class = 'block w-full py-2 px-3 border border-cream-300 rounded-lg bg-surface-raised focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink' %>
+<h2 class="text-[22px] leading-snug font-bold text-heading mb-4">
+ <%= person.persisted? ? t('views.organisations.people.form.edit_title') : t('views.organisations.people.form.new_title') %>
+</h2>
+
+<% if message.present? %>
+ <p class="mb-4 rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800" role="alert"><%= message %></p>
+<% end %>
+
+<%= form_with model: person, url: url, scope: :person, class: 'people-form space-y-4', data: { turbo_frame: '_top' } do |f| %>
+ <% list_state.each do |name, value| %>
+ <%= hidden_field_tag name, value %>
+ <% end %>
+ <% if person.persisted? %>
+ <%= f.hidden_field :lock_version %>
+ <% end %>
+
+ <div>
+ <%= f.label :user_id, Person.human_attribute_name(:user), class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.select :user_id, linkable_members_for(person).map { |user| [viewer_display_name(user), user.id] },
+ { include_blank: t('views.organisations.people.form.no_member') }, class: input_class %>
+ <p class="mt-1 text-xs text-muted"><%= t('views.organisations.people.form.member_hint') %></p>
+ </div>
+
+ <div>
+ <%= f.label :name, class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.text_field :name, class: input_class, maxlength: Person::MAX_FIELD_LENGTH %>
+ </div>
+
+ <% %i[function department company].each do |field| %>
+ <div>
+ <%= f.label field, class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.text_field field, class: input_class, maxlength: Person::MAX_FIELD_LENGTH %>
+ </div>
+ <% end %>
+
+ <div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
+ <div>
+ <%= f.label :email, class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.email_field :email, class: input_class, maxlength: Person::MAX_FIELD_LENGTH %>
+ </div>
+ <div>
+ <%= f.label :phone, class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.telephone_field :phone, class: input_class, maxlength: Person::MAX_FIELD_LENGTH %>
+ </div>
+ </div>
+
+ <div>
+ <%= f.label :notes, class: 'block text-sm font-medium text-cream-700 mb-1' %>
+ <%= f.text_area :notes, rows: 5, class: input_class, maxlength: Person::MAX_NOTES_LENGTH %>
+ </div>
+
+ <p class="text-xs text-muted"><i class="bi bi-eye" aria-hidden="true"></i> <%= t('views.organisations.people.form.shared_hint') %></p>
+
+ <div class="flex items-center gap-3">
+ <%= render Neo::Buttons::ButtonComponent.new(variant: :primary, size: :medium, type: 'submit') do %>
+ <%= t('views.organisations.people.form.save') %>
+ <% end %>
+ </div>
+<% end %>
diff --git a/app/views/organisations/people/_history.html.erb b/app/views/organisations/people/_history.html.erb
new file mode 100644
index 0000000..de78e33
--- /dev/null
+++ b/app/views/organisations/people/_history.html.erb
@@ -0,0 +1,18 @@
+<%# locals: (person:) %>
+<%# The history of one person: who created and changed the row and which
+ fields, never the values (PersonTrackable). Read straight from the row's
+ activities, like time_session_groups/_activities. %>
+<% activities = person.activities.includes(:actor).order(created_at: :desc).limit(20).to_a %>
+<% if activities.any? %>
+ <section>
+ <h3 class="mb-2 text-sm font-semibold text-heading"><%= t('views.organisations.people.history.title') %></h3>
+ <ul class="space-y-1 text-xs text-muted">
+ <% activities.each do |activity| %>
+ <li>
+ <time datetime="<%= activity.created_at.iso8601 %>"><%= l(activity.created_at, format: :short) %></time>
+ <span class="text-heading"><%= person_history_line(activity) %></span>
+ </li>
+ <% end %>
+ </ul>
+ </section>
+<% end %>
diff --git a/app/views/organisations/people/_index_desktop.html.erb b/app/views/organisations/people/_index_desktop.html.erb
new file mode 100644
index 0000000..e91dfcb
--- /dev/null
+++ b/app/views/organisations/people/_index_desktop.html.erb
@@ -0,0 +1,20 @@
+<%# locals: (list:, lane:, open:) %>
+<%# Desktop: list and lane side by side (NeoTwoColumnGridComponent, lane: true). %>
+<%= render NeoTwoColumnGridComponent.new(
+ selected_item: (open || nil),
+ context_type: :people,
+ css_classes: "#{open ? 'show-content' : 'hide-content'} hide-panel",
+ additional_targets: { "index-page-target" => "layout" },
+ chrome_height: NeoTwoColumnGridComponent::LANE_CHROME_HEIGHT_PX,
+ lane: true
+) do |grid| %>
+ <% grid.with_list do %>
+ <%= list %>
+ <% end %>
+
+ <% grid.with_main_content do %>
+ <turbo-frame id="<%= Organisations::PeopleController::DETAIL_FRAME_ID %>">
+ <%= lane %>
+ </turbo-frame>
+ <% end %>
+<% end %>
diff --git a/app/views/organisations/people/_index_mobile.html.erb b/app/views/organisations/people/_index_mobile.html.erb
new file mode 100644
index 0000000..b29d750
--- /dev/null
+++ b/app/views/organisations/people/_index_mobile.html.erb
@@ -0,0 +1,21 @@
+<%# locals: (list:, lane:, open:) %>
+<%# Mobile: the list, or the person (or the form) full screen with a way back,
+ as on the meetings pages. Same frame id as on the desktop. %>
+<div class="people-mobile-grid list">
+ <%= render NeoMobileTicketViewComponent.new(
+ selected_item: (open || nil),
+ show_detail: open,
+ back_url: organisation_people_path(@current_organisation, list_state),
+ back_label: t('views.organisations.people.index.back_to_list')
+ ) do |mobile| %>
+ <% mobile.with_list do %>
+ <%= list %>
+ <% end %>
+
+ <% mobile.with_detail do %>
+ <turbo-frame id="<%= Organisations::PeopleController::DETAIL_FRAME_ID %>">
+ <%= lane %>
+ </turbo-frame>
+ <% end %>
+ <% end %>
+</div>
diff --git a/app/views/organisations/people/_lane.html.erb b/app/views/organisations/people/_lane.html.erb
new file mode 100644
index 0000000..dadd2db
--- /dev/null
+++ b/app/views/organisations/people/_lane.html.erb
@@ -0,0 +1,18 @@
+<%# locals: (state:, person: nil, message: nil) %>
+<%# What the lane frame holds: a person (:detail), the form (:form, new or
+ edit), or nothing yet (:empty). Rendered by the index on a full visit and
+ alone for a frame request (show, new, edit, a lane request of the index). %>
+<div class="person-content min-w-0 relative">
+ <% if state == :detail %>
+ <%= render 'organisations/people/lane_head', closes: :lane %>
+ <%= render 'organisations/people/detail', person: person %>
+ <% elsif state == :form %>
+ <%= render 'organisations/people/lane_head', closes: (person.persisted? ? :edit : :new_form), person: person %>
+ <%= render 'organisations/people/form', person: person, message: message %>
+ <% else %>
+ <div id="person-display-placeholder" class="ticket-placeholder px-4 py-10 text-center">
+ <h2 class="text-lg font-semibold text-heading"><%= t('views.organisations.people.index.placeholder_title') %></h2>
+ <p class="text-sm text-muted"><%= t('views.organisations.people.index.placeholder_body') %></p>
+ </div>
+ <% end %>
+</div>
diff --git a/app/views/organisations/people/_lane_head.html.erb b/app/views/organisations/people/_lane_head.html.erb
new file mode 100644
index 0000000..6c6ed8e
--- /dev/null
+++ b/app/views/organisations/people/_lane_head.html.erb
@@ -0,0 +1,30 @@
+<%# locals: (closes:, person: nil) %>
+<%# The head of the lane: the type and the way out. An open person closes the
+ lane in place (layout-toggle); the new form leaves to the list, the edit
+ form goes back to its person. %>
+<% icon_button = 'inline-flex h-8 w-8 items-center justify-center rounded-md text-cream-500 transition-colors hover:bg-cream-200 hover:text-cream-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink' %>
+<div class="flex items-center gap-4 mb-2" data-lane-head data-lane-index-url="<%= organisation_people_path(@current_organisation) %>">
+ <span class="hidden lg:inline font-mono text-[13px] tracking-wide text-cream-500">
+ <%= t('views.organisations.people.show.type_label') %>
+ </span>
+ <div class="ml-auto">
+ <% if closes == :lane %>
+ <button type="button" class="<%= icon_button %> hidden lg:inline-flex"
+ title="<%= t('views.organisations.people.show.close') %>"
+ data-lane-close data-action="click->layout-toggle#closeContent">
+ <i class="bi bi-x-lg" aria-hidden="true"></i>
+ </button>
+ <% elsif closes == :edit %>
+ <%= link_to organisation_person_path(@current_organisation, person), class: "#{icon_button} inline-flex",
+ title: t('views.organisations.people.form.cancel') do %>
+ <i class="bi bi-x-lg" aria-hidden="true"></i>
+ <% end %>
+ <% else %>
+ <%= link_to organisation_people_path(@current_organisation, list_state), class: "#{icon_button} inline-flex",
+ title: t('views.organisations.people.show.close'),
+ data: { lane_close: true, turbo_frame: '_top' } do %>
+ <i class="bi bi-x-lg" aria-hidden="true"></i>
+ <% end %>
+ <% end %>
+ </div>
+</div>
diff --git a/app/views/organisations/people/_list_head.html.erb b/app/views/organisations/people/_list_head.html.erb
new file mode 100644
index 0000000..1433f4b
--- /dev/null
+++ b/app/views/organisations/people/_list_head.html.erb
@@ -0,0 +1,50 @@
+<%# locals: () %>
+<%# The head of the list: title box with the "+", the search and the three
+ filters (all, members, contacts). A search or a filter is a full visit of
+ the index; the open person travels along. %>
+<% frame_id = Organisations::PeopleController::DETAIL_FRAME_ID %>
+<%= render NeoTitleBoxComponent.new(title: t('views.organisations.people.index.title'), variant: :organisation) do |box| %>
+ <%# The "+" opens the form in the lane, only for those who may write. %>
+ <% if policy(Person).create? %>
+ <% box.with_title_action do %>
+ <%= render Neo::Buttons::IconButtonComponent.new(
+ variant: :primary,
+ icon: 'plus-lg',
+ size: :medium,
+ title: t('views.organisations.people.index.new_person'),
+ url: organisation_people_path(@current_organisation, list_state.merge('new' => Organisations::PeopleController::NEW_STATE)),
+ data: {
+ controller: 'lane-link',
+ action: 'click->lane-link#click',
+ lane_link_url_value: new_organisation_person_path(@current_organisation),
+ lane_link_frame_value: frame_id,
+ lane_link_set_value: { new: Organisations::PeopleController::NEW_STATE }.to_json,
+ lane_link_remove_value: %w[person_id].to_json,
+ lane_link_focus_value: '#person_name'
+ }
+ ) %>
+ <% end %>
+ <% end %>
+<% end %>
+
+<div class="people-list-head flex flex-wrap items-center gap-3 mb-4">
+ <%= form_with url: organisation_people_path(@current_organisation), method: :get, class: 'flex-1 min-w-48', data: { turbo_frame: '_top' } do %>
+ <%= hidden_field_tag :kind, list_state['kind'] if list_state['kind'] %>
+ <%= hidden_field_tag :person_id, params[:person_id] if params[:person_id].is_a?(String) %>
+ <label for="people-search" class="sr-only"><%= t('views.organisations.people.index.search_label') %></label>
+ <%= search_field_tag :q, list_state['q'], id: 'people-search', autocomplete: 'off',
+ placeholder: t('views.organisations.people.index.search_placeholder'),
+ class: 'block w-full py-2 px-4 border border-cream-300 rounded-lg bg-surface-raised focus:outline-none focus:border-ink focus:ring-1 focus:ring-ink' %>
+ <% end %>
+
+ <nav class="flex items-center gap-2" aria-label="<%= t('views.organisations.people.index.filter_label') %>">
+ <% People::Directory::KINDS.each do |kind| %>
+ <% active = (list_state['kind'] || 'all') == kind %>
+ <%= link_to t("views.organisations.people.index.kinds.#{kind}"),
+ organisation_people_path(@current_organisation, list_state.merge('kind' => (kind == 'all' ? nil : kind)).compact),
+ class: "inline-flex items-center rounded-full border px-3 py-1 text-sm #{active ? 'border-ink bg-ink text-cream-50' : 'border-cream-300 text-cream-700 hover:bg-cream-100'}",
+ 'aria-current': (active ? 'true' : nil),
+ data: { turbo_frame: '_top' } %>
+ <% end %>
+ </nav>
+</div>
diff --git a/app/views/organisations/people/_results.html.erb b/app/views/organisations/people/_results.html.erb
new file mode 100644
index 0000000..9822130
--- /dev/null
+++ b/app/views/organisations/people/_results.html.erb
@@ -0,0 +1,24 @@
+<%# locals: (entries:, selected: nil) %>
+<%# The rows of the directory (People::Directory). A row with a person row
+ opens it in the lane (list-row); a member without one is plain text, with
+ "Angaben ergänzen" for those who may write. %>
+<turbo-frame id="<%= Organisations::PeopleController::LIST_FRAME_ID %>">
+ <% if entries.empty? %>
+ <div class="flex items-center justify-center min-h-[40vh]">
+ <% if list_state.any? %>
+ <%= render 'shared/empty_content', variant: :no_results, icon_class: 'bi bi-search',
+ title: t('views.organisations.people.index.empty_no_results') %>
+ <% else %>
+ <%= render 'shared/empty_content', variant: :first_time, icon_class: 'bi bi-people',
+ title: t('views.organisations.people.index.empty_title'),
+ description: t('views.organisations.people.index.empty_description') %>
+ <% end %>
+ </div>
+ <% else %>
+ <ul class="people-list divide-y divide-cream-200">
+ <% entries.each do |entry| %>
+ <%= render 'organisations/people/row', entry: entry, selected: selected %>
+ <% end %>
+ </ul>
+ <% end %>
+</turbo-frame>
diff --git a/app/views/organisations/people/_row.html.erb b/app/views/organisations/people/_row.html.erb
new file mode 100644
index 0000000..0c7e4ff
--- /dev/null
+++ b/app/views/organisations/people/_row.html.erb
@@ -0,0 +1,46 @@
+<%# locals: (entry:, selected: nil) %>
+<% person = entry.person %>
+<% name = person_display_name(person: person, user: entry.user) %>
+<% row_data = if person
+ { controller: 'list-row', action: 'click->list-row#click', person_id: person.id,
+ list_row_url_value: organisation_person_path(@current_organisation, person),
+ list_row_id_value: person.id, list_row_param_value: 'person_id',
+ list_row_params_value: %w[person_id].to_json,
+ list_row_frame_value: Organisations::PeopleController::DETAIL_FRAME_ID }
+ else
+ {}
+ end %>
+<%= tag.li data: row_data, tabindex: (person ? -1 : nil),
+ class: "people-row flex items-center gap-3 px-3 py-2.5 #{'cursor-pointer hover:bg-cream-100' if person} #{'selected-row' if person && selected&.id == person.id}" do %>
+ <% if entry.user %>
+ <%= render Neo::Users::AvatarComponent.new(user: entry.user, size: :small) %>
+ <% else %>
+ <%= render Neo::Users::AvatarComponent.new(user: nil, size: :small, fallback_initials: person_initials(name)) %>
+ <% end %>
+ <div class="min-w-0 flex-1">
+ <div class="flex min-w-0 items-center gap-2">
+ <span class="truncate text-sm font-medium text-heading"><%= name %></span>
+ <% if entry.member? %>
+ <span class="shrink-0 rounded border border-cream-300 px-1.5 text-[11px] text-cream-600"><%= t('views.organisations.people.index.member_badge') %></span>
+ <% end %>
+ </div>
+ <% meta = [person&.function, person&.company].compact_blank %>
+ <% if meta.any? %>
+ <p class="truncate text-xs text-muted"><%= meta.join(' · ') %></p>
+ <% end %>
+ </div>
+ <% if person.nil? && policy(Person).create? %>
+ <%= link_to t('views.organisations.people.index.add_details'),
+ organisation_people_path(@current_organisation, list_state.merge('new' => Organisations::PeopleController::NEW_STATE,
+ 'user_id' => entry.user.id)),
+ class: 'shrink-0 text-xs text-cobalt-600 hover:underline',
+ data: {
+ controller: 'lane-link',
+ action: 'click->lane-link#click',
+ lane_link_url_value: new_organisation_person_path(@current_organisation, user_id: entry.user.id),
+ lane_link_frame_value: Organisations::PeopleController::DETAIL_FRAME_ID,
+ lane_link_set_value: { new: Organisations::PeopleController::NEW_STATE }.to_json,
+ lane_link_remove_value: %w[person_id].to_json
+ } %>
+ <% end %>
+<% end %>
diff --git a/app/views/organisations/people/index.html.erb b/app/views/organisations/people/index.html.erb
new file mode 100644
index 0000000..33b2e39
--- /dev/null
+++ b/app/views/organisations/people/index.html.erb
@@ -0,0 +1,29 @@
+<%# The people directory (Organisations::PeopleController): the list on the
+ left, the person or the form in the lane on the right, the shape of
+ "Alle Meetings" without its filter bar. layout-toggle and index-page own
+ the address (?person_id=, ?new=person); a save leaves the lane and lands
+ here again with the saved person open. %>
+<% content_for :head do %>
+ <meta name="turbo-cache-control" content="no-cache">
+<% end %>
+
+<% lane_state = if @form_person then :form elsif @lane_person then :detail end %>
+<% lane_person = @form_person || @lane_person %>
+
+<div class="labor-layout-view people-page <%= 'show-content' if lane_state %> hide-panel"
+ <%= tag.attributes(data: people_page_data(viewport_mode: @viewport_mode, selected: @lane_person,
+ form_open: @form_person.present?)) %>>
+ <% list = capture do %>
+ <%= render 'organisations/people/list_head' %>
+ <%= render 'organisations/people/results', entries: @entries, selected: @lane_person %>
+ <% end %>
+ <% lane = capture do %>
+ <%= render 'organisations/people/lane', state: lane_state || :empty, person: lane_person, message: @form_message %>
+ <% end %>
+
+ <% if @viewport_mode == 'mobile' %>
+ <%= render 'organisations/people/index_mobile', list: list, lane: lane, open: lane_state.present? %>
+ <% else %>
+ <%= render 'organisations/people/index_desktop', list: list, lane: lane, open: lane_state.present? %>
+ <% end %>
+</div>
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 45c90cb..b6c196f 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -1488,6 +1488,7 @@ de:
delimiter: "."
navigation:
all_meetings: Alle Meetings
+ people: Personen
all_organisations: Alle Organisationen
all_projects: Alle Projekte
times: Zeiten
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 893d1b7..11fdc13 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -1382,6 +1382,7 @@ en:
delimiter: ","
navigation:
all_meetings: All Meetings
+ people: People
all_organisations: All organisations
all_projects: All Projects
times: Times
diff --git a/config/locales/views/personen.de.yml b/config/locales/views/personen.de.yml
new file mode 100644
index 0000000..1e41570
--- /dev/null
+++ b/config/locales/views/personen.de.yml
@@ -0,0 +1,59 @@
+---
+de:
+ controllers:
+ people:
+ not_found: "Diese Person gibt es nicht."
+ link_not_allowed: "Dieses Mitglied lässt sich nicht verknüpfen."
+ create:
+ success: "Person angelegt."
+ update:
+ success: "Person gespeichert."
+ stale: "Jemand anderes hat diese Person inzwischen geändert. Unten stehen die aktuellen Angaben, bitte noch einmal ändern."
+ destroy:
+ success: "Person gelöscht."
+ views:
+ organisations:
+ people:
+ index:
+ title: "Personen"
+ new_person: "Person anlegen"
+ search_label: "Personen durchsuchen"
+ search_placeholder: "Name, Funktion, Firma, E-Mail …"
+ filter_label: "Anzeigen"
+ kinds:
+ all: "Alle"
+ members: "Mitglieder"
+ contacts: "Kontakte"
+ member_badge: "Mitglied"
+ add_details: "Angaben ergänzen"
+ placeholder_title: "Keine Person gewählt"
+ placeholder_body: "Wähle links eine Person aus."
+ empty_title: "Noch keine Personen"
+ empty_description: "Mitglieder der Organisation erscheinen hier von selbst. Personen ohne Konto legst du mit dem Plus an."
+ empty_no_results: "Keine Person passt zur Suche."
+ back_to_list: "Personen"
+ show:
+ type_label: "PERSON"
+ close: "Schließen"
+ edit: "Bearbeiten"
+ delete: "Löschen"
+ delete_confirm: "Diese Person wirklich löschen? Die Angaben sind danach weg."
+ linked_member: "Mitglied: %{name}"
+ no_account: "Kein Konto"
+ contact_label: "Kontakt"
+ duplicates_title: "Gleicher Name"
+ created_by: "Angelegt von %{name} am %{date}"
+ created_at: "Angelegt am %{date}"
+ form:
+ new_title: "Person anlegen"
+ edit_title: "Person bearbeiten"
+ no_member: "Kein Mitglied"
+ member_hint: "Mit einem Mitglied verknüpft, zeigt die Liste den Namen aus seinem Konto."
+ shared_hint: "Alle mit Zugriff auf Personen sehen diese Angaben, auch die Kundenseite."
+ save: "Speichern"
+ cancel: "Abbrechen"
+ history:
+ title: "Verlauf"
+ created: "%{actor} hat die Person angelegt"
+ updated: "%{actor} hat %{fields} geändert"
+ other: "%{actor} hat die Person geändert"
diff --git a/config/locales/views/personen.en.yml b/config/locales/views/personen.en.yml
new file mode 100644
index 0000000..f59d3e1
--- /dev/null
+++ b/config/locales/views/personen.en.yml
@@ -0,0 +1,59 @@
+---
+en:
+ controllers:
+ people:
+ not_found: "This person does not exist."
+ link_not_allowed: "This member cannot be linked."
+ create:
+ success: "Person added."
+ update:
+ success: "Person saved."
+ stale: "Someone else changed this person in the meantime. The current details are shown below, please make your change again."
+ destroy:
+ success: "Person deleted."
+ views:
+ organisations:
+ people:
+ index:
+ title: "People"
+ new_person: "Add person"
+ search_label: "Search people"
+ search_placeholder: "Name, function, company, email …"
+ filter_label: "Show"
+ kinds:
+ all: "All"
+ members: "Members"
+ contacts: "Contacts"
+ member_badge: "Member"
+ add_details: "Add details"
+ placeholder_title: "No person selected"
+ placeholder_body: "Pick a person on the left."
+ empty_title: "No people yet"
+ empty_description: "Members of the organisation show up here on their own. Add people without an account with the plus."
+ empty_no_results: "No person matches the search."
+ back_to_list: "People"
+ show:
+ type_label: "PERSON"
+ close: "Close"
+ edit: "Edit"
+ delete: "Delete"
+ delete_confirm: "Really delete this person? The details will be gone."
+ linked_member: "Member: %{name}"
+ no_account: "No account"
+ contact_label: "Contact"
+ duplicates_title: "Same name"
+ created_by: "Added by %{name} on %{date}"
+ created_at: "Added on %{date}"
+ form:
+ new_title: "Add person"
+ edit_title: "Edit person"
+ no_member: "No member"
+ member_hint: "When linked to a member, the list shows the name from their account."
+ shared_hint: "Everyone with access to people sees these details, the customer's side too."
+ save: "Save"
+ cancel: "Cancel"
+ history:
+ title: "History"
+ created: "%{actor} added the person"
+ updated: "%{actor} changed %{fields}"
+ other: "%{actor} changed the person"
diff --git a/config/routes.rb b/config/routes.rb
index 82c22c8..9e2188b 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -326,6 +326,12 @@ Rails.application.routes.draw do
# project-nested MeetingsController (which is bound to @project).
get 'meetings', to: 'meetings_overview#index', as: :meetings
+ # The shared people directory of the organisation (Person): one page with a
+ # lane, the list on the left, the person or the form in the lane. show, new
+ # and edit answer the lane frame; a full visit lands on the index with
+ # ?person_id= or ?new=person.
+ resources :people
+
# The column picker of "Alle Meetings" saves the overview's base view here:
# the controller of the project route (view_configuration under a project),
# without a project. The path default pins the list type; a view_type in the
diff --git a/spec/requests/organisations/people_spec.rb b/spec/requests/organisations/people_spec.rb
new file mode 100644
index 0000000..9960ee3
--- /dev/null
+++ b/spec/requests/organisations/people_spec.rb
@@ -0,0 +1,308 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# The people directory page and its writes. Every action against the right
+# (PersonPolicy, D7): 403 without it, view_people reads but never writes,
+# manage_people writes (a guest role too), an account admin needs no row, and
+# another organisation answers 404.
+RSpec.describe 'Organisations::People', :ci_guard, type: :request do
+ let(:organisation) { create(:organisation) }
+ let(:other_organisation) { create(:organisation) }
+
+ before { ActsAsTenant.current_tenant = organisation }
+ after { ActsAsTenant.current_tenant = nil }
+
+ def role_with(*actions, billable: true, title: nil)
+ role = create(:role, organisation: organisation, billable: billable, **{ title: title }.compact)
+ actions.each { |action| create(:permission, role: role, category: 'people', action: action, allowed: true) }
+ role
+ end
+
+ def member_with(role, first_name: 'Max')
+ user = create(:user, first_name: first_name, last_name: "Muster#{SecureRandom.hex(2)}")
+ create(:membership, user: user, organisation: organisation, role: role, active: true)
+ user
+ end
+
+ let(:admin) { member_with(role_with(title: Role::ACCOUNT_ADMIN_TITLE)) }
+ let(:viewer) { member_with(role_with('view_people')) }
+ let(:manager) { member_with(role_with('manage_people')) }
+ let(:guest_manager) { member_with(role_with('manage_people', billable: false)) }
+ let(:nobody) { member_with(role_with) }
+ let!(:person) { create(:person, organisation: organisation, name: 'Doris Dienstleister', phone: '+49 30 1234567') }
+
+ let(:frame_headers) { { 'Turbo-Frame' => Organisations::PeopleController::DETAIL_FRAME_ID } }
+ let(:valid_params) { { person: { name: 'Erika Beispiel', function: 'Administratorin' } } }
+
+ describe 'without the right' do
+ before { sign_in nobody }
+
+ it 'answers 403 on every action and changes nothing' do
+ get organisation_people_path(organisation)
+ expect(response).to have_http_status(:forbidden)
+
+ get organisation_person_path(organisation, person), headers: frame_headers
+ expect(response).to have_http_status(:forbidden)
+
+ get new_organisation_person_path(organisation), headers: frame_headers
+ expect(response).to have_http_status(:forbidden)
+
+ get edit_organisation_person_path(organisation, person), headers: frame_headers
+ expect(response).to have_http_status(:forbidden)
+
+ expect { post organisation_people_path(organisation), params: valid_params }.not_to change(Person, :count)
+ expect(response).to have_http_status(:forbidden)
+
+ patch organisation_person_path(organisation, person), params: { person: { phone: '0' } }
+ expect(response).to have_http_status(:forbidden)
+
+ expect { delete organisation_person_path(organisation, person) }.not_to change(Person, :count)
+ expect(response).to have_http_status(:forbidden)
+ expect(person.reload.phone).to eq('+49 30 1234567')
+ end
+
+ it 'shows no menu entry in the sidebar' do
+ get organisation_root_path(organisation)
+ follow_redirect! while response.redirect?
+
+ expect(response.body).to include(I18n.t('navigation.all_organisations'))
+ expect(response.body).not_to include(organisation_people_path(organisation))
+ end
+
+ it 'shows no entry on the mobile "more" page' do
+ get organisation_mobile_more_path(organisation)
+
+ expect(response.body).to include(I18n.t('mobile.more'))
+ expect(response.body).not_to include(organisation_people_path(organisation))
+ end
+ end
+
+ describe 'with view_people only' do
+ before { sign_in viewer }
+
+ it 'shows the list and the person, without write controls' do
+ get organisation_people_path(organisation, person_id: person.id)
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('Doris Dienstleister', '+49 30 1234567')
+ expect(response.body).not_to include(new_organisation_person_path(organisation))
+ expect(response.body).not_to include(edit_organisation_person_path(organisation, person))
+ end
+
+ it 'shows the person in the lane frame' do
+ get organisation_person_path(organisation, person), headers: frame_headers
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include(%(<turbo-frame id="#{Organisations::PeopleController::DETAIL_FRAME_ID}">), 'Doris Dienstleister')
+ end
+
+ it 'is refused every write with 403' do
+ expect { post organisation_people_path(organisation), params: valid_params }.not_to change(Person, :count)
+ expect(response).to have_http_status(:forbidden)
+
+ patch organisation_person_path(organisation, person), params: { person: { phone: '0' } }
+ expect(response).to have_http_status(:forbidden)
+
+ expect { delete organisation_person_path(organisation, person) }.not_to change(Person, :count)
+ expect(response).to have_http_status(:forbidden)
+
+ get new_organisation_person_path(organisation), headers: frame_headers
+ expect(response).to have_http_status(:forbidden)
+ end
+
+ it 'shows the menu entry in the sidebar' do
+ get organisation_root_path(organisation)
+ follow_redirect! while response.redirect?
+
+ expect(response.body).to include(%(href="#{organisation_people_path(organisation)}"), I18n.t('navigation.people'))
+ end
+
+ it 'shows the entry on the mobile "more" page' do
+ get organisation_mobile_more_path(organisation)
+
+ expect(response.body).to include(%(href="#{organisation_people_path(organisation)}"))
+ end
+ end
+
+ shared_examples 'may write' do
+ it 'creates a person and lands on the list with it open' do
+ expect { post organisation_people_path(organisation), params: valid_params.merge(q: 'erika') }.to change(Person, :count).by(1)
+
+ created = Person.find_by!(name: 'Erika Beispiel')
+ expect(response).to redirect_to(organisation_people_path(organisation, person_id: created.id, q: 'erika'))
+ expect(created.creator_id).to eq(writer.id)
+ end
+
+ it 'updates a person' do
+ patch organisation_person_path(organisation, person),
+ params: { person: { phone: '0', lock_version: person.lock_version } }
+
+ expect(response).to redirect_to(organisation_people_path(organisation, person_id: person.id))
+ expect(person.reload.phone).to eq('0')
+ end
+
+ it 'deletes a person' do
+ expect { delete organisation_person_path(organisation, person) }.to change(Person, :count).by(-1)
+ expect(response).to redirect_to(organisation_people_path(organisation))
+ end
+
+ it 'opens the form in the lane' do
+ get new_organisation_person_path(organisation), headers: frame_headers
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('id="person_name"', I18n.t('views.organisations.people.form.shared_hint'))
+ end
+ end
+
+ describe 'with manage_people' do
+ let(:writer) { manager }
+
+ before { sign_in manager }
+
+ include_examples 'may write'
+ end
+
+ describe 'a guest role (billable: false) with manage_people' do
+ let(:writer) { guest_manager }
+
+ before { sign_in guest_manager }
+
+ include_examples 'may write'
+ end
+
+ describe 'an account admin without any permission row' do
+ let(:writer) { admin }
+
+ before do
+ expect(Permission.where(category: 'people', role: admin.memberships.first.role)).to be_empty
+ sign_in admin
+ end
+
+ include_examples 'may write'
+ end
+
+ describe 'another organisation' do
+ let(:foreign_person) do
+ ActsAsTenant.with_tenant(other_organisation) { create(:person, organisation: other_organisation) }
+ end
+
+ before { sign_in admin }
+
+ # One request per example: after a 404 the test session is signed out.
+ it 'answers 404 for show of a person of another organisation' do
+ get organisation_person_path(organisation, foreign_person), headers: frame_headers
+
+ expect(response).to have_http_status(:not_found)
+ end
+
+ it 'answers 404 for update and leaves the row alone' do
+ patch organisation_person_path(organisation, foreign_person), params: { person: { phone: '0' } }
+
+ expect(response).to have_http_status(:not_found)
+ expect(Person.unscoped.find(foreign_person.id).phone).to be_nil
+ end
+
+ it 'answers 404 for destroy and keeps the row' do
+ delete organisation_person_path(organisation, foreign_person)
+
+ expect(response).to have_http_status(:not_found)
+ expect(Person.unscoped.exists?(foreign_person.id)).to be(true)
+ end
+
+ # The app's rule for an organisation the user is not a member of (every
+ # page, ApplicationController#load_tenant_from_session): to the picker,
+ # nothing of the other organisation rendered.
+ it 'sends the page of an organisation the user is not in to the organisation picker' do
+ foreign_person
+ get organisation_people_path(other_organisation)
+
+ expect(response).to redirect_to(select_organisation_path)
+ end
+ end
+
+ describe 'the lane' do
+ before { sign_in manager }
+
+ it 'opens a person on a full visit with ?person_id=' do
+ get organisation_people_path(organisation, person_id: person.id)
+
+ expect(response.body).to include('show-content', 'Doris Dienstleister', 'selected-row')
+ end
+
+ it 'opens the form on a full visit with ?new=person' do
+ get organisation_people_path(organisation, new: 'person')
+
+ expect(response.body).to include('id="person_name"')
+ end
+
+ it 'answers a lane request of the index with the lane alone' do
+ get organisation_people_path(organisation, person_id: person.id), headers: frame_headers
+
+ expect(response.body).to start_with(%(<turbo-frame id="#{Organisations::PeopleController::DETAIL_FRAME_ID}">))
+ expect(response.body).to include('Doris Dienstleister')
+ end
+
+ it 'sends a full visit of show to the index with the person open' do
+ get organisation_person_path(organisation, person)
+
+ expect(response).to redirect_to(organisation_people_path(organisation, person_id: person.id))
+ end
+
+ it 'renders the mobile list and detail one after the other' do
+ get organisation_people_path(organisation, person_id: person.id, viewport: 'mobile')
+
+ expect(response).to have_http_status(:ok)
+ expect(response.body).to include('people-mobile-grid', 'Doris Dienstleister')
+ end
+
+ it 'shows the form again with the reason when the save is refused' do
+ post organisation_people_path(organisation), params: { person: { name: '' } }
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(response.body).to include('id="person_name"')
+ end
+
+ it 'shows the current values and the stale message when someone else saved first' do
+ stale_version = person.lock_version
+ person.update!(phone: 'from the other side')
+
+ patch organisation_person_path(organisation, person), params: { person: { phone: 'mine', lock_version: stale_version } }
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(response.body).to include(CGI.escapeHTML(I18n.t('controllers.people.update.stale')), 'from the other side')
+ expect(person.reload.phone).to eq('from the other side')
+ end
+
+ it 'shows a duplicate hint for a row with the same name' do
+ twin = create(:person, organisation: organisation, name: 'doris DIENSTLEISTER')
+
+ get organisation_person_path(organisation, person), headers: frame_headers
+
+ expect(response.body).to include(I18n.t('views.organisations.people.show.duplicates_title'),
+ organisation_person_path(organisation, twin))
+ end
+
+ it 'lists the history without values' do
+ patch organisation_person_path(organisation, person), params: { person: { phone: '0', lock_version: person.lock_version } }
+
+ get organisation_person_path(organisation, person), headers: frame_headers
+
+ expect(response.body).to include(I18n.t('views.organisations.people.history.title'))
+ end
+
+ it 'filters and searches the list' do
+ get organisation_people_path(organisation, kind: 'contacts', q: 'dienst')
+
+ expect(response.body).to include('Doris Dienstleister')
+ expect(response.body).not_to include(CGI.escapeHTML(manager.display_name))
+ end
+ end
+
+ it 'has no missing translation on the page' do
+ sign_in admin
+ get organisation_people_path(organisation, person_id: person.id)
+
+ expect(response.body).not_to include('translation missing', 'Translation missing')
+ end
+end