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.

Fix four review findings on the "Alle Meetings" filter bar

Guido Boyke66d935a6b102
diff --git a/app/helpers/smart_folder_helper.rb b/app/helpers/smart_folder_helper.rb
index 5c889b7..b311282 100644
--- a/app/helpers/smart_folder_helper.rb
+++ b/app/helpers/smart_folder_helper.rb
@@ -158,6 +158,12 @@ module SmartFolderHelper
base_scope = model_class.all
base_scope = base_scope.where(organisation_id: organisation.id) if model_class.column_names.include?('organisation_id')
+ # A project reference without a given reach is the reader's reach in the
+ # area, never the whole organisation: the server-rendered expert form
+ # (smart_folder_rules/_rule_fields) passes no list, and the project names
+ # and ids of a project the reader cannot read are not theirs to see.
+ accessible_project_ids = AccessCheck::ProjectAccessService.accessible_project_ids(current_user, organisation, action: :read, area: area) if model_class == Project && accessible_project_ids.nil?
+
# Restrict references to accessible projects. Scope user references (e.g.
# assignee) to the people visible to the current user — otherwise the
# reference list leaks names/emails of users from other projects (even other orgs).
diff --git a/app/javascript/controllers/list_address_controller.js b/app/javascript/controllers/list_address_controller.js
new file mode 100644
index 0000000..431d9b2
--- /dev/null
+++ b/app/javascript/controllers/list_address_controller.js
@@ -0,0 +1,56 @@
+import { Controller } from "@hotwired/stimulus"
+import { listAddress } from "list_address"
+
+/**
+ * List Address Controller
+ *
+ * Keeps the address of a list page without a lane ("Alle Meetings") equal to
+ * the list it shows. Whenever the list frame is loaded (filter bar, column head,
+ * page link) or replaced by a stream (a save from the "+" modal), the address
+ * becomes the page's path with the state the frame rendered. The entry is
+ * replaced, not added, and keeps its history state; lane:list-changed tells
+ * index-page which list part the page now shows (its Back/Forward restorer).
+ *
+ * Values:
+ * frame the id of the list frame
+ * path the page's path, without query
+ */
+export default class extends Controller {
+ static values = { frame: String, path: String }
+
+ connect() {
+ this.handleFrameLoad = this.handleFrameLoad.bind(this)
+ this.handleStream = this.handleStream.bind(this)
+ document.addEventListener("turbo:frame-load", this.handleFrameLoad)
+ document.addEventListener("turbo:before-stream-render", this.handleStream)
+ }
+
+ disconnect() {
+ document.removeEventListener("turbo:frame-load", this.handleFrameLoad)
+ document.removeEventListener("turbo:before-stream-render", this.handleStream)
+ }
+
+ handleFrameLoad(event) {
+ if (event.target.id === this.frameValue) this.sync()
+ }
+
+ handleStream(event) {
+ if (event.target.getAttribute("target") !== this.frameValue) return
+
+ const render = event.detail.render
+ event.detail.render = async (stream) => {
+ await render(stream)
+ this.sync()
+ }
+ }
+
+ sync() {
+ const frame = document.getElementById(this.frameValue)
+ const state = frame && frame.querySelector("[data-list-filter-query]")
+ const address = listAddress(this.pathValue, state ? state.dataset.listFilterQuery : undefined)
+ if (!address) return
+
+ window.history.replaceState(window.history.state || { lane: true }, "", address)
+ this.element.dispatchEvent(new CustomEvent("lane:list-changed", { bubbles: true }))
+ }
+}
diff --git a/app/javascript/lib/list_address.js b/app/javascript/lib/list_address.js
new file mode 100644
index 0000000..75bfbff
--- /dev/null
+++ b/app/javascript/lib/list_address.js
@@ -0,0 +1,19 @@
+// What: the address of a list page without a lane ("Alle Meetings") after its
+// list frame loaded: the page's path with the list state the server rendered
+// (data-list-filter-query, Meetings::ListState).
+// Why: a column head, a page link and the "+" modal reload only the frame.
+// The filter bar reads sort and the open view from window.location, so an
+// address left behind loses the sort on the next filter and the page on a
+// reload. The project page does the same in layout_toggle#syncUrlFromFrame,
+// which also keeps the lane's own parameters; this page has no lane.
+//
+// Null when the frame rendered no state (an error page): the address stays.
+export function listAddress(path, renderedQuery) {
+ if (!path || renderedQuery === undefined || renderedQuery === null) return null
+
+ const query = new URLSearchParams(renderedQuery)
+ if (query.get('page') === '1') query.delete('page')
+ const search = query.toString()
+
+ return search ? `${path}?${search}` : path
+}
diff --git a/app/services/ad_hoc_filter_service.rb b/app/services/ad_hoc_filter_service.rb
index 19cec9f..362dd94 100644
--- a/app/services/ad_hoc_filter_service.rb
+++ b/app/services/ad_hoc_filter_service.rb
@@ -90,10 +90,10 @@ class AdHocFilterService
# creator needs a creator_id column).
def field_supported?(key, klass)
case key
- when 'participant', 'occurred_at'
+ # On a meeting list a meeting field; on any other list a custom attribute of
+ # the same name (a ticket field may be called "project").
+ when *MEETING_FIELDS
klass == Meeting || klass.column_names.include?('custom_attributes')
- when 'project'
- klass == Meeting
when 'assignee', *Tickets::WaitingStateFilter::STATES
klass == Ticket
when 'tag'
diff --git a/app/views/organisations/meetings_overview/_list_head.html.erb b/app/views/organisations/meetings_overview/_list_head.html.erb
index 84db261..d272ab2 100644
--- a/app/views/organisations/meetings_overview/_list_head.html.erb
+++ b/app/views/organisations/meetings_overview/_list_head.html.erb
@@ -27,32 +27,33 @@
<%# Claim hint (Nachtrag): outside the results frame so a filter never wipes it. %>
<%= render 'organisations/meetings/claim_suggestions', matches: meeting_claim_matches %>
-<% unless meetings_overview_first_use? %>
- <%# 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. %>
- <%= render NeoFilterBarComponent.new(
- current_user_id: current_user.id,
- smart_folders: @meeting_smart_folders,
- url: organisation_meetings_path(@current_organisation),
- frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID,
- i18n_scope: 'views.organisations.meetings.index',
- all_items_label: t('smart_folders.all_meetings'),
- 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,
- active_smart_folder: @active_smart_folder,
- active_view_permissions: filter_bar_view_permissions(@active_smart_folder),
- dissolver_result: @dissolver_result,
- ad_hoc_filters: ad_hoc_filter_params,
- ad_hoc_operators: ad_hoc_filter_op_params,
- dropped_categories: dropped_filter_categories,
- filter_categories_json: meeting_filter_categories_json(scope: policy_scope(Meeting), organisation: @current_organisation,
- projects: meeting_filter_projects),
- search_value: params[:search],
- search_mode: @current_search_mode,
- search_modes: %w[title_only content],
- organisation: @current_organisation
- ) %>
-<% end %>
+<%# 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. %>
+<%= render NeoFilterBarComponent.new(
+ current_user_id: current_user.id,
+ smart_folders: @meeting_smart_folders,
+ url: organisation_meetings_path(@current_organisation),
+ frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID,
+ i18n_scope: 'views.organisations.meetings.index',
+ all_items_label: t('smart_folders.all_meetings'),
+ 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,
+ active_smart_folder: @active_smart_folder,
+ active_view_permissions: filter_bar_view_permissions(@active_smart_folder),
+ dissolver_result: @dissolver_result,
+ ad_hoc_filters: ad_hoc_filter_params,
+ ad_hoc_operators: ad_hoc_filter_op_params,
+ dropped_categories: dropped_filter_categories,
+ filter_categories_json: meeting_filter_categories_json(scope: policy_scope(Meeting), organisation: @current_organisation,
+ projects: meeting_filter_projects),
+ search_value: params[:search],
+ search_mode: @current_search_mode,
+ search_modes: %w[title_only content],
+ organisation: @current_organisation
+) %>
diff --git a/app/views/organisations/meetings_overview/index.html.erb b/app/views/organisations/meetings_overview/index.html.erb
index 3117156..aed9dd2 100644
--- a/app/views/organisations/meetings_overview/index.html.erb
+++ b/app/views/organisations/meetings_overview/index.html.erb
@@ -6,9 +6,11 @@
doc/meetings_uebersicht_vereinheitlichen_plan.md).
index-page restores the list on Back and Forward: the bar pushes history
- entries of its own ({ lane: true }), which Turbo leaves alone. viewport
- reloads the page below the breakpoint with ?viewport=mobile, as on the
- project page. %>
+ entries of its own ({ lane: true }), which Turbo leaves alone. list-address
+ writes the list the frame rendered (sort, page, view) into the address after
+ every frame load, which the bar reads from window.location. viewport reloads
+ the page below the breakpoint with ?viewport=mobile, as on the project
+ page. %>
<% content_for :head do %>
<meta name="turbo-cache-control" content="no-cache">
<% end %>
@@ -17,7 +19,9 @@
<turbo-frame id="modal"></turbo-frame>
<div class="w-full"
- data-controller="index-page viewport"
+ data-controller="index-page viewport list-address"
+ data-list-address-frame-value="<%= Organisations::MeetingsOverviewController::LIST_FRAME_ID %>"
+ data-list-address-path-value="<%= organisation_meetings_path(@current_organisation) %>"
data-index-page-param-name-value="meeting_id"
data-index-page-frame-id-value="meeting_display_frame"
data-lane-params="<%= lane_params_json(selection: %w[meeting_id]) %>"
diff --git a/config/importmap.rb b/config/importmap.rb
index c5362f4..dda9f86 100644
--- a/config/importmap.rb
+++ b/config/importmap.rb
@@ -19,10 +19,12 @@ pin 'meetings/name_normalizer', to: 'lib/meetings/name_normalizer.js'
# Meetings Slice 5: pure LLM-detection merge rule, same inject-normalize pattern.
pin 'meetings/participant_merge', to: 'lib/meetings/participant_merge.js'
pin 'time_session_modal', to: 'lib/time_session_modal.js'
-# Overview meeting modal: the filter merge and the "did this really save?"
+# Overview meeting modal: the list state merge and the "did this really save?"
# 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 address of a list page without a lane after its frame loaded ("Alle Meetings").
+pin 'list_address', to: 'lib/list_address.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'
@@ -173,6 +175,7 @@ else
pin 'controllers/lane_link_controller', to: 'controllers/lane_link_controller.js'
pin 'controllers/lane_split_controller', to: 'controllers/lane_split_controller.js'
pin 'controllers/layout_toggle_controller', to: 'controllers/layout_toggle_controller.js'
+ pin 'controllers/list_address_controller', to: 'controllers/list_address_controller.js'
pin 'controllers/list_row_controller', to: 'controllers/list_row_controller.js'
pin 'controllers/meeting_analysis_composer_controller', to: 'controllers/meeting_analysis_composer_controller.js'
pin 'controllers/meeting_modal_controller', to: 'controllers/meeting_modal_controller.js'
diff --git a/spec/javascript/lib/list_address.test.js b/spec/javascript/lib/list_address.test.js
new file mode 100644
index 0000000..9c1cb42
--- /dev/null
+++ b/spec/javascript/lib/list_address.test.js
@@ -0,0 +1,35 @@
+// What: the address of "Alle Meetings" after its list frame loaded (lib/list_address.js).
+// Why: the filter bar reads sort and the open view from window.location. A
+// column head or a page link reloads only the frame; an address that stayed
+// behind lost the sort on the next filter and the page on a reload (review
+// of the overview filter bar, P2).
+import { test } from "node:test"
+import assert from "node:assert/strict"
+import { listAddress } from "../../../app/javascript/lib/list_address.js"
+
+const PATH = "/org/o1/meetings"
+
+test("the address is the path with the state the frame rendered", () => {
+ const rendered = "filter%5Bproject%5D%5B%5D=p1&page=2&sort%5Bcolumn%5D=title&sort%5Bdirection%5D=asc"
+ const params = new URL(listAddress(PATH, rendered), "http://x.invalid").searchParams
+
+ assert.deepEqual(params.getAll("filter[project][]"), ["p1"])
+ assert.equal(params.get("sort[column]"), "title")
+ assert.equal(params.get("sort[direction]"), "asc")
+ assert.equal(params.get("page"), "2")
+})
+
+test("a state that no longer has a condition takes it out of the address", () => {
+ assert.equal(listAddress(PATH, "search=Kickoff"), `${PATH}?search=Kickoff`)
+ assert.equal(listAddress(PATH, ""), PATH)
+})
+
+test("page 1 is no page", () => {
+ assert.equal(listAddress(PATH, "page=1&smart_folder_id=v1"), `${PATH}?smart_folder_id=v1`)
+})
+
+test("a frame without a rendered state leaves the address alone", () => {
+ assert.equal(listAddress(PATH, undefined), null)
+ assert.equal(listAddress(PATH, null), null)
+ assert.equal(listAddress("", "search=x"), null)
+})
diff --git a/spec/requests/organisations/meetings_overview_access_spec.rb b/spec/requests/organisations/meetings_overview_access_spec.rb
index 074df58..d7e4fd2 100644
--- a/spec/requests/organisations/meetings_overview_access_spec.rb
+++ b/spec/requests/organisations/meetings_overview_access_spec.rb
@@ -100,6 +100,25 @@ RSpec.describe 'Organisations::MeetingsOverview access', :ci_guard, type: :reque
end
end
+ describe 'the expert filter of a view with a project condition' do
+ it 'offers only readable projects in the server-rendered value list' do
+ view = ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder, name: 'Nur Alpha', user: reader_a, organisation: organisation, project: nil,
+ target_object_type: 'Meeting').tap do |folder|
+ folder.smart_folder_rule_groups.create!(position: 1)
+ .smart_folder_rules.create!(field: 'project', operator: 'equals', value: project_a.id, position: 1)
+ end
+ end
+ sign_in reader_a
+ get edit_organisation_smart_folder_path(organisation, view, modal: true, return_to: 'meetings')
+
+ expect(response).to have_http_status(:ok)
+ value_select = Capybara.string(response.body).find("select[data-field='project']")
+ expect(value_select.all('option').map(&:text)).to include('Projekt Alpha')
+ expect(response.body).not_to include('Projekt Beta', project_b.id)
+ end
+ end
+
describe 'saved views of somebody else' do
it 'does not open a private overview view of another user' do
foreign = ActsAsTenant.with_tenant(organisation) do
diff --git a/spec/requests/organisations/meetings_overview_spec.rb b/spec/requests/organisations/meetings_overview_spec.rb
index 146f628..1c48743 100644
--- a/spec/requests/organisations/meetings_overview_spec.rb
+++ b/spec/requests/organisations/meetings_overview_spec.rb
@@ -224,6 +224,15 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
expect(titles(list(items: 2, page: 2, filter: { project: [project_a.id] }))).to eq(['Seite 2'])
end
+ it 'lets the address follow the list frame, so the bar reads sort and page from it' do
+ create_meeting(project: project_a, title: 'Alpha Kickoff')
+ page = list
+
+ wrapper = page.find('[data-controller~="list-address"]')
+ expect(wrapper['data-list-address-frame-value']).to eq('meetings_overview_results')
+ expect(wrapper['data-list-address-path-value']).to eq(overview_path)
+ end
+
it 'answers the list frame alone' do
create_meeting(project: project_a, title: 'Alpha Kickoff')
get overview_path, headers: { 'Turbo-Frame' => 'meetings_overview_results' }
@@ -276,9 +285,12 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
describe 'empty states' do
before { sign_in reader }
- it 'shows the first-time empty state when there are no meetings at all' do
- list
+ it 'shows the first-time empty state when there are no meetings at all, below the filter bar' do
+ page = list
expect(response.body).to include(I18n.t('views.organisations.meetings_overview.index.empty_first_time_title'))
+ # The bar stands from the start: the "+" modal replaces only the list
+ # frame, and a bar missing until a full reload is a page without its tools.
+ expect(page).to have_css('[data-controller="filter-bar"]')
end
it 'shows the no-results empty state when a filter matches nothing' do
diff --git a/spec/requests/organisations/meetings_overview_views_spec.rb b/spec/requests/organisations/meetings_overview_views_spec.rb
index 5b98f30..99cce37 100644
--- a/spec/requests/organisations/meetings_overview_views_spec.rb
+++ b/spec/requests/organisations/meetings_overview_views_spec.rb
@@ -137,7 +137,7 @@ RSpec.describe 'Organisations::MeetingsOverview saved views', :ci_guard, type: :
end
describe 'changing, renaming, duplicating, sharing and deleting' do
- # The bar stands only once there is a meeting to filter.
+ # A meeting on the list, so the view has something to show.
before { record('Alpha Kickoff', project: project_a) }
let!(:saved) do
diff --git a/spec/services/ad_hoc_filter_service_spec.rb b/spec/services/ad_hoc_filter_service_spec.rb
index a063798..aa1cc7e 100644
--- a/spec/services/ad_hoc_filter_service_spec.rb
+++ b/spec/services/ad_hoc_filter_service_spec.rb
@@ -51,7 +51,7 @@ RSpec.describe AdHocFilterService do
let(:base_query) { project.tickets }
describe '#apply' do
- %w[participant occurred_at].each do |name|
+ %w[participant occurred_at project].each do |name|
it "preserves ticket custom #{name} filters through saving and reloading" do
create(:ticket_attribute_definition, project: project, name: name, field_type: 'select',
options: { 'allowed_values' => [{ 'value' => 'today', 'labels' => { 'de' => 'Heute' } }] })
diff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rb
index 4f27446..391c1fd 100644
--- a/spec/system/meetings_overview_spec.rb
+++ b/spec/system/meetings_overview_spec.rb
@@ -85,6 +85,28 @@ RSpec.describe 'Meetings overview', type: :system do
expect(page).to have_current_path(/filter%5Bproject%5D/)
end
+ it 'keeps a sort chosen at a column head through a new condition and a reload' do
+ page.driver.browser.manage.window.resize_to(1440, 1000)
+ ActsAsTenant.with_tenant(organisation) do
+ create(:meeting, project: alpha, organisation: organisation, creator: user, title: 'Aaa Alpha', occurred_at: 5.days.ago)
+ end
+ visit organisation_meetings_path(organisation)
+ expect_titles('Beta Retro', 'Alpha Kickoff', 'Aaa Alpha')
+
+ find('#meetings_overview_results th[data-column="title"] a').click
+ expect(page).to have_current_path(/sort%5Bcolumn%5D=title/, wait: 5)
+
+ find('[data-filter-bar-target="filterButton"]').click
+ find('[role="menuitem"][data-category="project"]').click
+ within('[data-filter-bar-target="valueMenu"]') { find("input[type='checkbox'][data-filter-value='#{alpha.id}']").click }
+ expect_titles('Aaa Alpha', 'Alpha Kickoff')
+ expect(page.all('#meetings_overview_results tr[data-meeting-id] h5').map { |title| title.text.strip }).to eq(['Aaa Alpha', 'Alpha Kickoff'])
+ expect(page).to have_current_path(/sort%5Bcolumn%5D=title/)
+
+ page.refresh
+ expect(page.all('#meetings_overview_results tr[data-meeting-id] h5', wait: 5).map { |title| title.text.strip }).to eq(['Aaa Alpha', 'Alpha Kickoff'])
+ end
+
it 'fits a phone of 390 px without scrolling sideways' do
page.driver.browser.manage.window.resize_to(390, 844)
visit organisation_meetings_path(organisation)