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.
Ruby agplai-assistantdockerdsgvogdprhotwireissue-trackerjira-alternativeknowledge-basellmmcp-servermeeting-notesopen-sourceproject-managementredmine-alternativeruby-on-railsself-hostedticketingtime-tracking
Offer "move to another project" in the meeting lane
Guido Boyke7873714c8998
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex 3e42c46..41e757b 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -597,6 +597,8 @@ jobs:spec/requests/organisations/meetings_overview_spec.rbspec/requests/organisations/meetings_overview_access_spec.rbspec/requests/organisations/meetings_overview_views_spec.rb+ spec/requests/organisations/meeting_move_spec.rb+ spec/services/actors/move_meeting_spec.rbspec/requests/organisations/meetings_overview_columns_spec.rbspec/requests/organisations/meetings_overview_lane_spec.rbspec/requests/organisations/meetings_overview_lane_access_spec.rbdiff --git a/app/controllers/concerns/project_controller.rb b/app/controllers/concerns/project_controller.rbindex e9ddba0..9823ffd 100644--- a/app/controllers/concerns/project_controller.rb+++ b/app/controllers/concerns/project_controller.rb@@ -95,8 +95,10 @@ module ProjectController# at this concern layer, exactly like create_summary/detect_participants.# regenerate (chatposts) persists a style nudge and enqueues a paid LLM job —# same fail-closed rule (Actors C1 review).+ # move_preflight/move: moving a meeting into another project needs write+ # access to the project it leaves (its dialog too, it offers only that).write_actions = %w[new create edit update destroy create_summary detect_participants- run accept dismiss regenerate]+ run accept dismiss regenerate move_preflight move]write_actions.include?(action_name) ? :write : :readenddiff --git a/app/controllers/organisations/meetings_controller.rb b/app/controllers/organisations/meetings_controller.rbindex 9b6106a..aaf492d 100644--- a/app/controllers/organisations/meetings_controller.rb+++ b/app/controllers/organisations/meetings_controller.rb@@ -17,7 +17,7 @@ module Organisations# viewport: the edit link + form carry viewport so the round-trip preserves it.# Since #817 _meeting_show has no viewport branch of its own any more.before_action :set_viewport_mode, only: %i[index show new create edit update]- before_action :set_meeting, only: %i[show edit update destroy create_summary toggle_search]+ before_action :set_meeting, only: %i[show edit update destroy create_summary toggle_search move_preflight move]before_action :redirect_organisation_list_page, only: %i[index show new]# The same literal ids live in the meetings views and the shared list-row@@ -271,6 +271,37 @@ module Organisationsendend+ # GET /projects/:project_id/meetings/:id/move_preflight+ # The "move" dialog (doc/meeting_verschieben_plan.md) as the content of its+ # frame (README_MODAL_PATTERN.md): what moves with the meeting, the target+ # projects, or why it cannot move. Each opening carries a token of its own.+ def move_preflight+ authorize @meeting, :move?++ token = SecureRandom.hex(8)+ render html: helpers.turbo_frame_tag(helpers.meeting_move_modal_id(@meeting)) {+ helpers.render(partial: 'organisations/meetings/move_modal', locals: move_modal_locals(token))+ }.html_safe, layout: false+ end++ # POST /projects/:project_id/meetings/:id/move+ # The write is Actors::MoveMeeting's. The target comes from the projects the+ # dialog offers, so another organisation's project, an archived one and one+ # without meetings write access are not found. A success opens the meeting+ # in its new project (or keeps "Alle Meetings", where it is still listed);+ # a refusal replaces exactly this opening of the dialog with the message.+ def move+ authorize @meeting, :move?++ target = move_target_projects.find_by(id: params[:target_project_id])+ return render_move_refusal([t('services.actors.move_meeting.forbidden_target')]) unless target++ result = Actors::MoveMeeting.call(meeting: @meeting, target_project: target, current_user: current_user)+ return render_move_refusal(result.errors) unless result.success?++ redirect_to moved_meeting_path(target), notice: t('flash.meetings.moved', project: target.name), status: :see_other+ end+# POST /projects/:project_id/meetings/detect_participants# LLM leg of the participant detection (Slice 5, plan decision 12): runs# BEFORE save on the flat `transcript` param — no persisted meeting, so@@ -399,6 +430,50 @@ module Organisationslatest.values.map { |display| { display_name: display } }end+ # The projects a meeting of this project may move to: active, not this one,+ # and with meetings write access (the same reach the participant claims use).+ def move_target_projects+ writable = AccessCheck::ProjectAccessService.writable_meetings_project_ids(current_user, @current_organisation)+ policy_scope(Project).active.where(id: writable).where.not(id: @project.id).order(:name)+ end++ # The counts of the dialog do not depend on the target, so the preflight is+ # asked before one is chosen, with this project standing in for it.+ def move_modal_locals(token, errors: [])+ { meeting: @meeting, token: token, errors: errors, targets: move_target_projects,+ impact: Actors::MoveMeeting.new(meeting: @meeting, target_project: @project, current_user: current_user).preflight }+ end++ # The token names one opening of the dialog; it is echoed into an id, so only+ # the shape the dialog itself creates is taken back.+ def move_modal_token+ token = params[:modal_token].to_s+ token.match?(/\A\h{1,32}\z/) ? token : SecureRandom.hex(8)+ end++ def render_move_refusal(errors)+ respond_to do |format|+ format.turbo_stream do+ token = move_modal_token+ render turbo_stream: turbo_stream.replace(helpers.meeting_move_modal_instance_id(@meeting, token),+ partial: 'organisations/meetings/move_modal',+ locals: move_modal_locals(token, errors: errors)),+ status: :unprocessable_content+ end+ format.html do+ redirect_to meeting_list_index_path(meeting_index_query.merge(meeting_id: @meeting.id)), alert: errors.to_sentence+ end+ end+ end++ # "Alle Meetings" still lists the moved meeting; the project page does not,+ # so the meeting opens in the list of its new project.+ def moved_meeting_path(target)+ return meeting_list_index_path(meeting_index_query.merge(meeting_id: @meeting.id)) if meeting_organisation_list?++ organisation_project_meetings_path(@current_organisation, target, meeting_id: @meeting.id)+ end+def set_meeting# Scoped to @project.meetings: a foreign-project (or foreign-tenant) id is# simply not found → 404, which rejects cross-project/tenant access.diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rbindex 9bb6b95..6697bad 100644--- a/app/helpers/meetings_helper.rb+++ b/app/helpers/meetings_helper.rb@@ -20,6 +20,20 @@ module MeetingsHelpermeeting_list_state.merge(Meetings::ListState.context_query(organisation: meeting_organisation_list?))end+ # The "move" dialog (README_MODAL_PATTERN.md): the empty frame in the lane+ # head, one opening inside it (its token), and the trigger the focus returns to.+ def meeting_move_modal_id(meeting)+ "meeting-move-modal-#{meeting.id}"+ end++ def meeting_move_modal_instance_id(meeting, token)+ "#{meeting_move_modal_id(meeting)}-#{token}"+ end++ def meeting_move_trigger_id(meeting)+ "meeting-move-trigger-#{meeting.id}"+ end+def meeting_list_hidden_fieldssafe_join(URI.decode_www_form(meeting_lane_state.to_query).map { |key, value| hidden_field_tag(key, value) })enddiff --git a/app/javascript/controllers/meeting_move_modal_controller.js b/app/javascript/controllers/meeting_move_modal_controller.jsnew file mode 100644index 0000000..d092e98--- /dev/null+++ b/app/javascript/controllers/meeting_move_modal_controller.js@@ -0,0 +1,101 @@+import { Controller } from "@hotwired/stimulus"+import { trapTabKey } from "dialog_a11y"++/**+ * Meeting Move Modal Controller+ *+ * The "move" dialog of a meeting (doc/meeting_verschieben_plan.md). It is the CONTENT of+ * the frame #meeting-move-modal-<id> in the lane head: the trigger loads+ * meetings#move_preflight into the frame, and this controller connecting is the dialog+ * opening. Each opening has a token of its own: a refused move replaces exactly this+ * element, and a late answer to a dialog closed meanwhile finds nothing.+ *+ * Built after README_MODAL_PATTERN.md from its reference implementation,+ * ticket_relation_modal_controller.js, without that dialog's own fields. The frame keeps+ * where the focus goes back, because a refused move swaps the instance.+ */+export default class extends Controller {+ static targets = ["card", "first"]+ // returnId: the trigger in the lane head, when the focused element has no id.+ static values = { returnId: String }++ connect() {+ this.frame = this.element.closest("turbo-frame")+ // The lane was closed while the dialog was loading: nobody could see or close it,+ // and it would still lock the page's scrolling. It discards itself instead.+ if (!this.shown()) {+ this.discarded = true+ this.close()+ return+ }+ if (this.frame && !this.frame.dataset.moveModalReturn) {+ this.frame.dataset.moveModalReturn = (document.activeElement && document.activeElement.id) || this.returnIdValue+ }+ document.body.classList.add("overflow-hidden")+ if (this.hasFirstTarget) this.firstTarget.focus()+ }++ // Removed by a close or by a refused move that brings the next instance.+ disconnect() {+ if (this.discarded) return++ document.body.classList.remove("overflow-hidden")+ const frame = this.frame+ if (!frame) return++ // The next trigger loads the dialog fresh.+ frame.removeAttribute("src")+ // After the mutation is done: a refused move has put its new instance in by then.+ setTimeout(() => this.returnFocus(frame), 0)+ }++ // On screen means: the block around the frame is rendered AND has a size. A shut lane+ // is a 0px grid track with overflow hidden, which checkVisibility() alone takes for+ // visible (see ticket_relation_modal_controller.js).+ shown() {+ const host = this.frame ? this.frame.parentElement : this.element.parentElement+ if (!host) return false+ if (typeof host.checkVisibility === "function" && !host.checkVisibility({ visibilityProperty: true })) return false++ const box = host.getBoundingClientRect()+ return box.width > 0 && box.height > 0+ }++ returnFocus(frame) {+ if (frame.querySelector('[data-controller~="meeting-move-modal"]')) return++ const id = frame.dataset.moveModalReturn+ delete frame.dataset.moveModalReturn+ const lost = !document.activeElement || document.activeElement === document.body+ const target = id && document.getElementById(id)+ if (lost && target) target.focus()+ }++ close() {+ if (this.frame) {+ this.frame.removeAttribute("src")+ this.frame.innerHTML = ""+ } else {+ this.element.remove()+ }+ }++ closeOnBackdrop(event) {+ if (event.target === event.currentTarget) this.close()+ }++ // Escape owner (lib/escape_owner.js): the lane behind stays open while this is true.+ // The dialog is the content of its frame: it stands in the page only while open.+ ownsEscape() {+ return true+ }++ closeOnEscape(event) {+ if (event.key === "Escape" && !event.defaultPrevented) this.close()+ }++ // Keyboard must not wander into the page behind an aria-modal dialog.+ trapFocus(event) {+ if (this.hasCardTarget) trapTabKey(event, this.cardTarget)+ }+}diff --git a/app/views/organisations/meetings/_lane_head.html.erb b/app/views/organisations/meetings/_lane_head.html.erbindex 8bd7bf8..c109765 100644--- a/app/views/organisations/meetings/_lane_head.html.erb+++ b/app/views/organisations/meetings/_lane_head.html.erb@@ -41,6 +41,22 @@</a><% end %>+ <%# Move into another project (doc/meeting_verschieben_plan.md): loads the+ dialog into the empty frame beside it (README_MODAL_PATTERN.md). %>+ <% if policy(meeting).move? %>+ <a href="<%= move_preflight_organisation_project_meeting_path(+ @current_organisation, meeting.project, meeting, **meeting_lane_state.symbolize_keys+ ) %>"+ id="<%= meeting_move_trigger_id(meeting) %>"+ class="<%= icon_button %>"+ title="<%= t('views.organisations.meetings.show.move_meeting') %>"+ aria-label="<%= t('views.organisations.meetings.show.move_meeting') %>"+ data-turbo-frame="<%= meeting_move_modal_id(meeting) %>">+ <i class="bi bi-arrow-right-square" aria-hidden="true"></i>+ </a>+ <%= turbo_frame_tag meeting_move_modal_id(meeting) %>+ <% end %>+<% if assistant %><button type="button"class="<%= icon_button %>"diff --git a/app/views/organisations/meetings/_move_modal.html.erb b/app/views/organisations/meetings/_move_modal.html.erbnew file mode 100644index 0000000..81e8217--- /dev/null+++ b/app/views/organisations/meetings/_move_modal.html.erb@@ -0,0 +1,102 @@+<%# locals: (meeting:, token:, targets:, impact:, errors: []) %>+<%# The "move" dialog of a meeting (doc/meeting_verschieben_plan.md). Content of the+ frame #meeting-move-modal-<id> in the lane head; the trigger there loads+ meetings#move_preflight into it. The root carries the id of THIS opening (token):+ a refused move replaces exactly it with the message. Shape and lifecycle after+ README_MODAL_PATTERN.md.++ A meeting with linked tickets cannot move: the dialog says so and offers no form.+ The form goes to _top, so a successful move is a visit to the meeting in its new+ place; a refusal answers with a stream into this opening. %>+<% mm = 'views.organisations.meetings.move' %>+<% modal_id = meeting_move_modal_id(meeting) %>+<% field_class = 'w-full rounded border border-cream-300 bg-surface-raised px-3 py-2 text-sm focus:border-ink focus:outline-none focus:ring-1 focus:ring-ink' %>+<% cancel_class = 'h-9 rounded border border-cream-300 bg-cream-100 px-4 text-sm font-medium text-cream-800 hover:bg-cream-200' %>+<% linked = impact[:ticket_links_count] %>+<div id="<%= meeting_move_modal_instance_id(meeting, token) %>"+ data-controller="meeting-move-modal"+ data-meeting-move-modal-return-id-value="<%= meeting_move_trigger_id(meeting) %>"+ data-action="keydown@window->meeting-move-modal#closeOnEscape keydown@window->meeting-move-modal#trapFocus">+ <div class="fixed inset-0 z-50 overflow-y-auto"+ data-action="click->meeting-move-modal#closeOnBackdrop">+ <div class="fixed inset-0 bg-gray-500 bg-opacity-60 backdrop-blur-sm" aria-hidden="true"></div>+ <div class="relative flex min-h-screen items-center justify-center p-4"+ data-action="click->meeting-move-modal#closeOnBackdrop">+ <div class="relative w-full max-w-md rounded-lg border border-slate-200 bg-surface-raised shadow-xl"+ role="dialog" aria-modal="true" aria-labelledby="<%= modal_id %>-title"+ data-meeting-move-modal-target="card">+ <div class="flex items-center justify-between border-b border-slate-200 p-4">+ <h3 id="<%= modal_id %>-title" class="text-lg font-bold text-cream-900">+ <i class="bi bi-arrow-right-square mr-1" aria-hidden="true"></i>+ <%= t("#{mm}.title") %>+ </h3>+ <button type="button" class="text-gray-400 hover:text-gray-600"+ title="<%= t("#{mm}.close") %>" aria-label="<%= t("#{mm}.close") %>"+ data-action="click->meeting-move-modal#close">+ <i class="bi bi-x-lg" aria-hidden="true"></i>+ </button>+ </div>++ <div class="space-y-4 p-5">+ <% if errors.any? %>+ <div class="rounded-lg border border-red-200 bg-red-50 p-3 text-sm text-red-800" role="alert">+ <% errors.each do |message| %>+ <p><%= message %></p>+ <% end %>+ </div>+ <% end %>++ <% if linked.positive? %>+ <p class="text-sm text-cream-800"><%= t("#{mm}.has_ticket_links", count: linked) %></p>+ <div class="flex justify-end border-t border-cream-200 pt-3">+ <button type="button" class="<%= cancel_class %>" data-meeting-move-modal-target="first"+ data-action="click->meeting-move-modal#close">+ <%= t("#{mm}.close") %>+ </button>+ </div>+ <% elsif targets.none? %>+ <p class="text-sm text-cream-800"><%= t("#{mm}.no_targets") %></p>+ <div class="flex justify-end border-t border-cream-200 pt-3">+ <button type="button" class="<%= cancel_class %>" data-meeting-move-modal-target="first"+ data-action="click->meeting-move-modal#close">+ <%= t("#{mm}.close") %>+ </button>+ </div>+ <% else %>+ <%= form_with url: move_organisation_project_meeting_path(current_organisation, meeting.project, meeting),+ method: :post, class: 'space-y-4', data: { turbo_frame: '_top' } do %>+ <%= hidden_field_tag :modal_token, token, id: nil %>+ <%= meeting_list_hidden_fields %>++ <div>+ <label for="<%= modal_id %>-target" class="mb-1 block text-sm font-medium text-cream-800"><%= t("#{mm}.target") %></label>+ <%= select_tag :target_project_id,+ options_from_collection_for_select(targets, :id, :name),+ id: "#{modal_id}-target", class: field_class,+ data: { meeting_move_modal_target: 'first' } %>+ </div>++ <ul class="list-disc space-y-1 pl-5 text-sm text-cream-700">+ <li><%= t("#{mm}.time_sessions", count: impact[:time_sessions_count], billed: impact[:billed_time_sessions_count]) %></li>+ <% if impact[:open_suggestions_count].positive? %>+ <li><%= t("#{mm}.open_suggestions", count: impact[:open_suggestions_count]) %></li>+ <% end %>+ <li><%= t("#{mm}.rights") %></li>+ </ul>++ <div class="flex justify-end gap-2 border-t border-cream-200 pt-3">+ <button type="button" class="<%= cancel_class %>" data-action="click->meeting-move-modal#close">+ <%= t("#{mm}.cancel") %>+ </button>+ <button type="submit"+ class="h-9 rounded border border-ink bg-lime-300 px-4 text-sm font-bold text-ink hover:bg-lime-400">+ <%= t("#{mm}.submit") %>+ </button>+ </div>+ <% end %>+ <% end %>+ </div>+ </div>+ </div>+ </div>+</div>diff --git a/config/importmap.rb b/config/importmap.rbindex f732d6e..3639916 100644--- a/config/importmap.rb+++ b/config/importmap.rb@@ -180,6 +180,7 @@ elsepin 'controllers/layout_toggle_controller', to: 'controllers/layout_toggle_controller.js'pin 'controllers/list_row_controller', to: 'controllers/list_row_controller.js'pin 'controllers/meeting_analysis_composer_controller', to: 'controllers/meeting_analysis_composer_controller.js'+ pin 'controllers/meeting_move_modal_controller', to: 'controllers/meeting_move_modal_controller.js'pin 'controllers/meeting_participants_controller', to: 'controllers/meeting_participants_controller.js'pin 'controllers/meeting_project_select_controller', to: 'controllers/meeting_project_select_controller.js'pin 'controllers/meeting_section_sync_controller', to: 'controllers/meeting_section_sync_controller.js'diff --git a/config/locales/controllers.de.yml b/config/locales/controllers.de.ymlindex 66b91ad..d0729d0 100644--- a/config/locales/controllers.de.yml+++ b/config/locales/controllers.de.yml@@ -230,6 +230,7 @@ de:no_edit_permission: "Sie haben keine Berechtigung, dieses Meeting zu bearbeiten."no_delete_permission: "Sie haben keine Berechtigung, dieses Meeting zu löschen."summary_started: "Die Zusammenfassung wird erstellt."+ moved: "Meeting wurde nach „%{project}“ verschoben."summary_no_content: "Dieses Meeting enthält weder Notizen noch ein Transkript für eine Zusammenfassung."summary_ai_unavailable: "Die KI-Zusammenfassung ist nicht verfügbar. Bitte prüfen Sie die KI-Einstellungen."summary_already_running: "Die Zusammenfassung wird bereits erstellt."diff --git a/config/locales/controllers.en.yml b/config/locales/controllers.en.ymlindex c66c9af..852a16c 100644--- a/config/locales/controllers.en.yml+++ b/config/locales/controllers.en.yml@@ -226,6 +226,7 @@ en:no_edit_permission: "You do not have permission to edit this meeting."no_delete_permission: "You do not have permission to delete this meeting."summary_started: "The summary is being generated."+ moved: "Meeting was moved to “%{project}”."summary_no_content: "This meeting has neither notes nor a transcript to summarize."summary_ai_unavailable: "The AI summary is not available. Please check the AI settings."summary_already_running: "The summary is already being generated."diff --git a/config/locales/views/meetings.de.yml b/config/locales/views/meetings.de.ymlindex 8cb4825..2287a39 100644--- a/config/locales/views/meetings.de.yml+++ b/config/locales/views/meetings.de.yml@@ -52,6 +52,7 @@ de:type_label: Meetingask_assistant: "Assistent fragen"edit_meeting: Meeting bearbeiten+ move_meeting: In anderes Projekt verschiebenback_to_list: Zurück zur Listeclose: Meeting schließenno_content: Keine Notizen oder Transkript erfasst.@@ -103,6 +104,24 @@ de:cancel: Abbrechensave: Speicherndelete: Löschen+ move:+ title: Meeting verschieben+ close: Schließen+ cancel: Abbrechen+ submit: Verschieben+ target: Zielprojekt+ no_targets: Es gibt kein anderes Projekt, in dem du Meetings anlegen darfst.+ has_ticket_links:+ one: Das Meeting ist mit einem Ticket verknüpft und kann deshalb nicht verschoben werden. Entferne zuerst die Verknüpfung.+ other: Das Meeting ist mit %{count} Tickets verknüpft und kann deshalb nicht verschoben werden. Entferne zuerst die Verknüpfungen.+ time_sessions:+ zero: Auf dieses Meeting ist keine Zeit gebucht.+ one: Die gebuchte Zeit zieht mit um (1 Eintrag, davon %{billed} abgerechnet).+ other: Die gebuchte Zeit zieht mit um (%{count} Einträge, davon %{billed} abgerechnet).+ open_suggestions:+ one: Ein offener Ticket-Vorschlag wird verworfen.+ other: "%{count} offene Ticket-Vorschläge werden verworfen."+ rights: Wer das Meeting danach sehen darf, bestimmen die Rechte im Zielprojekt.ticket_links:heading: Verknüpfte Aufgabenempty: Noch keine Aufgaben mit diesem Meeting verknüpft.diff --git a/config/locales/views/meetings.en.yml b/config/locales/views/meetings.en.ymlindex 0771151..9918833 100644--- a/config/locales/views/meetings.en.yml+++ b/config/locales/views/meetings.en.yml@@ -51,6 +51,7 @@ en:type_label: Meetingask_assistant: "Ask assistant"edit_meeting: Edit meeting+ move_meeting: Move to another projectback_to_list: Back to listclose: Close meetingno_content: No notes or transcript recorded.@@ -102,6 +103,24 @@ en:cancel: Cancelsave: Savedelete: Delete+ move:+ title: Move meeting+ close: Close+ cancel: Cancel+ submit: Move+ target: Target project+ no_targets: There is no other project you may add meetings to.+ has_ticket_links:+ one: The meeting is linked to a ticket and therefore cannot be moved. Remove the link first.+ other: The meeting is linked to %{count} tickets and therefore cannot be moved. Remove the links first.+ time_sessions:+ zero: No time is booked on this meeting.+ one: The booked time moves with it (1 entry, %{billed} of it billed).+ other: The booked time moves with it (%{count} entries, %{billed} of them billed).+ open_suggestions:+ one: One open ticket suggestion will be dismissed.+ other: "%{count} open ticket suggestions will be dismissed."+ rights: Who may see the meeting afterwards is decided by the rights in the target project.ticket_links:heading: Linked tasksempty: No tasks linked to this meeting yet.diff --git a/config/routes.rb b/config/routes.rbindex b503e30..82c22c8 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -779,6 +779,10 @@ Rails.application.routes.draw do# One-click search & chat release flip (Meeting-Such-Status): flips# create_embeddings via Actors::SaveMeeting (job enqueue / PII purge).post :toggle_search+ # Moving into another project (doc/meeting_verschieben_plan.md): the+ # dialog (frame content) and the write, both behind move_meetings.+ get :move_preflight+ post :moveendcollection do# LLM participant detection (Slice 5): runs BEFORE save on the rawdiff --git a/spec/requests/organisations/meeting_move_spec.rb b/spec/requests/organisations/meeting_move_spec.rbnew file mode 100644index 0000000..31e7047--- /dev/null+++ b/spec/requests/organisations/meeting_move_spec.rb@@ -0,0 +1,204 @@+# frozen_string_literal: true++require 'rails_helper'++# Moving a meeting into another project (MeetingsController#move_preflight and+# #move, Actors::MoveMeeting). The right: move_meetings (or account admin) plus+# meetings write in the source; the target needs meetings write too, is looked+# up among the active projects the user may see (another organisation's project+# is not found), and is never archived. A meeting with linked tickets stays.+RSpec.describe 'Organisations::Meetings move', :ci_guard, type: :request do+ let(:organisation) { create(:organisation) }+ let(:other_organisation) { create(:organisation) }+ let(:source) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Allgemein') } }+ let(:target) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Relaunch') } }+ let(:read_only_target) do+ ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Nur lesen') }+ end+ let(:foreign_project) do+ ActsAsTenant.with_tenant(other_organisation) { create(:project, organisation: other_organisation, name: 'Fremd') }+ end++ # move: grant move_meetings through the role; access: meetings access per project.+ def member(move:, access:)+ user = create(:user)+ ActsAsTenant.with_tenant(organisation) do+ role = create(:role, title: "Role #{SecureRandom.hex(4)}", organisation: organisation)+ create(:permission, role: role, category: 'meetings', action: 'move_meetings', allowed: true) if move+ create(:membership, user: user, organisation: organisation, role: role, active: true)+ access.each { |project, level| create(:project_permission, user: user, project: project, meetings_access: level) }+ end+ user+ end++ let(:mover) { member(move: true, access: { source => 'read_write', target => 'read_write', read_only_target => 'read_only' }) }+ let(:meeting) do+ ActsAsTenant.with_tenant(organisation) do+ create(:meeting, project: source, organisation: organisation, creator: mover, title: 'Erstgespräch')+ end+ end++ let(:preflight_path) { move_preflight_organisation_project_meeting_path(organisation, source, meeting) }+ let(:move_path) { move_organisation_project_meeting_path(organisation, source, meeting) }++ def meeting_project_id+ ActsAsTenant.without_tenant { meeting.reload.project_id }+ end++ def frame_get(path)+ get path, headers: { 'Turbo-Frame' => "meeting-move-modal-#{meeting.id}" }+ end++ describe 'GET move_preflight' do+ it 'offers the projects the mover may write meetings in, and only those' do+ foreign_project+ sign_in mover+ frame_get preflight_path++ expect(response).to have_http_status(:ok)+ expect(response.body).to include("meeting-move-modal-#{meeting.id}")+ expect(response.body).to include('Relaunch')+ expect(response.body).not_to include('Nur lesen')+ expect(response.body).not_to include('Fremd')+ expect(response.body).not_to include(%(value="#{source.id}"))+ end++ it 'names the booked time, the billed part and the open suggestions' do+ ActsAsTenant.with_tenant(organisation) do+ create(:time_session, project: source, organisation: organisation, meeting: meeting, creator: mover)+ create(:time_session, project: source, organisation: organisation, meeting: meeting, creator: mover,+ billed: true, billed_at: 1.day.ago)+ create(:meeting_ticket_suggestion, meeting: meeting)+ end+ sign_in mover+ frame_get preflight_path++ expect(response.body).to include(I18n.t('views.organisations.meetings.move.time_sessions', count: 2, billed: 1))+ expect(response.body).to include(I18n.t('views.organisations.meetings.move.open_suggestions', count: 1))+ end++ it 'says up front that a meeting with linked tickets cannot move, and offers no form' do+ ActsAsTenant.with_tenant(organisation) do+ ticket = create(:ticket, project: source, organisation: organisation, creator: mover)+ Reference.create!(source: meeting, target: ticket, target_title_snapshot: ticket.title)+ end+ sign_in mover+ frame_get preflight_path++ expect(response.body).to include(I18n.t('views.organisations.meetings.move.has_ticket_links', count: 1))+ expect(response.body).not_to include('name="target_project_id"')+ end++ it 'refuses a member without move_meetings' do+ user = member(move: false, access: { source => 'read_write', target => 'read_write' })+ sign_in user+ frame_get preflight_path++ expect(response).to have_http_status(:redirect)+ end+ end++ describe 'POST move' do+ it 'moves the meeting and opens it in the target project' do+ sign_in mover+ post move_path, params: { target_project_id: target.id, modal_token: 'abc' }++ expect(meeting_project_id).to eq(target.id)+ expect(response).to have_http_status(:see_other)+ expect(response).to redirect_to(organisation_project_meetings_path(organisation, target, meeting_id: meeting.id))+ expect(flash[:notice]).to eq(I18n.t('flash.meetings.moved', project: 'Relaunch'))+ end++ it 'stays on "Alle Meetings" when the move started there' do+ sign_in mover+ post move_path, params: { target_project_id: target.id, modal_token: 'abc', list_context: 'organisation' }++ expect(meeting_project_id).to eq(target.id)+ expect(response).to redirect_to(organisation_meetings_path(organisation, meeting_id: meeting.id))+ end++ it 'lets an account admin move without the role permission' do+ admin = create(:user)+ ActsAsTenant.with_tenant(organisation) do+ create(:membership, user: admin, organisation: organisation, role: create(:admin_role, organisation: organisation))+ end+ sign_in admin+ post move_path, params: { target_project_id: target.id, modal_token: 'abc' }++ expect(meeting_project_id).to eq(target.id)+ end++ it 'refuses a member without move_meetings' do+ user = member(move: false, access: { source => 'read_write', target => 'read_write' })+ sign_in user+ post move_path, params: { target_project_id: target.id, modal_token: 'abc' }++ expect(meeting_project_id).to eq(source.id)+ end++ it 'refuses a mover who may only read meetings in the source' do+ user = member(move: true, access: { source => 'read_only', target => 'read_write' })+ sign_in user+ post move_path, params: { target_project_id: target.id, modal_token: 'abc' }++ expect(meeting_project_id).to eq(source.id)+ end++ it 'shows the move in both project feeds, only to those who read meetings there' do+ tickets_only = member(move: false, access: {})+ ActsAsTenant.with_tenant(organisation) do+ create(:project_permission, user: tickets_only, project: target, tickets_access: 'read_only',+ meetings_access: 'no_access')+ end+ sign_in mover+ post move_path, params: { target_project_id: target.id, modal_token: 'abc' }++ get organisation_project_activities_path(organisation, target)+ expect(response.body).to include('Erstgespräch')+ expect(response.body).to include(I18n.t('views.organisations.tickets.timeline.meeting_moved_in', project: 'Allgemein'))++ get organisation_project_activities_path(organisation, source)+ expect(response.body).to include(I18n.t('views.organisations.tickets.timeline.meeting_moved_out', project: 'Relaunch'))++ sign_in tickets_only+ get organisation_project_activities_path(organisation, target)+ expect(response).to have_http_status(:ok)+ expect(response.body).not_to include('Erstgespräch')+ end++ context 'with a target the move refuses' do+ def expect_refused(target_id, message)+ sign_in mover+ post move_path, params: { target_project_id: target_id, modal_token: 'abc' }, as: :turbo_stream++ expect(meeting_project_id).to eq(source.id)+ expect(response).to have_http_status(:unprocessable_content)+ expect(response.body).to include("meeting-move-modal-#{meeting.id}-abc")+ expect(response.body).to include(CGI.escapeHTML(message))+ end++ it 'refuses a project the mover may only read meetings in' do+ expect_refused(read_only_target.id, I18n.t('services.actors.move_meeting.forbidden_target'))+ end++ it "does not find another organisation's project" do+ expect_refused(foreign_project.id, I18n.t('services.actors.move_meeting.forbidden_target'))+ end++ it 'refuses an archived project' do+ ActsAsTenant.with_tenant(organisation) { target.update!(archived_at: Time.current) }++ expect_refused(target.id, I18n.t('services.actors.move_meeting.forbidden_target'))+ end++ it 'refuses a meeting with a linked ticket' do+ ActsAsTenant.with_tenant(organisation) do+ ticket = create(:ticket, project: source, organisation: organisation, creator: mover)+ Reference.create!(source: meeting, target: ticket, target_title_snapshot: ticket.title)+ end++ expect_refused(target.id, I18n.t('services.actors.move_meeting.has_ticket_links'))+ end+ end+ end+enddiff --git a/spec/system/meeting_move_spec.rb b/spec/system/meeting_move_spec.rbnew file mode 100644index 0000000..2528bbf--- /dev/null+++ b/spec/system/meeting_move_spec.rb@@ -0,0 +1,78 @@+# frozen_string_literal: true++require 'rails_helper'++# The "move" dialog of a meeting, clicked for real (doc/meeting_verschieben_plan.md).+# Markup assertions cannot prove what these do: the dialog opening from the lane+# head, Escape closing only the dialog and not the lane behind it, the focus+# returning to the trigger, and a move landing on the meeting in its new project.+RSpec.describe 'Moving a meeting', type: :system do+ let(:organisation) { create(:organisation) }+ let(:user) { create(:user) }+ let(:source) { create(:project, organisation: organisation, name: 'Allgemein') }+ let(:target) { create(:project, organisation: organisation, name: 'Relaunch') }+ let(:mm) { 'views.organisations.meetings.move' }++ before do+ Prosopite.pause+ ActsAsTenant.current_tenant = organisation+ create(:membership, user: user, organisation: organisation, role: create(:admin_role, organisation: organisation),+ active: true)+ target+ sign_in user+ end++ # After the before block above: it needs its tenant.+ let!(:meeting) { create(:meeting, project: source, organisation: organisation, creator: user, title: 'Erstgespräch') }++ after do+ ActsAsTenant.current_tenant = nil+ Prosopite.resume+ end++ def open_dialog+ visit organisation_project_meetings_path(organisation, source, meeting_id: meeting.id)+ find("#meeting-move-trigger-#{meeting.id}").click+ expect(page).to have_css('[role="dialog"]', text: I18n.t("#{mm}.title"))+ end++ it 'closes on Escape without closing the lane, and gives the focus back to the trigger' do+ open_dialog++ # To the focused element: Element#send_keys clicks it first, and a click on+ # the select opens its native list, which takes the Escape.+ page.send_keys(:escape)++ expect(page).to have_no_css('[role="dialog"]')+ expect(page).to have_css("#meeting-move-trigger-#{meeting.id}")+ expect(page.evaluate_script('document.activeElement.id')).to eq("meeting-move-trigger-#{meeting.id}")+ end++ it 'moves the meeting and opens it in its new project' do+ open_dialog++ within('[role="dialog"]') do+ select 'Relaunch', from: I18n.t("#{mm}.target")+ click_button I18n.t("#{mm}.submit")+ end++ expect(page).to have_text(I18n.t('flash.meetings.moved', project: 'Relaunch'))+ expect(page).to have_current_path(organisation_project_meetings_path(organisation, target, meeting_id: meeting.id))+ expect(page).to have_css("#meeting-move-trigger-#{meeting.id}")+ expect(meeting.reload.project).to eq(target)+ end++ it 'says why a meeting with a linked ticket cannot move' do+ ticket = create(:ticket, project: source, organisation: organisation, creator: user)+ Reference.create!(source: meeting, target: ticket, target_title_snapshot: ticket.title)++ open_dialog++ within('[role="dialog"]') do+ expect(page).to have_text(I18n.t("#{mm}.has_ticket_links", count: 1))+ expect(page).to have_no_button(I18n.t("#{mm}.submit"))+ click_button I18n.t("#{mm}.close"), match: :first+ end+ expect(page).to have_no_css('[role="dialog"]')+ end+end