Skip to content

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

Keep the overview context through refreshes, and the open meeting through a view save

Guido Boyke474a4b9d29d9
diff --git a/app/controllers/concerns/CLAUDE.md b/app/controllers/concerns/CLAUDE.md
index 2e4b666..9aed003 100644
--- a/app/controllers/concerns/CLAUDE.md
+++ b/app/controllers/concerns/CLAUDE.md
@@ -70,7 +70,11 @@ direkt, Notifications = bespoke + `MasterListPresenter`, Meetings =
(`meeting_list_project` = `@project`) und „Alle Meetings“ (`nil`). Seit PR 3 öffnet auch die
Übersicht das Meeting in der Bahn; Detail und Schreibwege bleiben projektverschachtelt
(`MeetingsController`), und die Bahn trägt `list_context=organisation`
-(`Meetings::ListState`, ein erlaubter Wert, nur verglichen). `meeting_organisation_list?`
+(`Meetings::ListState`, ein erlaubter Wert, nur verglichen). Getragen wird er zweimal: der
+Server schreibt ihn in die Links und Formulare, die er für eine Anfrage MIT Kontext rendert
+(`meeting_lane_state`), und `layout-toggle` hängt ihn bei Klick und Absenden an jede Anfrage
+der Bahn (`laneContext`, aus `meeting_list_page_data`). Das Zweite fängt, was ohne Kontext
+gerendert wurde: Broadcasts, Abschnitts-Aktualisierungen, Controller-Ersetzungen. `meeting_organisation_list?`
ist die EINE Frage „welche Liste?“ für Stream, Weiterleitung und Rückweg (Bahn und Modal;
das frühere `context=overview_modal` ist darin aufgegangen). Der Kontext wählt nur die
Liste, die Rechte bleiben die des Projekts (`set_meeting`, Bereichs-Tor). Eine
diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rb
index 85d8321..2c65a78 100644
--- a/app/helpers/meetings_helper.rb
+++ b/app/helpers/meetings_helper.rb
@@ -72,6 +72,10 @@ module MeetingsHelper
# the page (meeting_column_picker_data).
def meeting_list_page_data(index_url:, list_frame_id:, viewport_mode:, lane_forms: [])
detail_frame_id = Organisations::MeetingsController::DETAIL_FRAME_ID
+ # Which list the lane belongs to, added by layout-toggle to every request of
+ # the lane at click and submit: also to a link rendered without it (a
+ # broadcast, a section refresh). None on the project page.
+ lane_context = Meetings::ListState.context_query(organisation: meeting_organisation_list?)
{
controller: 'layout-toggle hover-arrows index-page keyboard-navigation viewport column-picker',
hover_arrows_layout_toggle_outlet: '.labor-layout-view',
@@ -83,6 +87,7 @@ module MeetingsHelper
layout_toggle_list_filter_params_value: Meetings::ListState::KEYS.to_json,
layout_toggle_storage_key_value: 'layoutState:meetings',
layout_toggle_clear_detail_on_close_value: 'true',
+ layout_toggle_lane_context_value: (lane_context.to_json if lane_context.any?),
viewport_breakpoint_value: LANE_FULL_PAGE_BELOW_PX,
index_page_param_name_value: 'meeting_id',
index_page_frame_id_value: detail_frame_id,
@@ -96,7 +101,7 @@ module MeetingsHelper
viewport_current_mode_value: viewport_mode,
index_url: index_url,
lane_params: lane_params_json(selection: %w[meeting_id], form: lane_forms)
- }
+ }.compact
end
# The placeholders column_picker_controller fills in itself, passed through
diff --git a/app/javascript/controllers/CLAUDE.md b/app/javascript/controllers/CLAUDE.md
index ee2128c..1131af0 100644
--- a/app/javascript/controllers/CLAUDE.md
+++ b/app/javascript/controllers/CLAUDE.md
@@ -390,6 +390,11 @@ die Sidebar-Zeile liegt in der Navigation. Damit sind sie NICHT im selben Stimul
Löschen in der Bahn schickt `closeLane` (application.js): `layout_toggle#closeLane` schließt
und nimmt `meeting_id` im SELBEN Eintrag aus der Adresse. `list_address` ist gelöscht, die
Übersicht hat wie die Projektseite EINEN Adress-Schreiber (`layout_toggle#syncUrlFromFrame`).
+ Dazu hängt `syncFilterContext` den Wert `laneContext` (bei der Übersicht
+ `{"list_context":"organisation"}`) an jede Anfrage der fremden Bahn, auch an Links aus
+ Broadcasts und Abschnitts-Aktualisierungen, die ohne Kontext gerendert wurden. Sonst lädt ein
+ Klick auf „aktualisieren“ die Bahn im Projektmodus, und das nächste Speichern zeichnet die
+ Liste der Übersicht nicht neu.
## Mobile Anwendung (PR #807)
diff --git a/app/javascript/controllers/layout_toggle_controller.js b/app/javascript/controllers/layout_toggle_controller.js
index 9c7c015..b4837bd 100644
--- a/app/javascript/controllers/layout_toggle_controller.js
+++ b/app/javascript/controllers/layout_toggle_controller.js
@@ -42,7 +42,12 @@ export default class extends Controller {
// Tickets/Knowledge keep the shared default; Meetings mounts its own key. A grid
// WITHOUT a panel column never
// opens one, whatever the stored state says: see hasPanelColumn().
- storageKey: { type: String, default: "layoutState" }
+ storageKey: { type: String, default: "layoutState" },
+ // Parameters every request of a lane of another list carries, added at
+ // click and submit (syncFilterContext): "Alle Meetings" says
+ // list_context=organisation, so a save in its lane redraws that list, also
+ // from a link a broadcast or a section refresh rendered without it.
+ laneContext: { type: Object, default: {} }
}
connect() {
@@ -274,6 +279,7 @@ export default class extends Controller {
const laneIndexUrls = [...this.element.querySelectorAll('[data-lane-index-url]')].map(head => head.dataset.laneIndexUrl)
const indexes = indexPaths(this.element.dataset.indexUrl, laneIndexUrls, current.origin)
+ const ownIndex = new URL(this.element.dataset.indexUrl, current.origin).pathname
for (const control of this.element.querySelectorAll('a[href], form[action], button[formaction]')) {
const isForm = control.tagName === 'FORM'
if (isForm && control.method.toLowerCase() === 'get') continue
@@ -303,10 +309,25 @@ export default class extends Controller {
}
}
}
+ if (index !== ownIndex) this.applyLaneContext(control, address, isForm)
control.setAttribute(attribute, address.toString())
}
}
+ applyLaneContext(control, address, isForm) {
+ for (const [name, value] of Object.entries(this.laneContextValue)) {
+ address.searchParams.set(name, value)
+ if (!isForm) continue
+
+ control.querySelectorAll('input[type="hidden"]').forEach(input => { if (input.name === name) input.remove() })
+ const input = document.createElement('input')
+ input.type = 'hidden'
+ input.name = name
+ input.value = value
+ control.append(input)
+ }
+ }
+
listFilterNames(...sources) {
const names = new Set(this.listFilterParamsValue)
for (const source of sources) {
diff --git a/app/views/organisations/meetings_overview/_list_head.html.erb b/app/views/organisations/meetings_overview/_list_head.html.erb
index c4b44d7..3aabc0a 100644
--- a/app/views/organisations/meetings_overview/_list_head.html.erb
+++ b/app/views/organisations/meetings_overview/_list_head.html.erb
@@ -33,7 +33,9 @@
"+" modal 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 the
- lane), so arrow down from the search field is the keyboard's way in. %>
+ lane), 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. %>
<%= render NeoFilterBarComponent.new(
current_user_id: current_user.id,
smart_folders: @meeting_smart_folders,
@@ -44,8 +46,8 @@
smart_folder_context_type: 'Meeting',
smart_folder_return_to: 'meetings',
save_target_object_type: 'Meeting',
- return_params: meeting_list_state,
- return_keys: Meetings::ListState::KEYS,
+ return_params: meeting_list_state.merge(params.permit(:meeting_id).to_h),
+ return_keys: Meetings::ListState::KEYS + %w[meeting_id],
active_smart_folder: @active_smart_folder,
active_view_permissions: filter_bar_view_permissions(@active_smart_folder),
dissolver_result: @dissolver_result,
diff --git a/spec/javascript/controllers/layout_toggle_controller.test.js b/spec/javascript/controllers/layout_toggle_controller.test.js
index edf4054..341cdc6 100644
--- a/spec/javascript/controllers/layout_toggle_controller.test.js
+++ b/spec/javascript/controllers/layout_toggle_controller.test.js
@@ -20,6 +20,7 @@ function controllerWith(document, { window = {}, groups = null, element = null }
})
const controller = new Controller()
controller.listFilterParamsValue = []
+ controller.laneContextValue = {}
controller.element = element || { dataset: {}, dispatchEvent: () => {} }
return controller
}
@@ -312,6 +313,56 @@ test('a lane of another list takes the list state on the index its head names',
assert.equal(stale.href, '/org/o/projects/p/meetings/M/edit.turbo_stream?search=Alt')
})
+test('every request of a lane of another list carries the lane context, also from a link rendered without it', () => {
+ const current = new URL('http://lalabase.test/org/o/meetings?search=Neu')
+ const inputs = []
+ const document = {
+ createElement: () => ({ remove() { inputs.splice(inputs.indexOf(this), 1) } })
+ }
+ const control = (tagName, href) => ({
+ tagName, href, method: 'post',
+ getAttribute() { return this.href },
+ setAttribute(_name, value) { this.href = value },
+ matches() { return false },
+ querySelectorAll: () => tagName === 'FORM' ? [...inputs] : [],
+ append(input) { inputs.push(input) }
+ })
+ // Rendered by a broadcast or a section refresh, which know no context.
+ const refresh = control('A', '/org/o/projects/p/meetings/M/ticket_suggestions')
+ const save = control('FORM', '/org/o/projects/p/meetings/M')
+ const nextPage = control('A', '/org/o/meetings?page=2')
+ const ticket = control('A', '/org/o/projects/p/tickets/T')
+ const head = { dataset: { laneIndexUrl: '/org/o/projects/p/meetings' } }
+ const element = {
+ dataset: { indexUrl: '/org/o/meetings' },
+ querySelectorAll: selector => selector === '[data-lane-index-url]' ? [head] : [refresh, save, nextPage, ticket]
+ }
+ const controller = controllerWith(document, { element })
+ controller.listFilterParamsValue = ['search']
+ controller.laneContextValue = { list_context: 'organisation' }
+
+ controller.syncFilterContext(current)
+ controller.syncFilterContext(current)
+
+ assert.equal(new URL(refresh.href).searchParams.get('list_context'), 'organisation')
+ assert.equal(new URL(save.href).searchParams.get('list_context'), 'organisation')
+ const contextInputs = inputs.filter(input => input.name === 'list_context')
+ assert.equal(contextInputs.length, 1)
+ assert.equal(contextInputs[0].value, 'organisation')
+ assert.equal(nextPage.href, '/org/o/meetings?page=2')
+ assert.equal(ticket.href, '/org/o/projects/p/tickets/T')
+
+ // The project page has no lane context: its lane's links stay as they are.
+ const own = control('A', '/org/o/projects/p/meetings/M/ticket_suggestions')
+ const projectPage = controllerWith(document, {
+ element: { dataset: { indexUrl: '/org/o/projects/p/meetings' }, querySelectorAll: selector => selector === '[data-lane-index-url]' ? [] : [own] }
+ })
+ projectPage.listFilterParamsValue = ['search']
+ projectPage.laneContextValue = {}
+ projectPage.syncFilterContext(new URL('http://lalabase.test/org/o/projects/p/meetings'))
+ assert.equal(new URL(own.href).searchParams.has('list_context'), false)
+})
+
test('closing a lane whose object is gone takes it out of the address in the same entry', () => {
const current = new URL('http://lalabase.test/org/o/meetings?search=x&meeting_id=M')
const calls = []
diff --git a/spec/requests/organisations/meetings_overview_lane_spec.rb b/spec/requests/organisations/meetings_overview_lane_spec.rb
index f92eabd..b0d5847 100644
--- a/spec/requests/organisations/meetings_overview_lane_spec.rb
+++ b/spec/requests/organisations/meetings_overview_lane_spec.rb
@@ -79,6 +79,22 @@ RSpec.describe 'Organisations::MeetingsOverview lane', type: :request do
expect(page_body).to have_css("turbo-frame#meetings_overview_results[data-keyboard-navigation-target='listContainer']")
end
+ # A link the server renders without the request's context (a broadcast, a
+ # section refresh) must still carry it: layout-toggle adds the lane context
+ # to every request of the lane at click and submit.
+ it 'gives the lane its context as data, and the project page none' do
+ get overview_path
+
+ wrapper = page_body.find('.labor-layout-view')
+ expect(JSON.parse(wrapper['data-layout-toggle-lane-context-value'])).to eq('list_context' => 'organisation')
+
+ get organisation_project_meetings_path(organisation, project_a)
+
+ wrapper = page_body.find('.labor-layout-view')
+ expect(wrapper['data-layout-toggle-list-frame-ids-value']).to be_present
+ expect(wrapper['data-layout-toggle-lane-context-value']).to be_nil
+ end
+
it 'opens a row in the lane: list-row with the project-nested detail address and the context' do
get overview_path
@@ -258,6 +274,24 @@ RSpec.describe 'Organisations::MeetingsOverview lane', type: :request do
end
end
+ describe 'saving a view with a meeting open in the lane' do
+ it 'lets the filter bar carry the open meeting, and the save return with it open' do
+ get overview_path, params: { meeting_id: alpha.id, search: 'Alpha' }
+
+ bar = page_body.find('[data-controller~="filter-bar"]')
+ expect(JSON.parse(bar['data-filter-bar-return-keys-value'])).to include('meeting_id', *Meetings::ListState::KEYS)
+
+ post create_from_filters_organisation_smart_folders_path(organisation), params: {
+ return_to: 'meetings', target_object_type: 'Meeting', smart_folder_name: 'Mit Anna',
+ filter: { participant: ['Anna'] }, list_context: { search: 'Alpha', meeting_id: alpha.id }
+ }
+
+ expect(query_of(response.location)).to include('meeting_id' => alpha.id, 'search' => 'Alpha')
+ follow_redirect!
+ expect(page_body).to have_css('#meeting_display_frame h2', text: 'Alpha Kickoff')
+ end
+ end
+
describe 'the context the lane forwards' do
it 'sends a full page of the project route with the context to the overview' do
get organisation_project_meetings_path(organisation, project_a, list_context: 'organisation', search: 'Kick', meeting_id: alpha.id)
diff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rb
index db2de34..9c47c66 100644
--- a/spec/system/meetings_overview_spec.rb
+++ b/spec/system/meetings_overview_spec.rb
@@ -213,6 +213,56 @@ RSpec.describe 'Meetings overview', type: :system do
expect(page).to have_current_path(/meeting_id=/)
end
+ it 'keeps the overview context through a link rendered without it' 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')
+
+ # What a section refresh or a broadcast renders: the detail address
+ # without list_context, since neither knows which list is open.
+ beta = meeting('Beta Retro')
+ href = organisation_project_meeting_path(organisation, beta.project_id, beta, frame: 'content')
+ page.execute_script(<<~JS, href)
+ const link = document.createElement('a')
+ link.id = 'contextless-refresh'
+ link.href = arguments[0]
+ link.dataset.turboFrame = 'meeting_display_frame'
+ link.textContent = 'aktualisieren'
+ document.getElementById('meeting_display_frame').append(link)
+ JS
+ find('#contextless-refresh').click
+ expect(page).to have_no_css('#contextless-refresh', wait: 5)
+ expect(lane_title).to have_text('Beta Retro')
+
+ edit = "a[title='#{I18n.t('views.organisations.meetings.show.edit_meeting')}']"
+ within('#meeting_display_frame') { find(edit, match: :first).click }
+ within('#meeting_display_frame') do
+ fill_in 'meeting[title]', with: 'Beta Retro neu'
+ click_button I18n.t('views.organisations.meetings.form.save')
+ end
+
+ expect(page).to have_css('#meeting_display_frame h2', text: 'Beta Retro neu', wait: 5)
+ expect_titles('Alpha Kickoff', 'Beta Retro neu', 'Alpha Ohne Anna')
+ end
+
+ it 'keeps the open meeting when the list is saved as a view' do
+ page.driver.browser.manage.window.resize_to(1440, 1000)
+ visit organisation_meetings_path(organisation, filter: { participant: ['Anna'] })
+ expect_titles('Alpha Kickoff', 'Beta Retro')
+ row_of('Beta Retro').click
+ expect(lane_title).to have_text('Beta Retro')
+
+ click_button 'Als Ansicht sichern'
+ fill_in 'smart_folder_name', with: 'Mit Anna'
+ click_button 'Sichern'
+
+ expect(page).to have_css('[role="tab"][aria-selected="true"]', text: 'Mit Anna', wait: 5)
+ expect(lane_title).to have_text('Beta Retro')
+ expect(page).to have_current_path(/meeting_id=#{meeting('Beta Retro').id}/)
+ end
+
it 'keeps a condition set beside the open lane through a save in it' do
page.driver.browser.manage.window.resize_to(1440, 1000)
visit organisation_meetings_path(organisation)