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
Open "Neues Meeting" of "Alle Meetings" in the lane, with a project select
Guido Boyke821d4bf635d5
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.ymlindex d628682..c93f0e2 100644--- a/.github/workflows/guards.yml+++ b/.github/workflows/guards.yml@@ -589,6 +589,7 @@ jobs:spec/requests/organisations/meetings_overview_columns_spec.rbspec/requests/organisations/meetings_overview_lane_spec.rbspec/requests/organisations/meetings_overview_lane_access_spec.rb+ spec/requests/organisations/meetings_overview_new_access_spec.rbspec/services/actors/save_smart_folder_from_filters_spec.rbspec/services/actors/save_smart_folder_concurrency_spec.rbspec/services/actors/create_ticket_relation_concurrency_spec.rbdiff --git a/app/controllers/organisations/meetings_controller.rb b/app/controllers/organisations/meetings_controller.rbindex a793eb7..83d704e 100644--- a/app/controllers/organisations/meetings_controller.rb+++ b/app/controllers/organisations/meetings_controller.rb@@ -25,24 +25,13 @@ module OrganisationsDETAIL_FRAME_ID = 'meeting_display_frame'LIST_FRAME_ID = 'meetings_results'- # The org-wide list ("Alle Meetings") creates through a modal that hosts this- # controller's own `new` form in a frame of its own. Both ids are declared by the- # partial that carries the frame — meetings_overview/_new_meeting_modal.html.erb- # and _results.html.erb — the same "keep them in sync" rule as the two above.- # The filter bar of that page targets OVERVIEW_LIST_FRAME_ID too.- # OVERVIEW_LIST_FRAME_ID is REPLACED on a save, so its partial has to bring the- # <turbo-frame> itself; a frameless partial would delete the frame and every- # later stream to it would vanish without a word.- MODAL_FRAME_ID = 'meeting_modal_form'+ # The list frame of "Alle Meetings", declared by meetings_overview/_results —+ # the same "keep them in sync" rule as the two above. The filter bar of that+ # page targets it too. It is REPLACED on a save, so its partial has to bring+ # the <turbo-frame> itself; a frameless partial would delete the frame and+ # every later stream to it would vanish without a word.OVERVIEW_LIST_FRAME_ID = 'meetings_overview_results'- # Third place the Stimulus identifier "meeting-modal" appears (with the modal- # partial's data-controller and the importmap pin): the cancel button inside the- # form has to close the modal, and the form is rendered from here. Renaming the- # controller means renaming it here too — nothing fails loudly otherwise, the- # button just stops working.- MODAL_CANCEL_ACTION = 'click->meeting-modal#close'-# The list renders only these columns (_meeting_row: title, date, duration).# Selecting full rows would de-TOAST notes/transcript/plain_text_version (up to# ~1 MB each) for every row on every list render — the detail pane loads its@@ -106,18 +95,12 @@ module Organisations@meeting = @project.meetings.build(occurred_at: Time.current)authorize @meeting, :create?- if turbo_frame_request?- # Two frames ask for this form: the detail pane of the project page, and the- # modal on the org-wide list. Same partial, different wrapper and different- # idea of what "cancel" and "saved" mean.- case params[:frame]- when 'content'- render_detail_frame('organisations/meetings/meeting_new_for_frame', @meeting)- return- when 'modal'- render_modal_frame(@meeting)- return- end+ # Two frames ask for this form: the lane of the project page, and the frame+ # below the project select in the lane of "Alle Meetings" (frame_id names+ # which). Same partial; it knows which of the two it is in.+ if turbo_frame_request? && params[:frame] == 'content'+ render_detail_frame('organisations/meetings/meeting_new_for_frame', @meeting)+ returnend# The list header normally opens the form in the desktop detail frame. On a@@ -146,15 +129,11 @@ module Organisationsrespond_to do |format|format.turbo_stream { render turbo_stream: created_streams(@meeting) }format.html do- # Without JavaScript the modal is a plain form post. A save that started- # on "Alle Meetings" belongs back there, not in the project's own- # master-detail — the same rule the turbo_stream branch follows.- query = meeting_organisation_list? ? meeting_index_query : meeting_index_query.merge(meeting_id: @meeting.id)- redirect_to meeting_list_index_path(query), notice: t('flash.meetings.created')+ # Without JavaScript: back to the list the save started from, with the+ # new meeting open in its lane — the rule the turbo_stream branch follows.+ redirect_to meeting_list_index_path(meeting_index_query.merge(meeting_id: @meeting.id)), notice: t('flash.meetings.created')endend- elsif meeting_organisation_list?- render_modal_frame_with_errors(@meeting)elserender_form_with_errors('organisations/meetings/meeting_new_for_frame')end@@ -425,7 +404,7 @@ module Organisationsend# The list this request shows or redraws (MeetingList): the project's own, or- # "Alle Meetings" for a write from that page, its lane or its modal+ # "Alle Meetings" for a write from that page or its lane# (list_context=organisation, Meetings::ListState). Only the list: set_meeting# and the project's area gate decide what may be read and written, with or# without the context.@@ -458,14 +437,14 @@ module Organisationspolicy_scope(@project.meetings).find_by(id: meeting_id)end- # A new meeting can be saved from two pages, and they share no frame. The- # project page refreshes its list and opens the detail; the org-wide list- # creates in its modal, so it refreshes its own table instead and lets- # meeting_modal_controller close the modal on the successful submit.+ # A new meeting can be saved from two pages, and both answer alike: the+ # address names it, the list the form came from is redrawn with it selected,+ # and it opens in the lane. In the LANE, not in the frame the form stood in:+ # on "Alle Meetings" that is the frame below the project select, which goes+ # with it.def created_streams(meeting)- return overview_created_streams(meeting) if meeting_organisation_list?-- [created_address_stream(meeting)] + saved_streams(meeting, 'flash.meetings.created')+ list = list_stream(selected: meeting)+ [created_address_stream(meeting), list, lane_stream(meeting, frame_id: DETAIL_FRAME_ID), flash_stream(created_flash_key(meeting))]enddef created_address_stream(meeting)@@ -479,27 +458,27 @@ module OrganisationsMeetings::ListState.extract(params)end- # The refreshed list keeps the state the page is showing (the form carries it- # as hidden fields), so a meeting saved for another project (or without the- # searched word) is legitimately not in it. Then the list looks as if the save- # failed, so the flash says which of the two happened. The list is the one- # MeetingsOverviewController renders (MeetingList, project nil).- def overview_created_streams(meeting)- list = list_stream(selected: nil)- hidden = !@meeting_list_query.exists?(id: meeting.id)-- [list, flash_stream(hidden ? 'flash.meetings.created_hidden_by_filter' : 'flash.meetings.created')]+ # The redrawn list keeps the state the page is showing (the form carries it+ # as hidden fields). On "Alle Meetings" a meeting saved into a project the+ # list does not show (or without the searched word) is legitimately not in+ # it, and the list would look as if the save failed while the lane shows the+ # meeting; the flash says which of the two happened. The project page keeps+ # its own message (PR 4 changed nothing there). Asks the list rendered by+ # list_stream (@meeting_list_query).+ def created_flash_key(meeting)+ hidden = meeting_organisation_list? && !@meeting_list_query.exists?(id: meeting.id)+ hidden ? 'flash.meetings.created_hidden_by_filter' : 'flash.meetings.created'end- # Success response for create/update: refresh the list frame (new/edited row,+ # Success response for update: refresh the list frame (edited row,# re-sorted) with the meeting selected, show the detail, and flash.def saved_streams(meeting, flash_key)- [- list_stream(selected: meeting),- turbo_stream.update(detail_frame_id, partial: 'organisations/meetings/meeting_show',- locals: { meeting: meeting, detail_frame_id: detail_frame_id }),- flash_stream(flash_key)- ]+ [list_stream(selected: meeting), lane_stream(meeting), flash_stream(flash_key)]+ end++ def lane_stream(meeting, frame_id: detail_frame_id)+ turbo_stream.update(frame_id, partial: 'organisations/meetings/meeting_show',+ locals: { meeting: meeting, detail_frame_id: frame_id })end# The list the request came from (MeetingList#meeting_organisation_list?),@@ -576,60 +555,29 @@ module Organisationsstatus: :unprocessable_contentendformat.html do- @meetings = filtered_meetings- @new_meeting = @meeting- render :index, status: :unprocessable_content+ # The form of "Alle Meetings" stands in the frame below its project+ # select, which only that page draws: answer the frame, as Turbo would.+ if meeting_organisation_list?+ render_detail_frame(partial, @meeting, status: :unprocessable_content)+ else+ @meetings = filtered_meetings+ @new_meeting = @meeting+ render :index, status: :unprocessable_content+ endendendend- def render_detail_frame(partial, meeting)+ def render_detail_frame(partial, meeting, status: :ok)render html: helpers.turbo_frame_tag(detail_frame_id) {helpers.render(partial: partial, locals: { meeting: meeting, detail_frame_id: detail_frame_id })- }.html_safe, layout: false+ }.html_safe, layout: false, status: statusenddef detail_frame_idparams[:frame_id].presence || DETAIL_FRAME_IDend- # The org-wide modal's frame. Same form partial as the detail pane — only the- # wrapper id, the cancel behaviour and the save context differ, so there is no- # second copy of the meeting form to keep in step.- def render_modal_frame(meeting, status: :ok)- render html: helpers.turbo_frame_tag(MODAL_FRAME_ID) {- helpers.render(partial: 'organisations/meetings/meeting_new_for_frame',- locals: modal_form_locals(meeting))- }.html_safe, layout: false, status: status- end-- # Validation errors from the modal go back INTO the modal: it stays open, the- # project select above the frame keeps its value, and the messages sit with the- # fields that caused them.- def render_modal_frame_with_errors(meeting)- respond_to do |format|- format.turbo_stream do- render turbo_stream: turbo_stream.update(MODAL_FRAME_ID,- partial: 'organisations/meetings/meeting_new_for_frame',- locals: modal_form_locals(meeting)),- status: :unprocessable_content- end- format.html { render_modal_frame(meeting, status: :unprocessable_content) }- end- end-- # The save context is not here: the modal's frame is loaded with- # list_context=organisation (_new_meeting_modal), and the form carries it on- # with the list state (meeting_list_hidden_fields).- def modal_form_locals(meeting)- {- meeting: meeting,- detail_frame_id: MODAL_FRAME_ID,- modal: true,- cancel_action: MODAL_CANCEL_ACTION- }- end-def meeting_params# participants: the chips field posts meeting[participants][i][display_name]# and [user_id]; the actor strips this key out before touching Meetingdiff --git a/app/controllers/organisations/meetings_overview_controller.rb b/app/controllers/organisations/meetings_overview_controller.rbindex 68ccea9..fcce8a8 100644--- a/app/controllers/organisations/meetings_overview_controller.rb+++ b/app/controllers/organisations/meetings_overview_controller.rb@@ -16,10 +16,14 @@# (MeetingsController, list_context=organisation); this controller only renders# the selected meeting on a full visit.#-# The title box carries a "+" that opens a modal with a project select, and the-# modal's turbo-frame loads the real form from the project-nested-# MeetingsController (frame: 'modal'). This controller only decides WHETHER to-# offer the button and WHICH projects it may offer; the write never happens here.+# The title box carries a "+" that opens a project select in the lane, as the+# project page's "+" opens its form there (PR 4): ?new=meeting on this page's+# own address, for a full visit and for the lane frame alike, so there is no+# meeting route without a project. The frame below the select loads the real+# form from the project-nested MeetingsController (frame: 'content'). This+# controller only decides WHETHER to offer the select and WHICH projects it+# may offer; the write never happens here. Until PR 4 the select stood in a+# modal.## Security rests entirely on MeetingPolicy::Scope (accessible_project_ids for the# :meetings area, within the tenant, never without_tenant): the list, every@@ -35,6 +39,10 @@ module Organisationsinclude MeetingListLIST_FRAME_ID = MeetingsController::OVERVIEW_LIST_FRAME_ID+ # The frame below the project select in the lane: the chosen project's form+ # loads into it, and a refused save answers into it, so the select keeps+ # its project (meetings_overview/_new_meeting_lane).+ NEW_FORM_FRAME_ID = 'meeting_new_form'# The addresses of the page before the filter bar, still in bookmarks and# links from elsewhere: ?participant= and ?project_id= become the bar's@@ -46,6 +54,8 @@ module Organisationsbefore_action :set_viewport_mode, only: :indexdef index+ return render_new_meeting_frame if lane_frame_request?+@meetings = filtered_meetingsif turbo_frame_request?render_list_frame@@ -53,6 +63,7 @@ module Organisationsend@selected_meeting = find_selected_meeting+ @new_meeting_lane = @selected_meeting.nil? && new_meeting_requested?MeetingTicketSuggestionRun.recover_for_meeting!(@selected_meeting)# The claim hint (Nachtrag) is rendered lazily via the meeting_claim_matches# helper (shared with the project index), nothing to set up here.@@ -70,6 +81,32 @@ module Organisationsendend+ # The lane asks this address for its content in one case only: the "+"+ # (lane-link), for the project select.+ def lane_frame_request?+ turbo_frame_request? && request.headers['Turbo-Frame'] == MeetingsController::DETAIL_FRAME_ID+ end++ # The project select alone, for the lane. It reads no meeting, so there is no+ # scope to apply: what it names comes from writable_meeting_projects, the+ # write reach of AccessCheck::ProjectAccessService. Without that reach, or+ # for any other request into the lane, the answer is the usual refusal.+ def render_new_meeting_frame+ skip_policy_scope+ raise Pundit::NotAuthorizedError unless new_meeting_requested?++ render html: helpers.turbo_frame_tag(MeetingsController::DETAIL_FRAME_ID) {+ helpers.render(partial: 'organisations/meetings_overview/new_meeting_lane', locals: { projects: writable_meeting_projects })+ }, layout: false+ end++ # ?new=meeting, from someone who may write meetings somewhere. Otherwise the+ # page is the list without a lane, and layout-toggle takes new out of the+ # address (meeting_unresolved_lane_params).+ def new_meeting_requested?+ params[:new] == 'meeting' && can_create_meeting?+ end+# The meeting a full visit opens in the lane: through policy_scope(Meeting)# only, so an id of an unreadable project or another organisation is no# meeting at all, and nothing of it is rendered, not even its title. The@@ -132,7 +169,7 @@ module Organisationshelper_method :meeting_filter_projects# The projects the "+" may offer: where this person may WRITE meetings. Read- # access is not enough: the modal's form would be refused by the area gate in+ # access is not enough: the select's form would be refused by the area gate in# MeetingsController, and a button that leads to an error message is a promise# without cover (same rule as the Zeiten title box). The reach itself comes from# the single owner in AccessCheck::ProjectAccessService, not a second copy here.diff --git a/app/javascript/controllers/meeting_project_select_controller.js b/app/javascript/controllers/meeting_project_select_controller.jsnew file mode 100644index 0000000..8c03e77--- /dev/null+++ b/app/javascript/controllers/meeting_project_select_controller.js@@ -0,0 +1,50 @@+import { Controller } from "@hotwired/stimulus"+import { chosenFormUrl } from "meeting_project_select"++/**+ * Meeting Project Select Controller+ *+ * "Neues Meeting" on "Alle Meetings" opens a project select in the lane+ * (meetings_overview/_new_meeting_lane). The choice loads that project's form+ * into the frame below the select; every <option> carries its address from+ * ERB, and this controller only copies it onto the frame (lib/meeting_project_select).+ *+ * A new choice is a new frame visit, and Turbo cancels the one in flight, so+ * the form of the project chosen before cannot arrive after it. Taking the+ * choice back starts no visit: an answer still in flight then renders into the+ * frame, and it is put back to the zero state, or the lane would show a form+ * for a project the select no longer names.+ */+export default class extends Controller {+ static targets = ["select", "frame", "placeholder"]++ connect() {+ this.boundFrameLoaded = this.frameLoaded.bind(this)+ this.frameTarget.addEventListener("turbo:frame-load", this.boundFrameLoaded)+ }++ disconnect() {+ this.frameTarget.removeEventListener("turbo:frame-load", this.boundFrameLoaded)+ }++ choose() {+ const url = chosenFormUrl(this.selectTarget)+ if (url) {+ this.frameTarget.setAttribute("src", url)+ return+ }++ this.reset()+ }++ frameLoaded() {+ if (chosenFormUrl(this.selectTarget)) return++ this.reset()+ }++ reset() {+ this.frameTarget.removeAttribute("src")+ this.frameTarget.replaceChildren(this.placeholderTarget.content.cloneNode(true))+ }+}diff --git a/app/javascript/lib/meeting_project_select.js b/app/javascript/lib/meeting_project_select.jsnew file mode 100644index 0000000..578333d--- /dev/null+++ b/app/javascript/lib/meeting_project_select.js@@ -0,0 +1,15 @@+// What: the one decision meeting_project_select_controller.js makes, as a pure+// function so node:test can pin it: which form the frame below the project+// select of "Alle Meetings" shows (meetings_overview/_new_meeting_lane).+// Why: the address comes from ERB, one per <option>, so no route is assembled+// in the browser; and "nothing chosen" has to be one answer, because it+// decides twice: when the choice changes, and when an answer arrives that was+// asked for before the choice was taken back.++// The form address of the chosen project, or null when none is chosen (the+// prompt, an option without an address, no select at all).+export function chosenFormUrl(select) {+ const option = select && select.selectedOptions ? select.selectedOptions[0] : null+ const url = option && option.dataset ? option.dataset.formUrl : null+ return url || null+}diff --git a/app/views/organisations/meetings/_form_lane_head.html.erb b/app/views/organisations/meetings/_form_lane_head.html.erbindex 2957d1c..f895b39 100644--- a/app/views/organisations/meetings/_form_lane_head.html.erb+++ b/app/views/organisations/meetings/_form_lane_head.html.erb@@ -1,7 +1,11 @@-<%# locals: (new_form:) %>+<%# locals: (new_form:, project: @project) %>+<%# project: the project whose meetings index the lane belongs to+ (data-lane-index-url, lib/lane/filter_context). nil for the project select+ of "Alle Meetings": no project is chosen yet, and the form below it names+ its own (meetings/_meeting_new_for_frame). %><% 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:bg-cream-200 focus-visible:text-cream-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink focus-visible:ring-offset-2' %><% close_url = meeting_list_index_path(meeting_list_state) %>-<div class="flex items-center gap-4 mb-2" data-lane-head data-lane-index-url="<%= organisation_project_meetings_path(@current_organisation, @project) %>">+<div class="flex items-center gap-4 mb-2" data-lane-head<% if project %> data-lane-index-url="<%= organisation_project_meetings_path(@current_organisation, project) %>"<% end %>><span class="hidden lg:inline font-mono text-[13px] tracking-wide text-cream-500"><%= t('views.organisations.meetings.show.type_label') %></span>diff --git a/app/views/organisations/meetings/_index_desktop.html.erb b/app/views/organisations/meetings/_index_desktop.html.erbindex 2644d05..018efc2 100644--- a/app/views/organisations/meetings/_index_desktop.html.erb+++ b/app/views/organisations/meetings/_index_desktop.html.erb@@ -1,11 +1,13 @@-<%# locals: (list:) %>+<%# locals: (list:, lane_form: nil) %><%# Desktop two-column master-detail (list + detail frame), mirroring Knowledge.Shared by the project page and "Alle Meetings": list is the page's own head- and results, and the results partial brings its own list frame. %>+ and results, and the results partial brings its own list frame. lane_form is+ the page's own form state of the lane (?new=meeting): the form on the project+ page, the project select on "Alle Meetings". %><%= render NeoTwoColumnGridComponent.new(- selected_item: @selected_meeting || @new_meeting,+ selected_item: @selected_meeting || lane_form.presence,context_type: :meetings,- css_classes: "#{@selected_meeting || @new_meeting ? 'show-content' : 'hide-content'} hide-panel",+ css_classes: "#{@selected_meeting || lane_form.present? ? 'show-content' : 'hide-content'} hide-panel",additional_targets: { "index-page-target" => "layout", "column-picker-target" => "grid" },chrome_height: NeoTwoColumnGridComponent::LANE_CHROME_HEIGHT_PX,lane: true@@ -22,8 +24,8 @@<%# No data-turbo-action="advance": list-row owns the canonical…/meetings?meeting_id=… page address. %><turbo-frame id="meeting_display_frame">- <% if @new_meeting %>- <%= render (@new_meeting.persisted? ? 'organisations/meetings/meeting_edit' : 'organisations/meetings/meeting_new_for_frame'), meeting: @new_meeting, detail_frame_id: 'meeting_display_frame' %>+ <% if lane_form.present? %>+ <%= lane_form %><% else %><%= render 'organisations/meetings/display_meeting', selected_meeting: @selected_meeting %><% end %>diff --git a/app/views/organisations/meetings/_index_mobile.html.erb b/app/views/organisations/meetings/_index_mobile.html.erbindex 733941f..cf3a9f9 100644--- a/app/views/organisations/meetings/_index_mobile.html.erb+++ b/app/views/organisations/meetings/_index_mobile.html.erb@@ -1,13 +1,14 @@-<%# locals: (list:) %>+<%# locals: (list:, lane_form: nil) %><div class="meeting-mobile-grid list" data-column-picker-target="grid"><%# Mobile: list OR full-screen detail with a back button (Tickets pattern).Frame ids identical to desktop so the search frame reload works on mobile.Shared by the project page and "Alle Meetings": list is the page's own head- and results, and the way back leads to this page's list (MeetingList). %>+ and results, and the way back leads to this page's list (MeetingList).+ lane_form: as in _index_desktop. %><% back_query = request.query_parameters.except('meeting_id', 'new', 'frame', 'frame_id', 'format') %><%= render NeoMobileTicketViewComponent.new(- selected_item: @selected_meeting || @new_meeting,- show_detail: @selected_meeting.present? || @new_meeting.present?,+ selected_item: @selected_meeting || lane_form.presence,+ show_detail: @selected_meeting.present? || lane_form.present?,back_url: meeting_list_index_path(back_query),back_label: t('views.organisations.meetings.index.mobile_list_view')) do |mobile| %>@@ -17,8 +18,8 @@<% mobile.with_detail do %><turbo-frame id="meeting_display_frame">- <% if @new_meeting %>- <%= render (@new_meeting.persisted? ? 'organisations/meetings/meeting_edit' : 'organisations/meetings/meeting_new_for_frame'), meeting: @new_meeting, detail_frame_id: 'meeting_display_frame' %>+ <% if lane_form.present? %>+ <%= lane_form %><% else %><%= render 'organisations/meetings/display_meeting', selected_meeting: @selected_meeting %><% end %>diff --git a/app/views/organisations/meetings/_meeting_new_for_frame.html.erb b/app/views/organisations/meetings/_meeting_new_for_frame.html.erbindex 312c002..ac8a963 100644--- a/app/views/organisations/meetings/_meeting_new_for_frame.html.erb+++ b/app/views/organisations/meetings/_meeting_new_for_frame.html.erb@@ -1,19 +1,22 @@-<%# locals: (meeting:, detail_frame_id: nil, modal: false, cancel_action: nil) %>+<%# locals: (meeting:, detail_frame_id: nil) %><%# The ONE "new meeting" form, rendered into whichever frame asked for it: the- detail pane of the project master-detail, or the modal on the org-wide list.- Submits as turbo_stream — MeetingsController#create decides what to refresh from- the list context in the hidden fields (list_context, Meetings::ListState),- because the two pages have different frames.+ lane of the project page, or the frame below the project select in the lane+ of "Alle Meetings" (meetings_overview/_new_meeting_lane). Submits as+ turbo_stream; MeetingsController#create decides what to redraw from the list+ context in the hidden fields (list_context, Meetings::ListState), because the+ two pages have different lists.- modal / cancel_action are the modal's two additions: its frame without the- lane head, and how "Abbrechen" closes (a link back to the list makes no sense- inside a modal). Where the save came from and the org-wide list's state, its- project condition included, travel in the same hidden fields as the project- list's (meeting_list_hidden_fields). %>-<% modal_context = modal %>-<div id="meeting-form-card" class="<%= modal_context ? 'bg-cream-50 py-6 px-8 rounded-lg border border-cream-300 relative' : 'meeting-content min-w-0 relative' %>">- <% current_frame_id = detail_frame_id || 'meeting_display_frame' %>- <% unless modal_context %>+ In the lane itself the form brings the lane head and the heading. Below the+ select the lane has both already, and the card names its project's meetings+ index instead (data-lane-index-url, as the lane head does): layout-toggle+ sets the live list state into the hidden fields at submit for a form below+ an index it knows (lib/lane/filter_context), and the list may have changed+ since the select's options were rendered. %>+<% current_frame_id = detail_frame_id || Organisations::MeetingsController::DETAIL_FRAME_ID %>+<% own_lane = current_frame_id == Organisations::MeetingsController::DETAIL_FRAME_ID %>+<%= tag.div id: 'meeting-form-card', class: [('meeting-content' if own_lane), 'min-w-0 relative'].compact,+ data: ({ lane_index_url: organisation_project_meetings_path(@current_organisation, @project) } unless own_lane) do %>+ <% if own_lane %><%= render 'organisations/meetings/form_lane_head', new_form: true %><h2 class="text-[22px] leading-snug font-bold text-cream-900 mb-6"><%= t('views.organisations.meetings.index.new_meeting') %>@@ -29,17 +32,10 @@<%= render 'organisations/meetings/form_fields', form: form, meeting: meeting %><div class="flex justify-end items-center gap-2 mt-6">- <%# One cancel button, two behaviours: inside the modal it closes the modal- (a link back to the list makes no sense there), otherwise it leaves the- detail frame. Rendered once so a future label or icon change lands in- both places. %>- <% cancel_options = if cancel_action.present?- { type: 'button', data: { action: cancel_action } }- else- { url: meeting_list_index_path(meeting_list_state),- data: { turbo_frame: '_top', lane_back: true } }- end %>- <%= render Neo::Buttons::ButtonComponent.new(variant: :edit, **cancel_options) do %>+ <%# Back to the list the form was opened from, which closes the lane and+ takes new out of the address (MeetingList#meeting_list_index_path). %>+ <%= render Neo::Buttons::ButtonComponent.new(variant: :edit, url: meeting_list_index_path(meeting_list_state),+ data: { turbo_frame: '_top', lane_back: true }) do %><%= t('views.organisations.meetings.form.cancel') %><% end %>@@ -48,4 +44,4 @@<% end %></div><% end %>-</div>+<% end %>diff --git a/app/views/organisations/meetings/index.html.erb b/app/views/organisations/meetings/index.html.erbindex d86a1f2..8bfb044 100644--- a/app/views/organisations/meetings/index.html.erb+++ b/app/views/organisations/meetings/index.html.erb@@ -24,9 +24,16 @@<%= render 'organisations/meetings/meetings_results', meetings: @meetings, selected_meeting: @selected_meeting %><% end %>+ <%# The form as a state of the lane (?new=meeting), or a refused edit+ rendered as a page (MeetingsController#render_form_with_errors). %>+ <% lane_form = if @new_meeting+ render (@new_meeting.persisted? ? 'organisations/meetings/meeting_edit' : 'organisations/meetings/meeting_new_for_frame'),+ meeting: @new_meeting, detail_frame_id: 'meeting_display_frame'+ end %>+<% if @viewport_mode == 'mobile' %>- <%= render 'organisations/meetings/index_mobile', list: list %>+ <%= render 'organisations/meetings/index_mobile', list: list, lane_form: lane_form %><% else %>- <%= render 'organisations/meetings/index_desktop', list: list %>+ <%= render 'organisations/meetings/index_desktop', list: list, lane_form: lane_form %><% end %></div>diff --git a/app/views/organisations/meetings_overview/_list_head.html.erb b/app/views/organisations/meetings_overview/_list_head.html.erbindex 3aabc0a..bf35da1 100644--- a/app/views/organisations/meetings_overview/_list_head.html.erb+++ b/app/views/organisations/meetings_overview/_list_head.html.erb@@ -13,10 +13,30 @@) do |box| %><%# Same square primary "+" as the project meetings page and the Zeiten list.Only where this person may write meetings somewhere: a button that leads- to an error message is a promise without cover. %>+ to an error message is a promise without cover. It opens the project+ select in the lane (?new=meeting, MeetingsOverviewController#index) as a+ lane-link: the address bar at click time gives the list state, so a+ condition set after this head was rendered is kept, and below the lane+ width the page itself is visited, full width, as a row does. The href+ is the same state for a new tab or a page without JavaScript. %><% if can_create_meeting? %><% box.with_title_action do %>- <%= render 'organisations/meetings_overview/new_meeting_modal', projects: writable_meeting_projects %>+ <%= render Neo::Buttons::IconButtonComponent.new(+ variant: :primary,+ icon: 'plus-lg',+ size: :medium,+ title: t('views.organisations.meetings_overview.index.new_meeting'),+ url: organisation_meetings_path(@current_organisation, meeting_list_state.merge('new' => 'meeting')),+ data: {+ controller: 'lane-link',+ action: 'click->lane-link#click',+ lane_link_url_value: organisation_meetings_path(@current_organisation),+ lane_link_frame_value: Organisations::MeetingsController::DETAIL_FRAME_ID,+ lane_link_set_value: { new: 'meeting' }.to_json,+ lane_link_remove_value: %w[meeting_id].to_json,+ lane_link_focus_value: '#meeting-new-project'+ }+ ) %><% end %><% end %><% box.with_right_content do %>@@ -29,13 +49,14 @@<%# The words of the bar are the project page's (i18n_scope): the same list,the same sentence. Only the category "Projekt" is this page's own.- Unlike the project page, the bar stands before the first meeting too: the- "+" modal replaces only the list frame, never this head, so a bar left out- here would stay missing until a full reload.+ Unlike the project page, the bar stands before the first meeting too: a+ save from the lane replaces only the list frame, never this head, so a bar+ left out here would stay missing until a full reload.keyboard_navigation: the rows hold no link of their own (they open in thelane), so arrow down from the search field is the keyboard's way in.- meeting_id in the return context: saving a view or the expert filter comes- back with the open meeting still in the lane, as on the project page. %>+ meeting_id and new in the return context: saving a view or the expert+ filter comes back with the open meeting or the project select still in the+ lane, as on the project page. %><%= render NeoFilterBarComponent.new(current_user_id: current_user.id,smart_folders: @meeting_smart_folders,@@ -46,8 +67,8 @@smart_folder_context_type: 'Meeting',smart_folder_return_to: 'meetings',save_target_object_type: 'Meeting',- return_params: meeting_list_state.merge(params.permit(:meeting_id).to_h),- return_keys: Meetings::ListState::KEYS + %w[meeting_id],+ return_params: meeting_list_state.merge(params.permit(:meeting_id, :new).to_h),+ return_keys: Meetings::ListState::KEYS + %w[meeting_id new],active_smart_folder: @active_smart_folder,active_view_permissions: filter_bar_view_permissions(@active_smart_folder),dissolver_result: @dissolver_result,diff --git a/app/views/organisations/meetings_overview/_new_meeting_lane.html.erb b/app/views/organisations/meetings_overview/_new_meeting_lane.html.erbnew file mode 100644index 0000000..c497ab2--- /dev/null+++ b/app/views/organisations/meetings_overview/_new_meeting_lane.html.erb@@ -0,0 +1,65 @@+<%# locals: (projects:) %>+<%# "Neues Meeting" on "Alle Meetings", in the lane as on the project page+ (doc meetings_uebersicht_vereinheitlichen_plan.md, PR 4). A meeting always+ belongs to a project, so the lane asks for one first and only then loads the+ form for it. MeetingsOverviewController#index renders this for ?new=meeting,+ on a full visit and into the lane frame alike.++ The select stands OUTSIDE the frame below it on purpose: it decides what the+ frame shows, so it must survive every load of it, a refused save included.+ The frame is filled by the project-nested MeetingsController#new (frame:+ 'content') with the SAME form the project page uses, so there is no second+ copy of the meeting form. Each <option> carries its own address, built here;+ meeting-project-select only copies it onto the frame. list_context says which+ list a save redraws (MeetingList). The list state in it is the one this lane+ was opened with; layout-toggle sets the live one into the form at submit (the+ form names its project index, meetings/_meeting_new_for_frame).++ projects: where this person may WRITE meetings, nothing else+ (MeetingsOverviewController#writable_meeting_projects). Exactly one is chosen+ at once, and its form loads with the lane. %>+<% form_frame_id = Organisations::MeetingsOverviewController::NEW_FORM_FRAME_ID %>+<% context = Meetings::ListState.context_query(organisation: true) %>+<% form_urls = projects.to_h do |project|+ [project.id, new_organisation_project_meeting_path(@current_organisation, project, frame: 'content', frame_id: form_frame_id,+ **context.symbolize_keys, **meeting_list_state.symbolize_keys)]+ end %>+<% chosen = projects.one? ? projects.first : nil %>+<div class="meeting-content min-w-0 relative" data-controller="meeting-project-select">+ <%= render 'organisations/meetings/form_lane_head', new_form: true, project: nil %>+ <h2 class="text-[22px] leading-snug font-bold text-cream-900 mb-6">+ <%= t('views.organisations.meetings.index.new_meeting') %>+ </h2>++ <div class="mb-6">+ <label for="meeting-new-project" class="block text-sm font-medium text-cream-700 mb-1">+ <%= t('views.organisations.meetings_overview.new_meeting.project_label') %>+ </label>+ <select id="meeting-new-project"+ data-meeting-project-select-target="select"+ data-action="change->meeting-project-select#choose"+ 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">+ <option value=""><%= t('views.organisations.meetings_overview.new_meeting.project_prompt') %></option>+ <% projects.each do |project| %>+ <%= tag.option project.name, value: project.id, selected: project == chosen, data: { form_url: form_urls[project.id] } %>+ <% end %>+ </select>+ </div>++ <%# The frame's zero state, also put back when the choice is taken back. %>+ <% placeholder = capture do %>+ <p class="py-10 text-center text-sm text-cream-500">+ <%= t('views.organisations.meetings_overview.new_meeting.select_project_first') %>+ </p>+ <% end %>+ <template data-meeting-project-select-target="placeholder"><%= placeholder %></template>++ <%# frame-error: a denied write, a deleted project or an expired session+ answers this frame with a redirect. Without it Turbo blanks the frame to+ its bare "Content missing" and throws; with it the reader gets a message.+ Same wiring as tickets/_tickets_results.html.erb. %>+ <%= turbo_frame_tag form_frame_id, src: (form_urls[chosen.id] if chosen),+ data: { controller: 'frame-error', meeting_project_select_target: 'frame' } do %>+ <%= placeholder %>+ <% end %>+</div>diff --git a/app/views/organisations/meetings_overview/index.html.erb b/app/views/organisations/meetings_overview/index.html.erbindex 9ead5e9..2d39687 100644--- a/app/views/organisations/meetings_overview/index.html.erb+++ b/app/views/organisations/meetings_overview/index.html.erb@@ -3,10 +3,11 @@same page as the project meetings page(doc/meetings_uebersicht_vereinheitlichen_plan.md): the shared filter barabove a list frame that the bar, the column heads and the pages reload- (PR 1), the column picker (PR 2), and a row opens the meeting in the lane- beside the list (PR 3). The wrapper and the grid are the project page's- (meeting_list_page_data, meetings/_index_desktop and _index_mobile), with- this page's list in them.+ (PR 1), the column picker (PR 2), a row opens the meeting in the lane+ beside the list (PR 3), and the "+" opens a project select in the lane with+ the form of the chosen project below it (PR 4). The wrapper and the grid+ are the project page's (meeting_list_page_data, meetings/_index_desktop and+ _index_mobile), with this page's list and lane form in them.The detail in the lane is project-nested (MeetingsController) and carrieslist_context=organisation, so a save there redraws THIS list. layout-toggle@@ -19,10 +20,11 @@<%# The expert filter of the bar's view menu opens into this frame. %><turbo-frame id="modal"></turbo-frame>-<div class="labor-layout-view <%= 'show-content' if @selected_meeting %> hide-panel"+<div class="labor-layout-view <%= 'show-content' if @selected_meeting || @new_meeting_lane %> hide-panel"<%= tag.attributes(data: meeting_list_page_data(index_url: organisation_meetings_path(@current_organisation),list_frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID,- viewport_mode: @viewport_mode, selected: @selected_meeting)+ viewport_mode: @viewport_mode, selected: @selected_meeting,+ lane_forms: %w[new], new_form_open: @new_meeting_lane).merge(meeting_column_picker_data(organisation: @current_organisation, project: nil, active_view: @active_smart_folder,frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID))) %>><% list = capture do %>@@ -31,9 +33,12 @@first_use: meetings_overview_first_use? %><% end %>+ <%# "+" (?new=meeting): the project select, the form of the chosen project below it. %>+ <% lane_form = (render 'organisations/meetings_overview/new_meeting_lane', projects: writable_meeting_projects if @new_meeting_lane) %>+<% if @viewport_mode == 'mobile' %>- <%= render 'organisations/meetings/index_mobile', list: list %>+ <%= render 'organisations/meetings/index_mobile', list: list, lane_form: lane_form %><% else %>- <%= render 'organisations/meetings/index_desktop', list: list %>+ <%= render 'organisations/meetings/index_desktop', list: list, lane_form: lane_form %><% end %></div>diff --git a/config/importmap.rb b/config/importmap.rbindex c9b2581..625115d 100644--- a/config/importmap.rb+++ b/config/importmap.rb@@ -23,6 +23,9 @@ pin 'time_session_modal', to: 'lib/time_session_modal.js'# predicate, pure so spec/javascript can test them independently of the mobile# browser regressions that also run in CI.pin 'meeting_modal', to: 'lib/meeting_modal.js'+# The project select of "Neues Meeting" on "Alle Meetings": which form its frame+# shows, pure so spec/javascript can test it.+pin 'meeting_project_select', to: 'lib/meeting_project_select.js'# NeoAutosuggest's server search (the ticket picker of the "Link" modal): confirmed# choice, request sequence, debounce and abort, pure so spec/javascript can test them.pin 'autosuggest_search', to: 'lib/autosuggest_search.js'@@ -179,6 +182,7 @@ elsepin 'controllers/meeting_analysis_composer_controller', to: 'controllers/meeting_analysis_composer_controller.js'pin 'controllers/meeting_modal_controller', to: 'controllers/meeting_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'pin 'controllers/member_picker_controller', to: 'controllers/member_picker_controller.js'pin 'controllers/membership_workspace_controller', to: 'controllers/membership_workspace_controller.js'diff --git a/config/locales/views/meetings.de.yml b/config/locales/views/meetings.de.ymlindex 7d91f4b..c61f238 100644--- a/config/locales/views/meetings.de.yml+++ b/config/locales/views/meetings.de.yml@@ -201,6 +201,10 @@ de:modal_select_project_first: Wähle zuerst ein Projekt.empty_first_time_title: Noch keine Meetingsempty_first_time_description: Sobald in deinen Projekten Meetings erfasst werden, findest du sie hier projektübergreifend — zum Beispiel alle Meetings mit einer bestimmten Person.+ new_meeting:+ project_label: Projekt+ project_prompt: Projekt wählen …+ select_project_first: Wähle zuerst ein Projekt.models:view_configuration:meeting_columns:diff --git a/config/locales/views/meetings.en.yml b/config/locales/views/meetings.en.ymlindex ea933ae..0abe793 100644--- a/config/locales/views/meetings.en.yml+++ b/config/locales/views/meetings.en.yml@@ -200,6 +200,10 @@ en:modal_select_project_first: Choose a project first.empty_first_time_title: No meetings yetempty_first_time_description: As soon as meetings are recorded in your projects, you'll find them here across project boundaries — for example every meeting with a particular person.+ new_meeting:+ project_label: Project+ project_prompt: Choose a project …+ select_project_first: Choose a project first.models:view_configuration:meeting_columns:diff --git a/spec/javascript/controllers/meeting_project_select_controller.test.js b/spec/javascript/controllers/meeting_project_select_controller.test.jsnew file mode 100644index 0000000..f6b5141--- /dev/null+++ b/spec/javascript/controllers/meeting_project_select_controller.test.js@@ -0,0 +1,86 @@+// What: meeting_project_select_controller, the project select of "Neues+// Meeting" on "Alle Meetings" (meetings_overview/_new_meeting_lane).+// Type: node:test over the controller's source in a vm context, the way+// lane_link_controller.test.js does it.+// Why: the choice loads its project's form into the frame below; taking it+// back shows the zero state, also when an answer asked for before arrives+// after (Turbo cancels a frame visit only for a new one).+import { test } from "node:test"+import assert from "node:assert/strict"+import { readFileSync } from "node:fs"+import { runInNewContext } from "node:vm"+import * as lib from "../../../app/javascript/lib/meeting_project_select.js"++const source = readFileSync(new URL("../../../app/javascript/controllers/meeting_project_select_controller.js", import.meta.url), "utf8")+ .replace(/^import .*\n/gm, "")+ .replace("export default class", "class MeetingProjectSelectController")++const URL_A = "/projects/A/meetings/new?frame=content&frame_id=meeting_new_form&list_context=organisation"+const URL_B = "/projects/B/meetings/new?frame=content&frame_id=meeting_new_form&list_context=organisation"+const PLACEHOLDER = { placeholder: true }++function fixture() {+ const listeners = {}+ const frame = {+ attributes: {},+ children: ["form of A"],+ setAttribute(name, value) { this.attributes[name] = value },+ removeAttribute(name) { delete this.attributes[name] },+ replaceChildren(...nodes) { this.children = nodes },+ addEventListener(name, fn) { listeners[name] = fn },+ removeEventListener(name) { delete listeners[name] }+ }+ const options = { "": { dataset: {} }, A: { dataset: { formUrl: URL_A } }, B: { dataset: { formUrl: URL_B } } }+ const select = { value: "", get selectedOptions() { return [options[this.value]] } }+ const placeholder = { content: { cloneNode: () => PLACEHOLDER } }+ const Controller = runInNewContext(`${source}\nMeetingProjectSelectController`, { Controller: class {}, ...lib })+ const controller = new Controller()+ Object.assign(controller, { selectTarget: select, frameTarget: frame, placeholderTarget: placeholder })+ controller.connect()+ return { controller, frame, select, listeners }+}++test("a choice loads the form of its project, a new choice the other one", () => {+ const { controller, frame, select } = fixture()+ select.value = "A"+ controller.choose()+ assert.equal(frame.attributes.src, URL_A)+ select.value = "B"+ controller.choose()+ assert.equal(frame.attributes.src, URL_B)+})++test("taking the choice back shows the zero state and asks for nothing", () => {+ const { controller, frame, select } = fixture()+ select.value = "A"+ controller.choose()+ select.value = ""+ controller.choose()+ assert.equal(frame.attributes.src, undefined)+ assert.deepEqual(frame.children, [PLACEHOLDER])+})++test("an answer that arrives after the choice was taken back is put back to the zero state", () => {+ const { frame, select, listeners } = fixture()+ frame.attributes.src = URL_A+ select.value = ""+ frame.children = ["late form of A"]+ listeners["turbo:frame-load"]()+ assert.deepEqual(frame.children, [PLACEHOLDER])+ assert.equal(frame.attributes.src, undefined)+})++test("an answer for the chosen project stays", () => {+ const { frame, select, listeners } = fixture()+ select.value = "A"+ frame.attributes.src = URL_A+ frame.children = ["form of A"]+ listeners["turbo:frame-load"]()+ assert.deepEqual(frame.children, ["form of A"])+})++test("disconnect lets go of the frame", () => {+ const { controller, listeners } = fixture()+ controller.disconnect()+ assert.equal(listeners["turbo:frame-load"], undefined)+})diff --git a/spec/javascript/lib/meeting_project_select.test.js b/spec/javascript/lib/meeting_project_select.test.jsnew file mode 100644index 0000000..a56d5a2--- /dev/null+++ b/spec/javascript/lib/meeting_project_select.test.js@@ -0,0 +1,22 @@+// What: chosenFormUrl (lib/meeting_project_select.js), which form the frame+// below the project select of "Alle Meetings" shows.+// Type: node:test, pure function over a select-shaped object.+// Why: "nothing chosen" decides twice (a changed choice, a late answer), so+// every way of choosing nothing has to say null.+import { test } from "node:test"+import assert from "node:assert/strict"+import { chosenFormUrl } from "../../../app/javascript/lib/meeting_project_select.js"++const select = (option) => ({ selectedOptions: option ? [option] : [] })++test("the chosen option's address from ERB, as it stands", () => {+ const url = "/projects/p1/meetings/new?frame=content&frame_id=meeting_new_form&list_context=organisation"+ assert.equal(chosenFormUrl(select({ dataset: { formUrl: url } })), url)+})++test("the prompt, an option without an address and no select choose nothing", () => {+ assert.equal(chosenFormUrl(select({ dataset: {} })), null)+ assert.equal(chosenFormUrl(select({ dataset: { formUrl: "" } })), null)+ assert.equal(chosenFormUrl(select(null)), null)+ assert.equal(chosenFormUrl(null), null)+})diff --git a/spec/requests/organisations/meetings_overview_create_spec.rb b/spec/requests/organisations/meetings_overview_create_spec.rbindex 3fcebca..8628966 100644--- a/spec/requests/organisations/meetings_overview_create_spec.rb+++ b/spec/requests/organisations/meetings_overview_create_spec.rb@@ -2,28 +2,32 @@require 'rails_helper'-# Creating a meeting from the ORG-WIDE list ("Alle Meetings", 05.09.2026). A meeting-# always belongs to a project and this page has none, so the "+" opens a modal that-# picks a project and then loads THAT project's real form into its frame.+# Creating a meeting from the ORG-WIDE list ("Alle Meetings"). A meeting always+# belongs to a project and this page has none, so the "+" opens the lane with a+# project select (MeetingsOverviewController#index, ?new=meeting), and the frame+# below the select loads THAT project's real form (MeetingsController#new,+# frame: 'content'). Since PR 4 of doc meetings_uebersicht_vereinheitlichen_plan.md+# this is the lane, as on the project page; until then it was a modal.#-# Three guarantees carry the feature, and none is visible from the project page's+# Four guarantees carry the feature, and none is visible from the project page's# own specs:#-# 1. The select must offer exactly the projects this person may WRITE meetings in.-# Read access is not enough — the area gate would refuse the form, and the-# button would be a promise without cover.-# 2. A save from the modal must refresh the ORG-WIDE list AND leave its frame in-# place. This page has neither meetings_results nor meeting_display_frame, and-# Turbo drops a stream whose target is missing WITHOUT a word. A `replace` whose-# partial does not bring the <turbo-frame> deletes the frame, and from then on-# the filter row and every LATER save hit exactly that silent drop.-# 3. The list state must survive the whole round trip: list frame -> option URL ->-# hidden field -> refreshed list. The list frame writes its state into-# data-list-filter-query; meeting_modal_controller merges it into the option's-# URL when a project is chosen. The overview's project filter travels as-# filter[project][], which does not collide with the nested route's own-# project_id.+# 1. One address for the lane with the select, for a full visit and for the+# lane frame alike: the overview with ?new=meeting. Exactly one writable+# project is chosen at once and its form loads.+# 2. The form inside the select's frame is the project page's form without+# its lane head (the select's lane has one), and it carries the list it was+# opened from: list_context=organisation and the list state.+# 3. A save opens the new meeting in the lane and redraws THIS list, with the+# overview address carrying meeting_id, as on the project page. The list+# frame is replaced and must bring its <turbo-frame> along, or every later+# stream to it would vanish without a word.+# 4. A refused save answers into the select's frame, so the select keeps its+# project. Rights: meetings_overview_new_access_spec.rb.RSpec.describe 'Organisations::MeetingsOverview create', type: :request do+ before { Prosopite.pause } # several requests and setup writes per example+ after { Prosopite.resume }+let(:organisation) { create(:organisation) }let(:project_a) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Alpha') } }let(:project_b) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Beta') } }@@ -43,14 +47,10 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request dolet(:writer_a) { user_with(project_a => 'read_write') }let(:writer_both) { user_with(project_a => 'read_write', project_b => 'read_write') }let(:reader_a) { user_with(project_a => 'read_only') }- let(:mixed_user) { user_with(project_a => 'read_write', project_b => 'read_only') }let(:overview_path) { organisation_meetings_path(organisation) }let(:anna) { MeetingParticipant.normalize_name('Anna Müller') }-- def new_form_path_for(project)- "/projects/#{project.id}/meetings/new"- end+ let(:lane_frame) { { 'Turbo-Frame' => 'meeting_display_frame' } }# The creator is a caller's choice: hard-coding one silently drags an unrelated# user (and its role, membership and permissions) into every example.@@ -63,139 +63,195 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request doendend- # The query the modal would put on the frame for this project.- def new_url_query_for(project)- option = Nokogiri::HTML(response.body).at_css("option[value='#{project.id}'][data-new-url]")- return nil unless option+ def page_body = Capybara.string(response.body)- Rack::Utils.parse_nested_query(URI.parse(option['data-new-url']).query)+ def query_of(url) = Rack::Utils.parse_nested_query(URI.parse(url).query)++ def option_for(project)+ page_body.find("#meeting-new-project option[value='#{project.id}']", visible: :all)enddef hidden_field_value(name)Nokogiri::HTML(response.body).at_css("input[type=hidden][name='#{name}']")&.[]('value')end- describe 'the "+" and its project select' do- it 'offers the modal to someone who may write meetings' do- sign_in writer_a- get overview_path+ def streams+ Nokogiri::HTML.fragment(response.body).css('turbo-stream')+ end++ def stream(action, target)+ streams.find { |node| node['action'] == action && node['target'] == target }+ end- expect(response.body).to include('meeting-modal')- expect(response.body).to include(new_form_path_for(project_a))+ describe 'the "+"' do+ it 'opens the lane with the select at the overview address, from the address bar at click time' do+ sign_in writer_a+ get overview_path, params: { search: 'Kickoff' }++ plus = page_body.find("a[title='#{I18n.t('views.organisations.meetings_overview.index.new_meeting')}']")+ expect(plus['data-controller']).to eq('lane-link')+ expect(plus['data-lane-link-frame-value']).to eq('meeting_display_frame')+ expect(JSON.parse(plus['data-lane-link-set-value'])).to eq('new' => 'meeting')+ expect(JSON.parse(plus['data-lane-link-remove-value'])).to eq(['meeting_id'])+ expect(URI.parse(plus['data-lane-link-url-value']).path).to eq(overview_path)+ # The href is the same state for a page without JavaScript, or a new tab.+ expect(URI.parse(plus['href']).path).to eq(overview_path)+ expect(query_of(plus['href'])).to eq('new' => 'meeting', 'search' => 'Kickoff')end+ end- it 'offers nothing at all to a reader who may not write anywhere' do- sign_in reader_a- get overview_path+ describe 'the lane with the select (?new=meeting)' do+ it 'opens on a full visit, the list with its state beside it' do+ create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_both)+ sign_in writer_both+ get overview_path, params: { new: 'meeting', search: 'Kickoff' }expect(response).to have_http_status(:ok)- expect(response.body).not_to include('meeting-modal')- expect(response.body).not_to include(new_form_path_for(project_a))+ expect(page_body).to have_css('.labor-layout-view.show-content')+ expect(page_body).to have_css('#meetings_overview_results', text: 'Alpha Kickoff')+ expect(page_body).to have_css('#meeting_display_frame .meeting-content #meeting-new-project')+ expect(page_body).to have_css('#meeting_display_frame [data-lane-close]')end- it 'offers only the writable project when the user reads one and writes another' do- project_b # the readable one must exist before the request- sign_in mixed_user- get overview_path+ it 'answers the lane frame with the select alone, without the list' do+ create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_both)+ sign_in writer_both+ get overview_path, params: { new: 'meeting', frame: 'content', frame_id: 'meeting_display_frame' }, headers: lane_frame- expect(response.body).to include(new_form_path_for(project_a))- expect(response.body).not_to include(new_form_path_for(project_b))+ expect(response).to have_http_status(:ok)+ expect(page_body).to have_css('turbo-frame#meeting_display_frame #meeting-new-project')+ expect(response.body).not_to include('meetings_overview_results', 'Alpha Kickoff')end- it 'leaves the list state out of the option URL: the modal reads it from the list' do- sign_in writer_a- get overview_path, params: { search: 'Kickoff', filter: { project: [project_a.id] } }+ it 'leaves the choice open with two projects, and loads no form yet' do+ sign_in writer_both+ get overview_path, params: { new: 'meeting' }- # list_context says which list a save redraws; the list state is not in it.- expect(new_url_query_for(project_a)).to eq('frame' => 'modal', 'list_context' => 'organisation')- modal = Nokogiri::HTML(response.body).at_css('[data-controller="meeting-modal"]')- expect(modal['data-meeting-modal-list-frame-value']).to eq('meetings_overview_results')+ expect(page_body.all('#meeting-new-project option[selected]', visible: :all)).to be_empty+ inner = page_body.find('turbo-frame#meeting_new_form')+ expect(inner['src']).to be_nil+ expect(inner['data-controller']).to include('frame-error')+ expect(inner).to have_text(I18n.t('views.organisations.meetings_overview.new_meeting.select_project_first'))end- it 'writes the list state into the list frame, where the modal reads it' do- create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_a)+ it 'chooses the one writable project at once and loads its form' dosign_in writer_a- get overview_path, params: { search: 'Kickoff', filter: { project: [project_a.id] }, filter_op: { project: 'or' } }+ get overview_path, params: { new: 'meeting' }- state = Nokogiri::HTML(response.body).at_css('#meetings_overview_results [data-list-filter-query]')- expect(Rack::Utils.parse_nested_query(state['data-list-filter-query']))- .to eq('search' => 'Kickoff', 'filter' => { 'project' => [project_a.id] }, 'filter_op' => { 'project' => 'or' })+ expect(option_for(project_a)['selected']).to be_present+ inner = page_body.find('turbo-frame#meeting_new_form')+ expect(inner['src']).to eq(option_for(project_a)['data-form-url'])end- end- describe 'GET new (frame: modal)' do- it 'renders the form inside the modal frame for a writer' do+ it 'leads each option to its project form in the select frame, with the list it was opened from' do+ sign_in writer_both+ get overview_path, params: { new: 'meeting', search: 'Kickoff', filter: { project: [project_b.id] }, viewport: 'desktop' }++ url = option_for(project_a)['data-form-url']+ expect(URI.parse(url).path).to eq(new_organisation_project_meeting_path(organisation, project_a))+ # The overview's own project condition travels as filter[project][], never+ # as project_id: that is the nested route's own parameter.+ expect(query_of(url)).to eq('frame' => 'content', 'frame_id' => 'meeting_new_form', 'list_context' => 'organisation',+ 'search' => 'Kickoff', 'filter' => { 'project' => [project_b.id] }, 'viewport' => 'desktop')+ end++ it 'gives way to a meeting_id the server opens' do+ meeting = create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_a)sign_in writer_a- get new_organisation_project_meeting_path(organisation, project_a, frame: 'modal', list_context: 'organisation'),- headers: { 'Turbo-Frame' => 'meeting_modal_form' }+ get overview_path, params: { new: 'meeting', meeting_id: meeting.id }- expect(response).to have_http_status(:ok)- expect(response.body).to include('meeting_modal_form', 'meeting-form-card')- # The save must be marked as coming from the overview, or it would answer into- # frames this page does not have.- expect(hidden_field_value('list_context')).to eq('organisation')+ expect(page_body).to have_css('#meeting_display_frame h2', text: 'Alpha Kickoff')+ expect(page_body).to have_no_css('#meeting-new-project')end- it 'refuses the form to a reader (the area gate), creating no way in' do- sign_in reader_a- get new_organisation_project_meeting_path(organisation, project_a, frame: 'modal'),- headers: { 'Turbo-Frame' => 'meeting_modal_form' }+ it 'names new as a form state of the lane, and as unresolved where it did not open' do+ sign_in writer_a+ get overview_path, params: { new: 'meeting' }+ wrapper = page_body.find('.labor-layout-view')+ expect(JSON.parse(wrapper['data-lane-params'])['form']).to eq(['new'])+ expect(wrapper['data-layout-toggle-unresolved-selection-value']).to be_nil- expect(response).to have_http_status(:redirect)- expect(response.body).not_to include('meeting-form-card')+ sign_in reader_a+ get overview_path, params: { new: 'meeting' }+ expect(JSON.parse(page_body.find('.labor-layout-view')['data-layout-toggle-unresolved-selection-value']))+ .to eq('new' => 'meeting')end+ end- it 'carries the list state into the form as hidden fields, by value' do- # Second link. Asserting the field NAMES only would pass even if the values- # were cross-wired or arrived empty, the regression this example is for.+ describe 'GET new into the frame of the select' do+ it 'renders the form without a lane head of its own, for the list it was opened from' dosign_in writer_a- get new_organisation_project_meeting_path(organisation, project_a, frame: 'modal', list_context: 'organisation', search: 'Kickoff',+ get new_organisation_project_meeting_path(organisation, project_a, frame: 'content', frame_id: 'meeting_new_form',+ list_context: 'organisation', search: 'Kickoff',filter: { participant: [anna], project: [project_b.id] }),- headers: { 'Turbo-Frame' => 'meeting_modal_form' }+ headers: { 'Turbo-Frame' => 'meeting_new_form' }+ expect(response).to have_http_status(:ok)+ card = page_body.find('turbo-frame#meeting_new_form #meeting-form-card')+ expect(card).to have_css('form')+ expect(card).to have_no_css('[data-lane-close]')+ expect(card).to have_no_css('h2')+ # Which project index the form belongs to: layout-toggle sets the live list+ # state into its hidden fields at submit (lib/lane/filter_context).+ expect(card['data-lane-index-url']).to eq(organisation_project_meetings_path(organisation, project_a))+ expect(hidden_field_value('frame_id')).to eq('meeting_new_form')+ expect(hidden_field_value('list_context')).to eq('organisation')expect(hidden_field_value('search')).to eq('Kickoff')expect(hidden_field_value('filter[participant][]')).to eq(anna)expect(hidden_field_value('filter[project][]')).to eq(project_b.id)- expect(hidden_field_value('list_context')).to eq('organisation')+ end++ it 'keeps the lane head when the form is the lane itself (the project page)' do+ sign_in writer_a+ get new_organisation_project_meeting_path(organisation, project_a, frame: 'content', frame_id: 'meeting_display_frame'),+ headers: lane_frame++ card = page_body.find('turbo-frame#meeting_display_frame #meeting-form-card')+ expect(card).to have_css('[data-lane-close]')+ expect(card).to have_css('h2', text: I18n.t('views.organisations.meetings.index.new_meeting'))+ expect(card['data-lane-index-url']).to be_nilendit 'falls back to the full page for an unknown frame value instead of half a page' do- # The `case` added an implicit else: an unknown value delivers the whole- # master-detail into a frame that matches nothing in it.sign_in writer_a- get new_organisation_project_meeting_path(organisation, project_a, frame: 'bogus'),- headers: { 'Turbo-Frame' => 'meeting_modal_form' }+ get new_organisation_project_meeting_path(organisation, project_a, frame: 'modal'),+ headers: { 'Turbo-Frame' => 'meeting_new_form' }expect(response).to have_http_status(:ok)- expect(response.body).not_to include('id="meeting_modal_form"')+ expect(response.body).not_to include('<turbo-frame id="meeting_new_form"')endend- describe 'POST create from the modal' do+ describe 'POST create from the lane of the overview' dolet(:valid_params) do- { list_context: 'organisation', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current } }+ { list_context: 'organisation', frame_id: 'meeting_new_form', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current } }end- it 'creates the meeting and refreshes the org-wide list' do+ def saved = ActsAsTenant.with_tenant(organisation) { Meeting.find_by!(title: 'Kickoff Alpha') }++ it 'opens the new meeting in the lane, in the redrawn overview, at an address with meeting_id' dosign_in writer_aexpect do- post organisation_project_meetings_path(organisation, project_a), params: valid_params, as: :turbo_stream+ post organisation_project_meetings_path(organisation, project_a), params: valid_params.merge(search: 'Kickoff'), as: :turbo_streamend.to change { ActsAsTenant.with_tenant(organisation) { Meeting.count } }.by(1)expect(response.media_type).to eq('text/vnd.turbo-stream.html')- expect(response.body).to include('meetings_overview_results')- expect(response.body).to include('Kickoff Alpha')- # The modal closes itself on success, so the flash is the only confirmation- # left — asserted by its message, not by the bare word "flash", which the- # stream's own target attribute already satisfies.+ address = URI.parse(stream('replaceAddress', 'meeting_display_frame')['url'])+ expect(address.path).to eq(overview_path)+ expect(Rack::Utils.parse_nested_query(address.query)).to eq('search' => 'Kickoff', 'meeting_id' => saved.id)++ list = stream('replace', 'meetings_overview_results')+ expect(list.at_css("tr.selected-row[data-meeting-id='#{saved.id}']")).to be_present+ lane = stream('update', 'meeting_display_frame')+ expect(lane.at_css('h2').text).to include('Kickoff Alpha')expect(response.body).to include(I18n.t('flash.meetings.created'))+ # Not into the frame of the select: the lane shows the meeting, the select goes.+ expect(stream('update', 'meeting_new_form')).to be_nil+ expect(response.body).not_to include('target="meetings_results"')endit 'leaves the results turbo-frame in place, so the page still works afterwards' do- # `replace` swaps the TARGET ELEMENT. If the partial did not bring the frame,- # the first save would delete it, and from then on the filter row would aim at- # nothing and every later save would be dropped by Turbo without a word.sign_in writer_a2.times do |i|@@ -208,18 +264,7 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request doexpect(response.body).to include('Kickoff 0', 'Kickoff 1')end- it 'does not answer into the project page list, which does not exist here, nor into the lane' do- sign_in writer_a- post organisation_project_meetings_path(organisation, project_a), params: valid_params, as: :turbo_stream-- # The rows name the lane they open in (list-row), so the stream targets- # are asked, not the body: a save from the modal leaves the lane alone.- expect(response.body).to include('target="meetings_overview_results"')- expect(response.body).not_to include('target="meeting_display_frame"')- expect(response.body).not_to include('target="meetings_results"')- end-- it 'keeps an active participant filter in the refreshed list' do+ it 'keeps an active participant filter in the redrawn list' docreate_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_a, participants: ['Anna Müller'])create_meeting(project: project_a, title: 'Beta Sync', creator: writer_a, participants: ['Bert Berg'])sign_in writer_a@@ -227,15 +272,15 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request dopost organisation_project_meetings_path(organisation, project_a),params: valid_params.merge(filter: { participant: [anna] }), as: :turbo_stream- expect(response.body).to include('meetings_overview_results')- expect(response.body).to include('Alpha Kickoff')- expect(response.body).not_to include('Beta Sync')+ list = stream('replace', 'meetings_overview_results')+ expect(list.text).to include('Alpha Kickoff')+ expect(list.text).not_to include('Beta Sync')end- it 'keeps an active project filter, which travels as filter[project][]' do- # Third link. The save deliberately goes into a DIFFERENT project than the- # filter names: reading params[:project_id] instead would silently pick up the- # nested route's own parameter (the project being saved into) and look right.+ it 'keeps an active project filter, says the new meeting is hidden by it, and still opens it' do+ # The save deliberately goes into a DIFFERENT project than the filter names:+ # reading params[:project_id] instead would silently pick up the nested+ # route's own parameter (the project being saved into) and look right.create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_both)create_meeting(project: project_b, title: 'Beta Retro', creator: writer_both)sign_in writer_both@@ -243,14 +288,16 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request dopost organisation_project_meetings_path(organisation, project_a),params: valid_params.merge(filter: { project: [project_b.id] }), as: :turbo_stream- expect(response.body).to include('Beta Retro')- expect(response.body).not_to include('Alpha Kickoff')- # The saved meeting lives in project_a, which the filter excludes.- expect(response.body).not_to include('Kickoff Alpha')+ list = stream('replace', 'meetings_overview_results')+ expect(list.text).to include('Beta Retro')+ expect(list.text).not_to include('Alpha Kickoff', 'Kickoff Alpha')expect(response.body).to include(I18n.t('flash.meetings.created_hidden_by_filter'))+ expect(response.body).not_to include(I18n.t('flash.meetings.created'))+ expect(stream('update', 'meeting_display_frame').at_css('h2').text).to include('Kickoff Alpha')+ expect(query_of(stream('replaceAddress', 'meeting_display_frame')['url'])).to include('meeting_id' => saved.id)end- it 'keeps an active saved view of the overview in the refreshed list' do+ it 'keeps an active saved view of the overview in the redrawn list' docreate_meeting(project: project_b, title: 'Beta Retro', creator: writer_both)view = ActsAsTenant.with_tenant(organisation) docreate(:smart_folder, name: 'Nur Beta', user: writer_both, organisation: organisation, project: nil,@@ -264,7 +311,7 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request dopost organisation_project_meetings_path(organisation, project_b),params: valid_params.merge(smart_folder_id: view.id), as: :turbo_stream- expect(response.body).to include('Beta Retro', 'Kickoff Alpha')+ expect(stream('replace', 'meetings_overview_results').text).to include('Beta Retro', 'Kickoff Alpha')expect(response.body).to include(I18n.t('flash.meetings.created'))end@@ -275,107 +322,67 @@ RSpec.describe 'Organisations::MeetingsOverview create', type: :request doparams: valid_params.merge(filter: 'oops', sort: 'oops'), as: :turbo_streamexpect(response).to have_http_status(:ok)- expect(response.body).to include('meetings_overview_results')+ expect(stream('replace', 'meetings_overview_results')).to be_presentend- it 'keeps an active search in the refreshed list' do- create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_a)- create_meeting(project: project_a, title: 'Beta Retro', creator: writer_a)- sign_in writer_a-- post organisation_project_meetings_path(organisation, project_a),- params: valid_params.merge(search: 'Retro'), as: :turbo_stream-- expect(response.body).to include('Beta Retro')- expect(response.body).not_to include('Alpha Kickoff')- end-- it 'says so when the active filter hides the meeting that was just saved' do- # Otherwise the list re-renders as the "filter matched nothing" empty state- # and a successful save reads as a failure.- create_meeting(project: project_a, title: 'Alpha Kickoff', creator: writer_a, participants: ['Anna Müller'])- sign_in writer_a-- post organisation_project_meetings_path(organisation, project_a),- params: valid_params.merge(filter: { participant: [MeetingParticipant.normalize_name('Bert Berg')] }),- as: :turbo_stream-- expect(response.body).to include(I18n.t('flash.meetings.created_hidden_by_filter'))- expect(response.body).not_to include(I18n.t('flash.meetings.created'))- expect(response.body).to include(I18n.t('views.organisations.meetings.index.empty_no_results'))- end-- it 'answers 422 back into the modal frame on an invalid submit and creates nothing' do+ it 'answers 422 into the frame of the select on an invalid submit, and creates nothing' dosign_in writer_aexpect dopost organisation_project_meetings_path(organisation, project_a),- params: { list_context: 'organisation', meeting: { title: '', occurred_at: Time.current } },- as: :turbo_stream+ params: valid_params.deep_merge(meeting: { title: '' }), as: :turbo_streamend.not_to(change { ActsAsTenant.with_tenant(organisation) { Meeting.count } })expect(response).to have_http_status(:unprocessable_content)- expect(response.body).to include('meeting_modal_form', 'meeting-form-card')- end-- it 'denies the create to a reader and creates nothing' do- sign_in reader_a-- expect do- post organisation_project_meetings_path(organisation, project_a), params: valid_params, as: :turbo_stream- end.not_to(change { ActsAsTenant.with_tenant(organisation) { Meeting.count } })-- # Without this a 500 on the denial path would pass the example.- expect(response).to have_http_status(:redirect)+ form = stream('update', 'meeting_new_form')+ expect(form.at_css('#meeting-form-card form')).to be_present+ expect(form.at_css('[data-lane-close]')).to be_nil+ # The select stands outside this frame and is not sent again: it keeps its project.+ expect(response.body).not_to include('meeting-new-project')+ expect(stream('update', 'meeting_display_frame')).to be_nilendend- describe 'pages of the refreshed list' do+ describe 'pages of the redrawn list' doit 'point to the overview, not to the project the meeting went into' do2.times { |index| create_meeting(project: project_a, title: "Alt #{index}", creator: writer_a) }sign_in writer_apost organisation_project_meetings_path(organisation, project_a),- params: { list_context: 'organisation', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current }, items: 2 },+ params: { list_context: 'organisation', frame_id: 'meeting_new_form',+ meeting: { title: 'Kickoff Alpha', occurred_at: Time.current }, items: 2 },as: :turbo_streamnext_link = Nokogiri::HTML(response.body).at_css("a[title='#{I18n.t('views.shared.pagination_compact.next_page')}']")expect(next_link).to be_presentexpect(URI.parse(next_link['href']).path).to eq(overview_path)- expect(Rack::Utils.parse_nested_query(URI.parse(next_link['href']).query)).to include('page' => '2', 'items' => '2')+ expect(query_of(next_link['href'])).to include('page' => '2', 'items' => '2')endend- describe 'POST create from the modal without turbo (no JavaScript)' do- it 'sends a successful save back to the overview it started from' do- sign_in writer_a-- post organisation_project_meetings_path(organisation, project_a),- params: { list_context: 'organisation', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current } }-- expect(response).to redirect_to(organisation_meetings_path(organisation))- end-- it 'keeps the list state on the way back' do+ describe 'POST create without turbo (no JavaScript)' do+ it 'sends a successful save back to the overview, with the new meeting open and the list state kept' dosign_in writer_apost organisation_project_meetings_path(organisation, project_a),params: { list_context: 'organisation', meeting: { title: 'Kickoff Alpha', occurred_at: Time.current },filter: { project: [project_a.id] }, sort: { column: 'title', direction: 'asc' } }+ saved = ActsAsTenant.with_tenant(organisation) { Meeting.find_by!(title: 'Kickoff Alpha') }expect(URI.parse(response.location).path).to eq(overview_path)- expect(Rack::Utils.parse_nested_query(URI.parse(response.location).query))- .to include('filter' => { 'project' => [project_a.id] }, 'sort' => { 'column' => 'title', 'direction' => 'asc' })+ expect(query_of(response.location))+ .to include('filter' => { 'project' => [project_a.id] }, 'sort' => { 'column' => 'title', 'direction' => 'asc' },+ 'meeting_id' => saved.id)end- it 'renders the modal frame again on an invalid save' do+ it 'renders the form again on an invalid save' dosign_in writer_apost organisation_project_meetings_path(organisation, project_a),- params: { list_context: 'organisation', meeting: { title: '', occurred_at: Time.current } }+ params: { list_context: 'organisation', frame_id: 'meeting_new_form', meeting: { title: '', occurred_at: Time.current } }expect(response).to have_http_status(:unprocessable_content)- expect(response.body).to include('meeting_modal_form', 'meeting-form-card')+ expect(response.body).to include('meeting-form-card')endendenddiff --git a/spec/requests/organisations/meetings_overview_new_access_spec.rb b/spec/requests/organisations/meetings_overview_new_access_spec.rbnew file mode 100644index 0000000..f3d845c--- /dev/null+++ b/spec/requests/organisations/meetings_overview_new_access_spec.rb@@ -0,0 +1,199 @@+# frozen_string_literal: true++require 'rails_helper'++# "Neues Meeting" on "Alle Meetings": what the project select in the lane may+# name, and what its form may write (doc meetings_uebersicht_vereinheitlichen_plan.md,+# PR 4). The select offers the projects where the person may WRITE meetings, and+# nothing else, not even the name of a project they may only read. The form+# behind it is the project-nested MeetingsController#new and #create, whose own+# gates decide; list_context=organisation chooses the list a save redraws, never+# what anyone may write.+#+# Every negative assertion first proves the page or the select is there, so a+# redirect or a 404 cannot pass it in a vacuum.+RSpec.describe 'Organisations::MeetingsOverview new meeting access', :ci_guard, type: :request do+ before { Prosopite.pause } # several requests and setup writes per example+ after { Prosopite.resume }++ let(:organisation) { create(:organisation) }+ let(:project_a) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Alpha') } }+ let(:project_b) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Lesbar') } }+ let(:project_c) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Verborgen') } }+ let(:overview_path) { organisation_meetings_path(organisation) }+ let(:lane_frame) { { 'Turbo-Frame' => 'meeting_display_frame' } }++ def member_with(levels)+ user = create(:user)+ ActsAsTenant.with_tenant(organisation) do+ role = create(:role, title: "Role #{SecureRandom.hex(4)}", organisation: organisation)+ create(:membership, user: user, organisation: organisation, role: role, active: true)+ levels.each { |project, level| create(:project_permission, user: user, project: project, meetings_access: level) }+ end+ user+ end++ def page_body = Capybara.string(response.body)++ def select_options+ page_body.all('#meeting-new-project option', visible: :all).map { |option| option.text.strip }+ end++ def meeting_count+ ActsAsTenant.with_tenant(organisation) { Meeting.count }+ end++ # Writes in Alpha, reads Lesbar, and has nothing at all in Verborgen.+ let(:mixed_user) { member_with(project_a => 'read_write', project_b => 'read_only') }+ let(:reader) { member_with(project_a => 'read_only') }++ before do+ project_c+ ActsAsTenant.with_tenant(organisation) do+ create(:meeting, project: project_b, organisation: organisation, title: 'Lesbar Kickoff')+ end+ end++ describe 'the project select in the lane' do+ before { sign_in mixed_user }++ it 'names only the projects the person may write meetings in, on a full visit' do+ get overview_path, params: { new: 'meeting' }++ expect(response).to have_http_status(:ok)+ expect(page_body).to have_css('#meeting_display_frame #meeting-new-project')+ expect(select_options).to include('Projekt Alpha')+ expect(select_options).not_to include('Projekt Lesbar', 'Projekt Verborgen')+ # Readable, so the list and its filter bar may name it; the lane may not.+ expect(page_body).to have_css('#meetings_overview_results', text: 'Lesbar Kickoff')+ expect(page_body.find('#meeting_display_frame')).to have_no_text('Projekt Lesbar')+ expect(response.body).not_to include('Projekt Verborgen')+ end++ it 'names only the projects the person may write meetings in, in the lane frame' do+ get overview_path, params: { new: 'meeting', frame: 'content', frame_id: 'meeting_display_frame' }, headers: lane_frame++ expect(response).to have_http_status(:ok)+ expect(page_body).to have_css('turbo-frame#meeting_display_frame #meeting-new-project')+ expect(select_options).to include('Projekt Alpha')+ expect(response.body).not_to include('Projekt Lesbar', 'Projekt Verborgen')+ end++ it 'leads every option to the form of its own project and nowhere else' do+ get overview_path, params: { new: 'meeting' }++ urls = page_body.all('#meeting-new-project option[data-form-url]', visible: :all).map { |option| option['data-form-url'] }+ expect(urls.size).to eq(1)+ expect(URI.parse(urls.first).path).to eq(new_organisation_project_meeting_path(organisation, project_a))+ end+ end++ describe 'without the right to write meetings anywhere' do+ before { sign_in reader }++ it 'shows the list and opens nothing on a full visit with ?new=meeting' do+ ActsAsTenant.with_tenant(organisation) do+ create(:meeting, project: project_a, organisation: organisation, title: 'Alpha Kickoff')+ end+ get overview_path, params: { new: 'meeting' }++ expect(response).to have_http_status(:ok)+ expect(page_body).to have_css('#meetings_overview_results', text: 'Alpha Kickoff')+ expect(page_body).to have_css('turbo-frame#meeting_display_frame')+ expect(page_body).to have_no_css('#meeting-new-project')+ expect(page_body).to have_no_css('.labor-layout-view.show-content')+ expect(page_body).to have_no_css("a[title='#{I18n.t('views.organisations.meetings_overview.index.new_meeting')}']")+ end++ it 'answers the lane frame with no select' do+ get overview_path, params: { new: 'meeting', frame: 'content', frame_id: 'meeting_display_frame' }, headers: lane_frame++ expect(response.body).not_to include('meeting-new-project')+ expect(response.body).not_to include('Projekt Alpha')+ end+ end++ describe 'the form behind the select (MeetingsController#new, frame: content)' do+ def get_form(project)+ get new_organisation_project_meeting_path(organisation, project, frame: 'content', frame_id: 'meeting_new_form',+ list_context: 'organisation'),+ headers: { 'Turbo-Frame' => 'meeting_new_form' }+ end++ it 'renders the form for a writable project (the positive control)' do+ sign_in mixed_user+ get_form(project_a)++ expect(response).to have_http_status(:ok)+ expect(page_body).to have_css('turbo-frame#meeting_new_form #meeting-form-card form')+ end++ it 'renders no form for a project the person may only read' do+ sign_in mixed_user+ get_form(project_b)++ expect(response).to have_http_status(:redirect)+ expect(response.body).not_to include('meeting-form-card')+ end++ it 'renders no form for a project the person may not read at all' do+ sign_in mixed_user+ get_form(project_c)++ expect(response).to have_http_status(:redirect)+ expect(response.body).not_to include('meeting-form-card')+ end++ it 'renders no form for a project of another organisation' do+ other = create(:organisation)+ foreign = ActsAsTenant.with_tenant(other) { create(:project, organisation: other, name: 'Fremdprojekt') }+ sign_in mixed_user+ get_form(foreign)++ expect(response.status).to be_in([302, 403, 404])+ expect(response.body).not_to include('meeting-form-card', 'Fremdprojekt')+ end+ end++ describe 'a save into a project the select would not offer' do+ let(:params) { { list_context: 'organisation', frame_id: 'meeting_new_form', meeting: { title: 'Untergeschoben', occurred_at: Time.current } } }++ it 'saves into a writable project (the positive control)' do+ sign_in mixed_user++ expect do+ post organisation_project_meetings_path(organisation, project_a), params: params, as: :turbo_stream+ end.to change { meeting_count }.by(1)+ end++ it 'refuses a project the person may only read, with the context, and creates nothing' do+ sign_in mixed_user++ expect do+ post organisation_project_meetings_path(organisation, project_b), params: params, as: :turbo_stream+ end.not_to(change { meeting_count })+ expect(response).to have_http_status(:redirect)+ expect(response.body).not_to include('meetings_overview_results')+ end++ it 'refuses a project the person may not read, with the context, and creates nothing' do+ sign_in mixed_user++ expect do+ post organisation_project_meetings_path(organisation, project_c), params: params, as: :turbo_stream+ end.not_to(change { meeting_count })+ expect(response).to have_http_status(:redirect)+ end++ it 'refuses a project of another organisation, with the context, and creates nothing' do+ other = create(:organisation)+ foreign = ActsAsTenant.with_tenant(other) { create(:project, organisation: other) }+ sign_in mixed_user++ expect do+ post organisation_project_meetings_path(organisation, foreign), params: params, as: :turbo_stream+ end.not_to(change { Meeting.unscoped.count })+ expect(response.status).to be_in([302, 403, 404])+ end+ end+enddiff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rbindex fec201f..2ea749c 100644--- a/spec/system/meetings_overview_spec.rb+++ b/spec/system/meetings_overview_spec.rb@@ -3,13 +3,13 @@require 'rails_helper'# "Alle Meetings" in the browser (doc/meetings_uebersicht_vereinheitlichen_plan.md,-# PR 1 to 3): the shared filter bar with the condition "Projekt", a view saved-# on this page and opened again, the "+" modal, whose save must leave the list-# with the conditions it had, the column picker, and the meeting in the lane,-# whose saves redraw this list. The request specs cannot see these: the modal-# reads the list state from the list frame in JavaScript, the picker saves and-# reloads the frame from the browser, and the lane is opened, closed and-# restored by the row opener, the ✕ and Back.+# PR 1 to 4): the shared filter bar with the condition "Projekt", a view saved+# on this page and opened again, the "+" with its project select in the lane,+# whose save must leave the list with the conditions it had, the column picker,+# and the meeting in the lane, whose saves redraw this list. The request specs+# cannot see these: the "+" and the select load their frames in JavaScript, the+# picker saves and reloads the frame from the browser, and the lane is opened,+# closed and restored by the row opener, the ✕ and Back.RSpec.describe 'Meetings overview', type: :system dobefore { Prosopite.pause }after do@@ -71,21 +71,158 @@ RSpec.describe 'Meetings overview', type: :system doexpect(page).to have_no_css('[role="tab"]', text: 'Nur Alpha')end- it 'keeps the conditions of the list after a save from the "+" modal' do- page.driver.browser.manage.window.resize_to(1440, 1000)- visit organisation_meetings_path(organisation, filter: { project: [alpha.id] })- expect_titles('Alpha Kickoff')+ describe 'the "+" in the lane' do+ let(:plus) { "a[title='#{I18n.t('views.organisations.meetings_overview.index.new_meeting')}']" }+ let(:select_label) { I18n.t('views.organisations.meetings_overview.new_meeting.project_label') }++ def open_new_meeting+ find(plus).click+ expect(page).to have_css('#meeting_display_frame #meeting-new-project', wait: 5)+ end++ # The settled page: while a frame renders, the scroll bar can come and go+ # for a moment, and the page is a scroll bar wider than its box.+ def expect_no_sideways_scroll+ page.document.synchronize(5) do+ overflow = page.evaluate_script('document.documentElement.scrollWidth - document.documentElement.clientWidth')+ raise Capybara::ExpectationNotMet, "the page scrolls #{overflow} px sideways" if overflow.positive?+ end+ end++ it 'opens the select in the lane, saves into the chosen project and opens the new meeting in the list it kept' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation, filter: { project: [alpha.id] })+ expect_titles('Alpha Kickoff')++ open_new_meeting+ expect(page).to have_css('.labor-layout-view.show-content')+ expect(page).to have_current_path(/new=meeting/)+ expect(page).to have_current_path(/filter%5Bproject%5D/)+ expect_titles('Alpha Kickoff')++ select 'Projekt Alpha', from: select_label+ within('#meeting_new_form') do+ fill_in 'meeting[title]', with: 'Alpha Planung'+ click_button I18n.t('views.organisations.meetings.form.save')+ end++ expect(page).to have_css('#meeting_display_frame h2', text: 'Alpha Planung', wait: 5)+ expect(page).to have_no_css('#meeting-new-project')+ expect_titles('Alpha Planung', 'Alpha Kickoff')+ expect(page).to have_css('#meetings_overview_results tr.selected-row', text: 'Alpha Planung')+ saved = Meeting.unscoped.find_by!(title: 'Alpha Planung')+ expect(saved.project).to eq(alpha)+ expect(page).to have_current_path(/meeting_id=#{saved.id}/)+ expect(page).to have_no_current_path(/new=meeting/)+ expect(page).to have_current_path(/filter%5Bproject%5D/)+ end++ it 'says so when the new meeting is not in the filtered list, and keeps it open in the lane' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation, filter: { project: [alpha.id] })+ expect_titles('Alpha Kickoff')++ open_new_meeting+ select 'Projekt Beta', from: select_label+ within('#meeting_new_form') do+ fill_in 'meeting[title]', with: 'Beta Planung'+ click_button I18n.t('views.organisations.meetings.form.save')+ end++ expect(page).to have_css('#meeting_display_frame h2', text: 'Beta Planung', wait: 5)+ expect(page).to have_text(I18n.t('flash.meetings.created_hidden_by_filter'))+ expect_titles('Alpha Kickoff')+ end++ it 'loads the form of another project when the choice changes, and nothing when it is cleared' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation)+ open_new_meeting+ expect(page).to have_css('#meeting_new_form', text: I18n.t('views.organisations.meetings_overview.new_meeting.select_project_first'))++ select 'Projekt Alpha', from: select_label+ expect(page).to have_css("#meeting_new_form form[action$='/projects/#{alpha.id}/meetings.turbo_stream']", wait: 5)+ select 'Projekt Beta', from: select_label+ expect(page).to have_css("#meeting_new_form form[action$='/projects/#{beta.id}/meetings.turbo_stream']", wait: 5)++ select I18n.t('views.organisations.meetings_overview.new_meeting.project_prompt'), from: select_label+ expect(page).to have_no_css('#meeting_new_form form', wait: 5)+ expect(page).to have_css('#meeting_new_form', text: I18n.t('views.organisations.meetings_overview.new_meeting.select_project_first'))+ end++ it 'shows the errors of a refused save in the form, the chosen project kept' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation)+ open_new_meeting++ select 'Projekt Beta', from: select_label+ within('#meeting_new_form') do+ fill_in 'meeting[title]', with: ''+ click_button I18n.t('views.organisations.meetings.form.save')+ end++ expect(page).to have_css('#meeting_new_form #meeting-form-card .bg-red-50', wait: 5)+ expect(page).to have_select(select_label, selected: 'Projekt Beta')+ expect(Meeting.unscoped.count).to eq(2)+ end++ it 'closes with Abbrechen: the lane shuts, new leaves the address, the list keeps its state' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation, search: 'Alpha')+ expect_titles('Alpha Kickoff')++ open_new_meeting+ select 'Projekt Alpha', from: select_label+ within('#meeting_new_form') { click_link I18n.t('views.organisations.meetings.form.cancel') }++ expect(page).to have_no_css('#meeting-new-project', wait: 5)+ expect(page).to have_no_css('.labor-layout-view.show-content')+ expect(page).to have_no_current_path(/new=meeting/)+ expect(page).to have_current_path(/search=Alpha/)+ expect_titles('Alpha Kickoff')+ end- find("button[title='#{I18n.t('views.organisations.meetings_overview.index.new_meeting')}']").click- select 'Projekt Alpha', from: 'meeting-modal-project'- within('#meeting_modal_form') do- fill_in 'meeting[title]', with: 'Alpha Planung'- click_button I18n.t('views.organisations.meetings.form.save')+ it 'opens the select on a full visit with ?new=meeting' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit organisation_meetings_path(organisation, new: 'meeting', search: 'Alpha')++ expect(page).to have_css('#meeting_display_frame #meeting-new-project', wait: 5)+ expect(page).to have_css('.labor-layout-view.show-content')+ expect_titles('Alpha Kickoff')end- expect(page).to have_no_css('[data-meeting-modal-target="modal"]:not(.hidden)', wait: 5)- expect_titles('Alpha Planung', 'Alpha Kickoff')- expect(page).to have_current_path(/filter%5Bproject%5D/)+ it 'opens full width on a phone of 390 px, and Abbrechen and Speichern lead back to the list with its search' do+ page.driver.browser.manage.window.resize_to(390, 844)+ # In the phone layout from the start: without it the viewport controller+ # swaps the page for that layout a moment after the rows show.+ visit organisation_meetings_path(organisation, search: 'Alpha', viewport: 'mobile')+ expect(page).to have_css('#meetings_overview_results tr[data-meeting-id]', count: 1, wait: 10)++ open_new_meeting+ expect(page).to have_no_css('#meetings_overview_results tr[data-meeting-id]')+ expect(page).to have_current_path(/new=meeting/)+ select 'Projekt Alpha', from: select_label+ expect(page).to have_css('#meeting_new_form form', wait: 5)+ expect_no_sideways_scroll++ within('#meeting_new_form') { click_link I18n.t('views.organisations.meetings.form.cancel') }+ expect(page).to have_css('#meetings_overview_results tr[data-meeting-id]', count: 1, wait: 10)+ expect(page).to have_current_path(/search=Alpha/)+ expect(page).to have_no_current_path(/new=meeting/)++ open_new_meeting+ select 'Projekt Alpha', from: select_label+ within('#meeting_new_form') do+ fill_in 'meeting[title]', with: 'Alpha Handy'+ click_button I18n.t('views.organisations.meetings.form.save')+ end+ expect(page).to have_css('#meeting_display_frame h2', text: 'Alpha Handy', wait: 5)+ expect_no_sideways_scroll++ find('.mobile-ticket-view a', text: I18n.t('views.organisations.meetings.index.mobile_list_view'), match: :first).click+ expect(page).to have_css('#meetings_overview_results tr[data-meeting-id]', text: 'Alpha Handy', wait: 10)+ expect(page).to have_current_path(/search=Alpha/)+ endendit 'keeps a sort chosen at a column head through a new condition and a reload' do@@ -381,25 +518,6 @@ RSpec.describe 'Meetings overview', type: :system doexpect(page).to have_css("#{overview_rows}.selected-row", text: 'Alpha Kickoff')end- it 'leaves the open lane and its unsaved edit alone when Escape closes the "+" modal' do- page.driver.browser.manage.window.resize_to(1440, 1000)- visit organisation_meetings_path(organisation)- expect_titles('Alpha Kickoff', 'Beta Retro', 'Alpha Ohne Anna')- row_of('Beta Retro').click- expect(lane_title).to have_text('Beta Retro')- within('#meeting_display_frame') { find("a[title='#{I18n.t('views.organisations.meetings.show.edit_meeting')}']", match: :first).click }- within('#meeting_display_frame') { fill_in 'meeting[title]', with: 'Ungespeichert' }-- find("button[title='#{I18n.t('views.organisations.meetings_overview.index.new_meeting')}']").click- expect(page).to have_css('[data-meeting-modal-target="modal"]:not(.hidden)', wait: 5)- page.send_keys(:escape)-- expect(page).to have_no_css('[data-meeting-modal-target="modal"]:not(.hidden)', wait: 5)- expect(page).to have_css('.labor-layout-view.show-content')- expect(find('#meeting_display_frame').find_field('meeting[title]').value).to eq('Ungespeichert')- expect(page).to have_current_path(/meeting_id=#{meeting('Beta Retro').id}/)- end-it 'opens the meeting full width on a phone and leads back to the list with its search' dopage.driver.browser.manage.window.resize_to(390, 844)visit organisation_meetings_path(organisation, search: 'Alpha')