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 the project page's new-meeting form as a lane state
Guido Boykea971d39b2f5b
diff --git a/app/controllers/organisations/meetings_controller.rb b/app/controllers/organisations/meetings_controller.rbindex 83d704e..9b6106a 100644--- a/app/controllers/organisations/meetings_controller.rb+++ b/app/controllers/organisations/meetings_controller.rb@@ -103,9 +103,11 @@ module Organisationsreturnend- # The list header normally opens the form in the desktop detail frame. On a- # phone that frame is absent from the list DOM, so the top-level request turns- # the form into an explicit index-page state while retaining active filters.+ # The first-use CTA of an empty list opens the form in the desktop detail+ # frame (the list head's "+" is a lane-link to ?new=meeting itself). On a+ # phone that frame is absent from the list DOM, so the top-level request+ # turns the form into an explicit index-page state while retaining active+ # filters.if params[:frame] == 'content'redirect_to organisation_project_meetings_path(@current_organisation,diff --git a/app/javascript/controllers/lane_link_controller.js b/app/javascript/controllers/lane_link_controller.jsindex e7539b3..76071c6 100644--- a/app/javascript/controllers/lane_link_controller.js+++ b/app/javascript/controllers/lane_link_controller.js@@ -20,10 +20,10 @@ import { readLaneParams, laneParamNames, withLaneState } from "lane/params"// focus a selector to focus once the frame has loaded (the way back returns// the focus to the file name that opened the preview, D10)//-// A link that removes a selection parameter (the "+" of "Alle Meetings" takes-// meeting_id away) leaves no row open, so it takes the mark off the row that-// was (.selected-row, list_row_controller). The address is the truth, and a-// full visit of the new address marks no row either.+// A link that removes a selection parameter (the "+" of either meetings page+// takes meeting_id away) leaves no row open, so it takes the mark off the row+// that was (.selected-row, list_row_controller). The address is the truth, and+// a full visit of the new address marks no row either.export default class extends Controller {static values = {url: String,diff --git a/app/views/organisations/meetings/_list_head.html.erb b/app/views/organisations/meetings/_list_head.html.erbindex e5de8fb..7587823 100644--- a/app/views/organisations/meetings/_list_head.html.erb+++ b/app/views/organisations/meetings/_list_head.html.erb@@ -11,23 +11,30 @@context_type: :meetings,margin_bottom: 'mb-3.5') do |header| %>- <% new_entry_frame = @viewport_mode == 'mobile' ? '_top' : 'meeting_display_frame' %>+ <%# The "+" opens the form as a state of the lane (?new=meeting), as the "+"+ of "Alle Meetings" opens its project select: a lane-link, so the address+ says new instead of the meeting that was open, and that meeting's row+ loses its mark. The address bar at click time gives the list state, and+ below the lane width the page itself is visited. The href is the same+ state for a new tab, a page without JavaScript and the phone layout,+ which has no lane. %><% if policy(@project).area_access?(:meetings, :write) %><% header.with_title_action do %>+ <% lane_data = {+ controller: 'lane-link',+ action: 'click->lane-link#click',+ lane_link_url_value: new_organisation_project_meeting_path(@current_organisation, @project),+ 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+ } %><%= render Neo::Buttons::IconButtonComponent.new(variant: :primary,icon: 'plus-lg',size: :medium,title: t('views.organisations.meetings.index.new_meeting'),- url: new_organisation_project_meeting_path(- @current_organisation,- @project,- frame: 'content',- frame_id: 'meeting_display_frame',- **meeting_list_state.symbolize_keys,- viewport: @viewport_mode- ),- data: { turbo_frame: new_entry_frame }+ url: organisation_project_meetings_path(@current_organisation, @project, meeting_list_state.merge('new' => 'meeting')),+ data: @viewport_mode == 'mobile' ? { turbo_frame: '_top' } : lane_data) %><% end %><% end %>diff --git a/spec/requests/organisations/meetings_lane_spec.rb b/spec/requests/organisations/meetings_lane_spec.rbindex 455b5f3..587287d 100644--- a/spec/requests/organisations/meetings_lane_spec.rb+++ b/spec/requests/organisations/meetings_lane_spec.rb@@ -113,6 +113,22 @@ RSpec.describe 'Meetings detail lane', type: :request doexpect(page).to have_no_css('.mobile-list-view', visible: :all)end+ # The phone layout has no lane: its "+" is the page with the form state,+ # the list state kept, and that page shows the form as the mobile detail.+ it 'leads the mobile "+" to the page with the form state' do+ get meetings_path(search: 'alpha', viewport: 'mobile')++ plus = page.find("a[title='#{I18n.t('views.organisations.meetings.index.new_meeting')}']")+ expect(plus['data-turbo-frame']).to eq('_top')+ expect(plus['data-controller']).to be_nil+ uri = URI.parse(plus[:href])+ expect(uri.path).to eq(meetings_path)+ expect(Rack::Utils.parse_nested_query(uri.query)).to eq('search' => 'alpha', 'viewport' => 'mobile', 'new' => 'meeting')++ get plus[:href]+ expect(page).to have_css('.mobile-detail-view #meeting-form-card.meeting-content')+ end+it 'closes a desktop new form through a filter-preserving URL without form state' doget meetings_path(new: 'meeting', search: 'alpha', participant: 'anna', viewport: 'desktop')diff --git a/spec/system/meeting_filters_columns_spec.rb b/spec/system/meeting_filters_columns_spec.rbindex d4c7b69..07bddf2 100644--- a/spec/system/meeting_filters_columns_spec.rb+++ b/spec/system/meeting_filters_columns_spec.rb@@ -203,4 +203,48 @@ RSpec.describe 'Meeting filters and columns', type: :system dorow.send_keys(:enter)expect(page).to have_css('#meeting-header', text: title)end++ # The "+" puts the form where the open meeting was: the address has to say+ # so (new instead of meeting_id), and the meeting's row may not stay marked.+ # A reload of that address shows the form, with the list state kept.+ it 'opens the form from the "+" in place of the open meeting' do+ page.driver.browser.manage.window.resize_to(1440, 1000)+ visit path(search: 'a', search_mode: 'title_only')+ # The rows show before their scripts listen: a click before that opens nothing.+ page.document.synchronize do+ connected = page.evaluate_script(<<~JS)+ Boolean(window.Stimulus?.getControllerForElementAndIdentifier(document.querySelector('tr[data-meeting-id]'), 'list-row'))+ JS+ raise Capybara::ExpectationNotMet, 'the row controller is not connected yet' unless connected+ end+ find("tr[data-meeting-id='#{meetings.second.id}']").click+ expect(page).to have_css('tr.selected-row', text: 'Beta', wait: 5)+ expect(page).to have_css('#meeting-header', text: 'Beta', wait: 5)++ plus = "a[title='#{I18n.t('views.organisations.meetings.index.new_meeting')}']"+ # The lane opens with a width transition (layout.css, --panel-width), and+ # the "+" moves with the list column until it ends.+ page.document.synchronize(5) do+ left = -> { page.evaluate_script("document.querySelector(\"#{plus}\").getBoundingClientRect().left") }+ before = left.call+ sleep 0.15+ raise Capybara::ExpectationNotMet, 'the "+" is still moving' unless left.call == before+ end+ # A full visit of the href would show the same state: the marker proves+ # the lane opened the form in place.+ page.execute_script('window.laneStayed = true')+ find(plus).click++ expect(page).to have_css('#meeting_display_frame #meeting-form-card form', wait: 5)+ expect(page.evaluate_script('window.laneStayed')).to be(true)+ expect(page).to have_no_css('tr.selected-row')+ expect(page).to have_current_path(/[?&]new=meeting/, url: true)+ expect(page).to have_no_current_path(/meeting_id=/, url: true)+ expect(page).to have_current_path(/search_mode=title_only/, url: true)++ page.refresh+ expect(page).to have_css('#meeting_display_frame #meeting-form-card form', wait: 5)+ expect(page).to have_no_css('tr.selected-row')+ expect(find('input[name="search"]').value).to eq('a')+ endend