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.

Give "Alle Meetings" the column picker of the project page

Guido Boykef8fa3faca545
diff --git a/.github/workflows/guards.yml b/.github/workflows/guards.yml
index 4171ad8..c23c25c 100644
--- a/.github/workflows/guards.yml
+++ b/.github/workflows/guards.yml
@@ -586,6 +586,7 @@ jobs:
spec/requests/organisations/meetings_overview_spec.rb
spec/requests/organisations/meetings_overview_access_spec.rb
spec/requests/organisations/meetings_overview_views_spec.rb
+ spec/requests/organisations/meetings_overview_columns_spec.rb
spec/services/actors/save_smart_folder_from_filters_spec.rb
spec/services/actors/save_smart_folder_concurrency_spec.rb
spec/services/actors/create_ticket_relation_concurrency_spec.rb
diff --git a/app/controllers/concerns/meeting_list.rb b/app/controllers/concerns/meeting_list.rb
index 3910bcd..b5bbe11 100644
--- a/app/controllers/concerns/meeting_list.rb
+++ b/app/controllers/concerns/meeting_list.rb
@@ -22,11 +22,6 @@
module MeetingList
extend ActiveSupport::Concern
- # The columns of "Alle Meetings" until it gets the column picker (PR 2 of the
- # plan). Labels and types come from the meetings column list; project is the
- # one column only this list has.
- OVERVIEW_COLUMN_KEYS = %w[title project occurred_at duration_minutes participants].freeze
-
private
# Sets what the list head and the rows read (@meeting_smart_folders,
@@ -66,25 +61,15 @@ module MeetingList
project ? policy_scope(project.meetings) : policy_scope(Meeting)
end
+ # The base view of this list: the reader's row of the project, or on "Alle
+ # Meetings" the row without a project, which offers the column "Projekt" too.
+ # A saved view brings its own list (Lists::ResolveColumns).
def meeting_list_columns
- project = meeting_list_project
- return overview_columns unless project
-
- @view_configuration = ViewConfiguration.for_user_project(current_user, project, 'meetings')
+ @view_configuration = ViewConfiguration.for_list(user: current_user, organisation: @current_organisation,
+ project: meeting_list_project, view_type: 'meetings')
Lists::ResolveColumns.call(view_configuration: @view_configuration, smart_folder: @active_smart_folder)
end
- # The same column hashes the project list renders from (Lists::ResolveColumns),
- # in a fixed order.
- def overview_columns
- by_key = ViewConfiguration.meeting_base_columns.index_by { |column| column[:key] }
- by_key['project'] = { key: 'project', type: 'text', label: t('models.view_configuration.meeting_columns.project') }
- OVERVIEW_COLUMN_KEYS.each_with_index.map do |key, index|
- column = by_key.fetch(key)
- column.merge(rank: (index unless column[:required]), min_width: ViewConfiguration.column_min_width(column), pinned: false)
- end
- end
-
# A search term is one string; any other shape is no search.
def scalar_param(key)
value = params[key]
diff --git a/app/helpers/meetings_helper.rb b/app/helpers/meetings_helper.rb
index 3b92592..3301abe 100644
--- a/app/helpers/meetings_helper.rb
+++ b/app/helpers/meetings_helper.rb
@@ -49,16 +49,42 @@ module MeetingsHelper
end
end
- # The share of the width each fixed column of "Alle Meetings" takes
- # (MeetingList::OVERVIEW_COLUMN_KEYS). Here and not in the concern: Tailwind
- # scans helpers for class names, controllers it does not.
- MEETING_OVERVIEW_COLUMN_WIDTHS = {
- 'title' => 'w-[30%]', 'project' => 'w-[18%]', 'occurred_at' => 'w-[18%]',
- 'duration_minutes' => 'w-[10%]', 'participants' => 'w-[24%]'
- }.freeze
+ # The column picker's wiring on a meetings list page, the element that
+ # carries data-controller="column-picker": where a change is saved, which
+ # frame it reloads, and its words. project nil is "Alle Meetings". A change
+ # goes into the open saved view, else into the base view of this list.
+ def meeting_column_picker_data(project:, frame_id:)
+ {
+ column_picker_frame_value: frame_id,
+ column_picker_required_value: ViewConfiguration.required_columns_for('meetings').to_json,
+ column_picker_fixed_width_value: ViewConfiguration::COLUMN_MIN_WIDTH_PX['title'],
+ column_picker_save_url_value: meeting_columns_save_url(project),
+ # Only an org-wide TICKET view needs to name a project; a meeting view
+ # belongs to its list, so none is sent from "Alle Meetings".
+ column_picker_project_id_value: project&.id,
+ column_picker_editable_value: (@active_smart_folder.nil? || policy(@active_smart_folder).update?).to_s,
+ column_picker_error_label_value: t('components.column_picker.save_failed'),
+ column_picker_moved_template_value: t('components.column_picker.moved', name: '%{name}', position: '%{position}'),
+ column_picker_pin_label_on_value: t('components.column_picker.pin_label_on', name: '%{name}'),
+ column_picker_pin_label_off_value: t('components.column_picker.pin_label_off', name: '%{name}'),
+ column_picker_pin_title_on_value: t('components.column_picker.pinned'),
+ column_picker_pin_title_off_value: t('components.column_picker.pin')
+ }
+ end
+
+ def meeting_columns_save_url(project)
+ return columns_organisation_smart_folder_path(@current_organisation, @active_smart_folder) if @active_smart_folder
+ return columns_organisation_meetings_view_configuration_path(@current_organisation) unless project
+
+ columns_organisation_project_view_configuration_path(@current_organisation, project, view_type: 'meetings')
+ end
+
+ # "für alle Ansichten übernehmen": the base view of this list and the
+ # reader's own views of it (Actors::ApplyColumnsToViews).
+ def meeting_columns_apply_all_url(project)
+ return apply_columns_to_all_organisation_meetings_view_configuration_path(@current_organisation) unless project
- def meeting_overview_column_width_class(column)
- MEETING_OVERVIEW_COLUMN_WIDTHS.fetch(column[:key].to_s)
+ apply_columns_to_all_organisation_project_view_configuration_path(@current_organisation, project, view_type: 'meetings')
end
# A column head that sorts its list: base_path is the list's address (the
diff --git a/app/models/view_configuration.rb b/app/models/view_configuration.rb
index b357170..7bc34b6 100644
--- a/app/models/view_configuration.rb
+++ b/app/models/view_configuration.rb
@@ -291,12 +291,22 @@ class ViewConfiguration < ApplicationRecord
def self.find_or_initialize_with_defaults(**attributes)
find_or_initialize_by(**attributes) do |config|
config.table_columns = default_columns_for(attributes[:project], attributes[:view_type])
- config.pinned_columns = %w[participants] if attributes[:view_type] == 'meetings'
+ config.pinned_columns = default_pins_for(attributes[:project], attributes[:view_type])
config.header_columns = DEFAULT_HEADER_COLUMNS
end
end
private_class_method :find_or_initialize_with_defaults
+ # The values a base view keeps readable under the title when its column does
+ # not fit. On a meetings list the participants; on "Alle Meetings" the
+ # project as well, because a row that cannot name its project there (a phone,
+ # a narrow list) says less than the page did before it had a picker.
+ def self.default_pins_for(project, view_type)
+ return [] unless view_type == 'meetings'
+
+ project ? %w[participants] : %w[project participants]
+ end
+
# Get all available columns for configuration (instance method)
#
# Memoized: resolving the time columns asks TimeSessions::ViewingScope, and a
diff --git a/app/views/organisations/meetings/_column_picker.html.erb b/app/views/organisations/meetings/_column_picker.html.erb
index d3d1357..388378a 100644
--- a/app/views/organisations/meetings/_column_picker.html.erb
+++ b/app/views/organisations/meetings/_column_picker.html.erb
@@ -1,3 +1,7 @@
+<%# locals: () %>
+<%# The column picker panel of both meetings lists: the project page (@project)
+ and "Alle Meetings" (@project nil), which offers the column "Projekt" too
+ (ViewConfiguration.available_columns_for). %>
<%= render Neo::ColumnPickerComponent.new(
available: @view_configuration.available_columns,
chosen: @columns,
@@ -5,5 +9,5 @@
view_name: @active_smart_folder&.name || t('smart_folders.all_meetings'),
fit: initial_column_fit(@columns.reject { |column| column[:required] }, content_open: @selected_meeting.present? || @new_meeting.present?),
pinned_keys: @active_smart_folder&.pinned_column_keys || @view_configuration.pinned_column_keys,
- apply_all_url: apply_columns_to_all_organisation_project_view_configuration_path(@current_organisation, @project, view_type: 'meetings')
+ apply_all_url: meeting_columns_apply_all_url(@project)
) %>
diff --git a/app/views/organisations/meetings/_column_picker_trigger.html.erb b/app/views/organisations/meetings/_column_picker_trigger.html.erb
new file mode 100644
index 0000000..1e9726e
--- /dev/null
+++ b/app/views/organisations/meetings/_column_picker_trigger.html.erb
@@ -0,0 +1,13 @@
+<%# locals: () %>
+<%# The column picker's trigger in the filter bar's view tools, on both meetings
+ lists (the project page and "Alle Meetings"). It opens the panel the page
+ renders beside the list (meetings/_column_picker). %>
+<button type="button"
+ class="column-picker-trigger grid place-items-center h-7 w-7 rounded-md text-muted hover:text-heading hover:bg-cream-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink"
+ data-column-picker-trigger
+ data-action="click->column-picker#toggle"
+ aria-expanded="false"
+ aria-controls="<%= Neo::ColumnPickerComponent::ELEMENT_ID %>"
+ title="<%= t('components.column_picker.trigger_title') %>">
+ <i class="bi bi-sliders2 text-sm" aria-hidden="true"></i>
+</button>
diff --git a/app/views/organisations/meetings/_list_head.html.erb b/app/views/organisations/meetings/_list_head.html.erb
index 419ca8e..e5de8fb 100644
--- a/app/views/organisations/meetings/_list_head.html.erb
+++ b/app/views/organisations/meetings/_list_head.html.erb
@@ -72,15 +72,7 @@
organisation: @current_organisation
) do |bar| %>
<% bar.with_view_tool do %>
- <button type="button"
- class="column-picker-trigger grid place-items-center h-7 w-7 rounded-md text-muted hover:text-heading hover:bg-cream-100 focus:outline-none focus-visible:ring-2 focus-visible:ring-ink"
- data-column-picker-trigger
- data-action="click->column-picker#toggle"
- aria-expanded="false"
- aria-controls="<%= Neo::ColumnPickerComponent::ELEMENT_ID %>"
- title="<%= t('components.column_picker.trigger_title') %>">
- <i class="bi bi-sliders2 text-sm" aria-hidden="true"></i>
- </button>
+ <%= render 'organisations/meetings/column_picker_trigger' %>
<% end %>
<% end %>
diff --git a/app/views/organisations/meetings/_meeting_row.html.erb b/app/views/organisations/meetings/_meeting_row.html.erb
index eeaff5f..0b295e1 100644
--- a/app/views/organisations/meetings/_meeting_row.html.erb
+++ b/app/views/organisations/meetings/_meeting_row.html.erb
@@ -1,26 +1,29 @@
+<%# locals: (meeting:, selected_meeting: nil, opens_in_lane: true) %>
<%
- selected_id = (defined?(selected_meeting) && selected_meeting&.id) || params[:meeting_id]
+ selected_id = selected_meeting&.id || params[:meeting_id]
is_selected = selected_id == meeting.id
- detail_url = organisation_project_meeting_path(@current_organisation, @project, meeting)
- # Cell widths MUST stay in sync with the <th> widths in _meetings_results.
+ # The project page opens the meeting in its lane; "Alle Meetings" has none
+ # yet and opens it on the meeting's own project page, the title a real link
+ # for the keyboard (clickable-row leaves clicks on a link alone).
+ detail_url = opens_in_lane ? organisation_project_meeting_path(@current_organisation, @project, meeting) : organisation_project_meetings_path(@current_organisation, meeting.project, meeting_id: meeting.id)
+ row_data = if opens_in_lane
+ { controller: 'list-row', list_row_url_value: detail_url, list_row_id_value: meeting.id, list_row_param_value: 'meeting_id',
+ list_row_params_value: %w[meeting_id].to_json, list_row_frame_value: 'meeting_display_frame',
+ meetings_row_item_id_value: meeting.id, meeting_id: meeting.id, action: 'click->list-row#click' }
+ else
+ { controller: 'clickable-row', clickable_row_url_value: detail_url, meeting_id: meeting.id, action: 'click->clickable-row#click' }
+ end
+ # Cell widths MUST stay in sync with the <th> widths in _meetings_table.
%>
-<tr
- data-controller="list-row"
- data-list-row-url-value="<%= html_escape(detail_url) %>"
- data-list-row-id-value="<%= meeting.id %>"
- data-list-row-param-value="meeting_id"
- data-list-row-params-value="<%= %w[meeting_id].to_json %>"
- data-list-row-frame-value="meeting_display_frame"
- data-meetings-row-item-id-value="<%= meeting.id %>"
- data-meeting-id="<%= meeting.id %>"
- data-action="click->list-row#click"
- class="transition-colors duration-100 ease-in-out cursor-pointer focus:outline-none hover:bg-cream-100 <%= 'selected-row' if is_selected %>"
- tabindex="-1">
+<%= tag.tr data: row_data, tabindex: (-1 if opens_in_lane),
+ class: "transition-colors duration-100 ease-in-out cursor-pointer focus:outline-none hover:bg-cream-100 #{'selected-row' if is_selected}" do %>
<% @columns.each do |column| %>
<td data-column="<%= column[:key] %>" <%= tag.attributes(data: { rank: column[:rank] }) %>
style="<%= column_min_width_style(column) %>" class="p-3 text-sm <%= column[:required] ? 'title-column' : column_align_class(column) %>">
<% if column[:key] == 'title' %>
- <h5 class="text-sm font-medium truncate"><%= meeting.title %></h5>
+ <h5 class="text-sm font-medium truncate">
+ <%= opens_in_lane ? meeting.title : link_to(meeting.title, detail_url, data: { turbo_frame: '_top' }, class: 'text-cream-900 hover:text-ink hover:underline') %>
+ </h5>
<div class="ticket-meta text-[11px] text-muted truncate">
<% @columns.reject { |item| item[:required] }.each do |item| %>
<% value = meeting_column_value(meeting, item) %>
@@ -32,4 +35,4 @@
<% end %>
</td>
<% end %>
-</tr>
+<% end %>
diff --git a/app/views/organisations/meetings/_meetings_results.html.erb b/app/views/organisations/meetings/_meetings_results.html.erb
index af0fd6c..df2ec42 100644
--- a/app/views/organisations/meetings/_meetings_results.html.erb
+++ b/app/views/organisations/meetings/_meetings_results.html.erb
@@ -49,27 +49,8 @@
</div>
<% end %>
<% else %>
- <div class="relative w-full overflow-x-auto">
- <table class="w-full meeting-table" data-fit="<%= @viewport_mode == 'mobile' ? 0 : initial_column_fit(@columns.reject { |column| column[:required] }, content_open: selected_meeting.present? || params[:meeting_id].present? || params[:new] == 'meeting') %>" data-column-count="<%= @columns.size %>">
- <thead>
- <tr>
- <% @columns.each do |column| %>
- <th scope="col" data-column="<%= column[:key] %>" <%= tag.attributes(data: { rank: column[:rank] }) %>
- data-col-min="<%= column[:min_width] %>" style="<%= column_min_width_style(column) %>"
- class="py-3 px-3 text-[11px] font-mono font-medium uppercase tracking-wider text-muted <%= column[:required] ? 'title-header text-start' : column_align_class(column) %>">
- <%= meeting_sort_link(column, base_path: organisation_project_meetings_path(@current_organisation, @project), frame_id: 'meetings_results') %>
- </th>
- <% end %>
- </tr>
- </thead>
- <tbody>
- <% meetings.each do |meeting| %>
- <%= render 'organisations/meetings/meeting_row', meeting: meeting, selected_meeting: selected_meeting %>
- <% end %>
- <%= render 'shared/ruled_rows', missing: @pagy.limit - meetings.size, colspan: @columns.size unless @viewport_mode == 'mobile' %>
- </tbody>
- </table>
- </div>
+ <%= render 'organisations/meetings/meetings_table', meetings: meetings, selected_meeting: selected_meeting,
+ base_path: organisation_project_meetings_path(@current_organisation, @project), frame_id: 'meetings_results', opens_in_lane: true %>
<% end %>
<% if @pagy.count.positive? %>
<%= render 'shared/pagination_nav_compact', pagy: @pagy, frame_id: 'meetings_results', items_per_page: @pagy.limit,
diff --git a/app/views/organisations/meetings/_meetings_table.html.erb b/app/views/organisations/meetings/_meetings_table.html.erb
new file mode 100644
index 0000000..8524e1f
--- /dev/null
+++ b/app/views/organisations/meetings/_meetings_table.html.erb
@@ -0,0 +1,32 @@
+<%# locals: (meetings:, selected_meeting:, base_path:, frame_id:, opens_in_lane:) %>
+<%# The table of a meetings list, shared by the project page
+ (meetings/_meetings_results) and "Alle Meetings" (meetings_overview/_results).
+ Heads and cells come from @columns (Lists::ResolveColumns) with rank,
+ minimum width and pin: a column that does not fit folds away in rank order
+ and a pinned value moves under the title (layout.css; the fit itself is
+ column_picker_controller's). On a phone no ranked column stands in the head
+ (data-fit 0), so the table never scrolls sideways.
+ base_path and frame_id are the list's own: a sort link reloads that frame.
+ opens_in_lane: a row opens the meeting in the lane beside the list (project
+ page), or on its project's page ("Alle Meetings", until its lane). %>
+<div class="relative w-full overflow-x-auto">
+ <table class="w-full meeting-table" data-fit="<%= @viewport_mode == 'mobile' ? 0 : initial_column_fit(@columns.reject { |column| column[:required] }, content_open: selected_meeting.present? || params[:meeting_id].present? || params[:new] == 'meeting') %>" data-column-count="<%= @columns.size %>">
+ <thead>
+ <tr>
+ <% @columns.each do |column| %>
+ <th scope="col" data-column="<%= column[:key] %>" <%= tag.attributes(data: { rank: column[:rank] }) %>
+ data-col-min="<%= column[:min_width] %>" style="<%= column_min_width_style(column) %>"
+ class="py-3 px-3 text-[11px] font-mono font-medium uppercase tracking-wider text-muted <%= column[:required] ? 'title-header text-start' : column_align_class(column) %>">
+ <%= meeting_sort_link(column, base_path: base_path, frame_id: frame_id) %>
+ </th>
+ <% end %>
+ </tr>
+ </thead>
+ <tbody>
+ <% meetings.each do |meeting| %>
+ <%= render 'organisations/meetings/meeting_row', meeting: meeting, selected_meeting: selected_meeting, opens_in_lane: opens_in_lane %>
+ <% end %>
+ <%= render 'shared/ruled_rows', missing: @pagy.limit - meetings.size, colspan: @columns.size unless @viewport_mode == 'mobile' %>
+ </tbody>
+ </table>
+</div>
diff --git a/app/views/organisations/meetings/index.html.erb b/app/views/organisations/meetings/index.html.erb
index 5d1f0d9..2a6722e 100644
--- a/app/views/organisations/meetings/index.html.erb
+++ b/app/views/organisations/meetings/index.html.erb
@@ -13,18 +13,7 @@
<div class="labor-layout-view <%= 'show-content' if @selected_meeting || @new_meeting %> hide-panel"
data-controller="layout-toggle hover-arrows index-page keyboard-navigation viewport column-picker"
- data-column-picker-frame-value="meetings_results"
- data-column-picker-required-value='<%= ["title"].to_json %>'
- data-column-picker-fixed-width-value="<%= ViewConfiguration::COLUMN_MIN_WIDTH_PX['title'] %>"
- data-column-picker-save-url-value="<%= @active_smart_folder ? columns_organisation_smart_folder_path(@current_organisation, @active_smart_folder) : columns_organisation_project_view_configuration_path(@current_organisation, @project, view_type: 'meetings') %>"
- data-column-picker-project-id-value="<%= @project.id %>"
- data-column-picker-editable-value="<%= @active_smart_folder.nil? || policy(@active_smart_folder).update? %>"
- data-column-picker-error-label-value="<%= t('components.column_picker.save_failed') %>"
- data-column-picker-moved-template-value="<%= t('components.column_picker.moved', name: '%{name}', position: '%{position}') %>"
- data-column-picker-pin-label-on-value="<%= t('components.column_picker.pin_label_on', name: '%{name}') %>"
- data-column-picker-pin-label-off-value="<%= t('components.column_picker.pin_label_off', name: '%{name}') %>"
- data-column-picker-pin-title-on-value="<%= t('components.column_picker.pinned') %>"
- data-column-picker-pin-title-off-value="<%= t('components.column_picker.pin') %>"
+ <%= tag.attributes(data: meeting_column_picker_data(project: @project, frame_id: 'meetings_results')) %>
data-hover-arrows-layout-toggle-outlet=".labor-layout-view"
data-layout-toggle-list-frame-ids-value="<%= ['meetings_results'].to_json %>"
data-layout-toggle-detail-frame-id-value="meeting_display_frame"
diff --git a/app/views/organisations/meetings_overview/_index_desktop.html.erb b/app/views/organisations/meetings_overview/_index_desktop.html.erb
new file mode 100644
index 0000000..e60388f
--- /dev/null
+++ b/app/views/organisations/meetings_overview/_index_desktop.html.erb
@@ -0,0 +1,21 @@
+<%# locals: () %>
+<%# The project page's grid (meetings/_index_desktop): the list with its head,
+ and the column picker in the side panel. The lane stays empty and shut
+ until PR 3 of meetings_uebersicht_vereinheitlichen_plan.md opens a meeting
+ in it; a row opens the meeting on its project's page meanwhile. %>
+<%= render NeoTwoColumnGridComponent.new(
+ context_type: :meetings,
+ css_classes: 'hide-content hide-panel',
+ additional_targets: { 'column-picker-target' => 'grid' },
+ chrome_height: NeoTwoColumnGridComponent::LANE_CHROME_HEIGHT_PX,
+ lane: true
+) do |grid| %>
+ <% grid.with_list do %>
+ <%= render 'organisations/meetings_overview/list_head' %>
+ <%= render 'organisations/meetings_overview/results', meetings: @meetings, first_use: meetings_overview_first_use? %>
+ <% end %>
+
+ <% grid.with_side_panel do %>
+ <%= render 'organisations/meetings/column_picker' %>
+ <% end %>
+<% end %>
diff --git a/app/views/organisations/meetings_overview/_index_mobile.html.erb b/app/views/organisations/meetings_overview/_index_mobile.html.erb
new file mode 100644
index 0000000..ed7cbf5
--- /dev/null
+++ b/app/views/organisations/meetings_overview/_index_mobile.html.erb
@@ -0,0 +1,17 @@
+<%# locals: () %>
+<%# Phone: the project page's list (meetings/_index_mobile) with its picker,
+ which floats over the list (views.css, .meeting-mobile-grid). No detail
+ yet: a row opens the meeting on its project's page. %>
+<div class="meeting-mobile-grid list" data-column-picker-target="grid">
+ <%= render NeoMobileTicketViewComponent.new(
+ back_url: organisation_meetings_path(@current_organisation),
+ back_label: t('views.organisations.meetings.index.mobile_list_view')
+ ) do |mobile| %>
+ <% mobile.with_list do %>
+ <%= render 'organisations/meetings_overview/list_head' %>
+ <%= render 'organisations/meetings_overview/results', meetings: @meetings, first_use: meetings_overview_first_use? %>
+ <% end %>
+ <% end %>
+
+ <%= render 'organisations/meetings/column_picker' %>
+</div>
diff --git a/app/views/organisations/meetings_overview/_list_head.html.erb b/app/views/organisations/meetings_overview/_list_head.html.erb
index d272ab2..937ba3d 100644
--- a/app/views/organisations/meetings_overview/_list_head.html.erb
+++ b/app/views/organisations/meetings_overview/_list_head.html.erb
@@ -1,6 +1,6 @@
<%# locals: () %>
<%# The head of "Alle Meetings": the title box, the claim hint and the shared
- filter bar. All of it stays outside #meetings_overview_results, so a filter,
+ filter bar with the column picker's trigger. All of it stays outside #meetings_overview_results, so a filter,
a sort or a page reloads only the rows and never the controls that asked for
it (the same rule as meetings/_list_head). The sentence frame of the bar is
answered from this partial too (MeetingsOverviewController#index). %>
@@ -56,4 +56,9 @@
search_mode: @current_search_mode,
search_modes: %w[title_only content],
organisation: @current_organisation
-) %>
+) do |bar| %>
+ <%# The column picker, at the place the project page has it. %>
+ <% bar.with_view_tool do %>
+ <%= render 'organisations/meetings/column_picker_trigger' %>
+ <% end %>
+<% end %>
diff --git a/app/views/organisations/meetings_overview/_results.html.erb b/app/views/organisations/meetings_overview/_results.html.erb
index 6bcc35f..de0df62 100644
--- a/app/views/organisations/meetings_overview/_results.html.erb
+++ b/app/views/organisations/meetings_overview/_results.html.erb
@@ -34,69 +34,13 @@
title: t('views.organisations.meetings.index.empty_no_results') %>
<% end %>
</div>
- <% elsif @viewport_mode == 'mobile' %>
- <%# Phone: one block per meeting, the title on its own line and the project,
- date and participants below it. No table, so nothing scrolls sideways. %>
- <ul class="divide-y divide-cream-200">
- <% rows.each do |meeting| %>
- <% row_url = organisation_project_meetings_path(@current_organisation, meeting.project, meeting_id: meeting.id) %>
- <li data-meeting-id="<%= meeting.id %>"
- data-controller="clickable-row"
- data-clickable-row-url-value="<%= row_url %>"
- data-action="click->clickable-row#click"
- class="px-3 py-3 cursor-pointer hover:bg-cream-100">
- <h5 class="text-sm font-medium truncate">
- <%= link_to meeting.title, row_url, data: { turbo_frame: '_top' }, class: 'text-cream-900 hover:text-ink hover:underline' %>
- </h5>
- <p class="text-[11px] text-muted truncate">
- <%= safe_join([meeting.project.name,
- display_time(meeting.occurred_at, user: current_user),
- meeting_column_value(meeting, { key: 'participants' }).presence].compact, ' · ') %>
- </p>
- </li>
- <% end %>
- </ul>
<% else %>
- <div class="relative w-full">
- <table class="w-full table-fixed meeting-table">
- <thead>
- <tr>
- <% @columns.each do |column| %>
- <th scope="col" data-column="<%= column[:key] %>"
- class="py-3 px-3 text-start text-[11px] font-mono font-medium uppercase tracking-wider text-muted <%= meeting_overview_column_width_class(column) %>">
- <%= meeting_sort_link(column, base_path: base_path, frame_id: frame_id) %>
- </th>
- <% end %>
- </tr>
- </thead>
- <tbody>
- <% rows.each do |meeting| %>
- <% row_url = organisation_project_meetings_path(@current_organisation, meeting.project, meeting_id: meeting.id) %>
- <%# A row opens the meeting on its project's page (clickable-row's
- default branch navigates the window). The title stays a real
- link for keyboard access; the controller ignores clicks on it. %>
- <tr data-meeting-id="<%= meeting.id %>"
- data-controller="clickable-row"
- data-clickable-row-url-value="<%= row_url %>"
- data-action="click->clickable-row#click"
- class="transition-colors duration-100 ease-in-out cursor-pointer hover:bg-cream-100">
- <% @columns.each do |column| %>
- <td data-column="<%= column[:key] %>" class="p-3 text-sm">
- <% if column[:key] == 'title' %>
- <h5 class="text-sm font-medium truncate">
- <%= link_to meeting.title, row_url, data: { turbo_frame: '_top' }, class: 'text-cream-900 hover:text-ink hover:underline' %>
- </h5>
- <% else %>
- <% value = meeting_column_value(meeting, column) %>
- <%= tag.div value, class: 'truncate', title: strip_tags(value.to_s) %>
- <% end %>
- </td>
- <% end %>
- </tr>
- <% end %>
- </tbody>
- </table>
- </div>
+ <%# The project page's table (meetings/_meetings_table): the columns of the
+ picker, folded by rank, pinned values under the title; on a phone
+ all of them stand under the title. A row opens the meeting on its
+ project's page until this list has a lane of its own. %>
+ <%= render 'organisations/meetings/meetings_table', meetings: rows, selected_meeting: nil,
+ base_path: base_path, frame_id: frame_id, opens_in_lane: false %>
<% end %>
<% if @pagy.count.positive? %>
<%= render 'shared/pagination_nav_compact', pagy: @pagy, frame_id: frame_id, items_per_page: @pagy.limit,
diff --git a/app/views/organisations/meetings_overview/index.html.erb b/app/views/organisations/meetings_overview/index.html.erb
index aed9dd2..3aeeb1d 100644
--- a/app/views/organisations/meetings_overview/index.html.erb
+++ b/app/views/organisations/meetings_overview/index.html.erb
@@ -10,7 +10,10 @@
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. %>
+ page. column-picker is the project page's picker (PR 2 of the plan): it
+ saves into the open view or into the base view of this list, and reloads
+ the list frame. The grid around the list is the project page's too, with
+ the picker in its side panel and an empty lane until PR 3 fills it. %>
<% content_for :head do %>
<meta name="turbo-cache-control" content="no-cache">
<% end %>
@@ -19,13 +22,17 @@
<turbo-frame id="modal"></turbo-frame>
<div class="w-full"
- data-controller="index-page viewport list-address"
+ data-controller="index-page viewport list-address column-picker"
+ <%= tag.attributes(data: meeting_column_picker_data(project: nil, frame_id: Organisations::MeetingsOverviewController::LIST_FRAME_ID)) %>
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]) %>"
data-viewport-current-mode-value="<%= @viewport_mode %>">
- <%= render 'organisations/meetings_overview/list_head' %>
- <%= render 'organisations/meetings_overview/results', meetings: @meetings, first_use: meetings_overview_first_use? %>
+ <% if @viewport_mode == 'mobile' %>
+ <%= render 'organisations/meetings_overview/index_mobile' %>
+ <% else %>
+ <%= render 'organisations/meetings_overview/index_desktop' %>
+ <% end %>
</div>
diff --git a/spec/models/view_configuration_without_project_spec.rb b/spec/models/view_configuration_without_project_spec.rb
index 3717709..2dade12 100644
--- a/spec/models/view_configuration_without_project_spec.rb
+++ b/spec/models/view_configuration_without_project_spec.rb
@@ -84,14 +84,14 @@ RSpec.describe ViewConfiguration, 'without a project' do
end
describe '.for_user_organisation' do
- it 'starts with the columns "Alle Meetings" always showed, participants pinned' do
+ it 'starts with the columns "Alle Meetings" always showed, project and participants pinned' do
config = described_class.for_user_organisation(user, organisation, 'meetings')
expect(config).not_to be_persisted
expect(config.project).to be_nil
expect(config.organisation).to eq(organisation)
expect(config.ordered_columns).to eq(%w[title project occurred_at duration_minutes participants])
- expect(config.pinned_column_keys).to eq(%w[participants])
+ expect(config.pinned_column_keys).to eq(%w[project participants])
end
it 'returns the stored row' do
diff --git a/spec/requests/organisations/meetings_overview_columns_spec.rb b/spec/requests/organisations/meetings_overview_columns_spec.rb
new file mode 100644
index 0000000..791c8ae
--- /dev/null
+++ b/spec/requests/organisations/meetings_overview_columns_spec.rb
@@ -0,0 +1,327 @@
+# frozen_string_literal: true
+
+require 'rails_helper'
+
+# The column picker of "Alle Meetings" (meetings_uebersicht_vereinheitlichen_plan.md,
+# PR 2): the project page's picker, plus the column "Projekt", which only this
+# list offers. The base view of the overview is a view configuration without a
+# project, saved through an organisation-level route; a saved view without a
+# project keeps its own list, as on the project page.
+#
+# What the rights examples hold: a reader saves only their own configuration in
+# their own organisation, only with read access to meetings somewhere, a view of
+# somebody else only with SmartFolderPolicy#update?, and a key the reader may
+# not see is refused as a whole (422). Every negative assertion first proves the
+# page or the answer it is about.
+RSpec.describe 'Organisations::MeetingsOverview columns', :ci_guard, type: :request do
+ before { Prosopite.pause } # several requests and setup writes per example
+ after { Prosopite.resume }
+
+ let(:organisation) { create(:organisation) }
+ let(:other_organisation) { create(:organisation) }
+ let(:project) { ActsAsTenant.with_tenant(organisation) { create(:project, organisation: organisation, name: 'Projekt Alpha') } }
+ let(:overview_path) { organisation_meetings_path(organisation) }
+ let(:base_columns_path) { columns_organisation_meetings_view_configuration_path(organisation) }
+ let(:json) { { 'ACCEPT' => 'application/json' } }
+
+ def member_with(levels, in_organisation = organisation)
+ create(:user).tap do |user|
+ ActsAsTenant.with_tenant(in_organisation) do
+ role = create(:role, title: "Role #{SecureRandom.hex(4)}", organisation: in_organisation)
+ create(:membership, user: user, organisation: in_organisation, role: role, active: true)
+ levels.each { |list_project, level| create(:project_permission, user: user, project: list_project, meetings_access: level) }
+ end
+ end
+ end
+
+ let(:reader) { member_with(project => 'read_only') }
+ let(:colleague) { member_with(project => 'read_only') }
+
+ def overview_config(user, in_organisation = organisation)
+ ActsAsTenant.with_tenant(in_organisation) { ViewConfiguration.find_by(user: user, organisation: in_organisation, project: nil, view_type: 'meetings') }
+ end
+
+ def project_config(user)
+ ActsAsTenant.with_tenant(organisation) { ViewConfiguration.find_by(user: user, project: project, view_type: 'meetings') }
+ end
+
+ def meeting_view(name:, owner:, view_project: nil, columns: %w[title occurred_at])
+ ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder, name: name, organisation: organisation, project: view_project, user: owner,
+ target_object_type: 'Meeting', display_columns: { 'table_columns' => columns })
+ end
+ end
+
+ def columns_of(view)
+ ActsAsTenant.with_tenant(organisation) { view.reload.ordered_columns }
+ end
+
+ def page_body
+ Capybara.string(response.body)
+ end
+
+ def head_keys
+ page_body.all('#meetings_overview_results thead th').map { |head| head['data-column'] }
+ end
+
+ def picker_keys
+ # The panel is hidden until its trigger opens it.
+ page_body.all('#column-picker li[data-column-key]', visible: :all).map { |row| row['data-column-key'] }
+ end
+
+ before do
+ ActsAsTenant.with_tenant(organisation) do
+ create(:meeting, project: project, organisation: organisation, creator: reader, title: 'Alpha Kickoff').tap do |meeting|
+ create(:meeting_participant, meeting: meeting, display_name: 'Anna Müller')
+ end
+ end
+ end
+
+ describe 'the page' do
+ before { sign_in reader }
+
+ it 'shows on a first visit the columns it always showed, with the picker at the bar' do
+ get overview_path
+
+ expect(response).to have_http_status(:ok)
+ expect(head_keys).to eq(%w[title project occurred_at duration_minutes participants])
+ expect(page_body).to have_css('[data-controller="filter-bar"] [data-column-picker-trigger]')
+ expect(page_body).to have_css('[data-controller~="column-picker"]')
+ expect(page_body.find('[data-controller~="column-picker"]')['data-column-picker-save-url-value']).to eq(base_columns_path)
+ expect(picker_keys).to include('title', 'project', 'creator', 'created_at')
+ expect(overview_config(reader)).to be_nil
+ end
+
+ it 'offers the column "Projekt" only here, not on the project page' do
+ get organisation_project_meetings_path(organisation, project)
+ expect(response).to have_http_status(:ok)
+ expect(picker_keys).to include('title', 'occurred_at')
+ expect(picker_keys).not_to include('project')
+
+ get overview_path
+ expect(picker_keys).to include('project')
+ end
+
+ it 'renders the stored list with ranks and minimum widths, and the pinned values under the title' do
+ ActsAsTenant.with_tenant(organisation) do
+ ViewConfiguration.for_user_organisation(reader, organisation, 'meetings').tap do |config|
+ config.ordered_columns = %w[title participants project]
+ config.pinned_column_keys = %w[project]
+ config.save!
+ end
+ end
+
+ get overview_path
+
+ expect(head_keys).to eq(%w[title participants project])
+ ranked = page_body.all('#meetings_overview_results thead th[data-rank]').map { |head| [head['data-column'], head['data-rank'], head['data-col-min']] }
+ expect(ranked).to eq([%w[participants 1 220], %w[project 2 140]])
+ meta = page_body.all('#meetings_overview_results tbody tr[data-meeting-id] .ticket-meta__item', visible: :all)
+ shown_under_title = meta.to_h { |item| [item.text.strip, item[:hidden].nil?] }
+ expect(shown_under_title).to eq('Anna Müller' => false, 'Projekt Alpha' => true)
+ end
+ end
+
+ describe 'saving the base view' do
+ it 'stores the list and the pins in a row of its own, apart from the project page' do
+ sign_in reader
+ patch base_columns_path, params: { cols: %w[project title creator], pins: %w[creator] }, headers: json
+
+ expect(response).to have_http_status(:ok)
+ expect(response.parsed_body).to eq('success' => true, 'columns' => %w[title project creator])
+ expect(overview_config(reader).ordered_columns).to eq(%w[title project creator])
+ expect(overview_config(reader).pinned_column_keys).to eq(%w[creator])
+ expect(project_config(reader)).to be_nil
+
+ get overview_path
+ expect(head_keys).to eq(%w[title project creator])
+ end
+
+ it 'refuses an unknown key with 422 and stores nothing' do
+ sign_in reader
+ patch base_columns_path, params: { cols: %w[title nope] }, headers: json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(response.parsed_body['success']).to be false
+ expect(overview_config(reader)).to be_nil
+ end
+
+ it 'refuses the column "Projekt" on the project page with 422' do
+ sign_in reader
+ patch columns_organisation_project_view_configuration_path(organisation, project, view_type: 'meetings'),
+ params: { cols: %w[title occurred_at] }, headers: json
+ expect(response).to have_http_status(:ok)
+
+ patch columns_organisation_project_view_configuration_path(organisation, project, view_type: 'meetings'),
+ params: { cols: %w[title project] }, headers: json
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(project_config(reader).ordered_columns).to eq(%w[title occurred_at])
+ end
+
+ it 'cannot be turned into a ticket view without a project' do
+ sign_in reader
+ patch base_columns_path, params: { cols: %w[title], view_type: 'tickets' }, headers: json
+
+ expect(response).to have_http_status(:ok)
+ expect(overview_config(reader).view_type).to eq('meetings')
+ expect(ActsAsTenant.with_tenant(organisation) { ViewConfiguration.where(user: reader, project: nil).pluck(:view_type) }).to eq(%w[meetings])
+ end
+
+ it 'refuses a reader without read access to meetings anywhere and stores nothing' do
+ without_meetings = member_with(project => 'no_access')
+ sign_in without_meetings
+
+ patch base_columns_path, params: { cols: %w[title project] }, headers: json
+
+ expect(response).to have_http_status(:forbidden)
+ expect(overview_config(without_meetings)).to be_nil
+ end
+
+ it 'writes only the own row and never reads the row of a colleague' do
+ ActsAsTenant.with_tenant(organisation) do
+ ViewConfiguration.for_user_organisation(colleague, organisation, 'meetings').tap do |config|
+ config.ordered_columns = %w[title creator]
+ config.save!
+ end
+ end
+ sign_in reader
+
+ get overview_path
+ expect(head_keys).to eq(%w[title project occurred_at duration_minutes participants])
+
+ patch base_columns_path, params: { cols: %w[title updated_at] }, headers: json
+ expect(response).to have_http_status(:ok)
+ expect(overview_config(reader).ordered_columns).to eq(%w[title updated_at])
+ expect(overview_config(colleague).ordered_columns).to eq(%w[title creator])
+ end
+
+ it 'does not reach into another organisation' do
+ foreign_project = ActsAsTenant.with_tenant(other_organisation) { create(:project, organisation: other_organisation) }
+ member_with({ foreign_project => 'read_only' }, other_organisation)
+ sign_in reader
+
+ patch columns_organisation_meetings_view_configuration_path(other_organisation), params: { cols: %w[title] }, headers: json
+
+ expect(response).to have_http_status(:found)
+ expect(overview_config(reader, other_organisation)).to be_nil
+ expect(overview_config(reader)).to be_nil
+
+ patch columns_organisation_meetings_view_configuration_path(organisation), params: { cols: %w[title] }, headers: json
+ expect(response).to have_http_status(:ok)
+ expect(overview_config(reader).ordered_columns).to eq(%w[title])
+ end
+ end
+
+ describe 'a saved view without a project' do
+ let(:own_view) { meeting_view(name: 'Meine', owner: reader) }
+
+ it 'stores its own list, the column "Projekt" included, and leaves the base view alone' do
+ sign_in reader
+ patch columns_organisation_smart_folder_path(organisation, own_view), params: { cols: %w[project title], pins: %w[project] }, headers: json
+
+ expect(response).to have_http_status(:ok)
+ expect(columns_of(own_view)).to eq(%w[title project])
+ expect(ActsAsTenant.with_tenant(organisation) { own_view.reload.pinned_column_keys }).to eq(%w[project])
+ expect(overview_config(reader)).to be_nil
+
+ get overview_path, params: { smart_folder_id: own_view.id }
+ expect(head_keys).to eq(%w[title project])
+ end
+
+ it 'ignores a project id from the request: the view belongs to the overview' do
+ sign_in reader
+ patch columns_organisation_smart_folder_path(organisation, own_view), params: { cols: %w[title project], project_id: project.id }, headers: json
+
+ expect(response).to have_http_status(:ok)
+ expect(columns_of(own_view)).to eq(%w[title project])
+ end
+
+ it 'refuses an unknown key with 422' do
+ sign_in reader
+ patch columns_organisation_smart_folder_path(organisation, own_view), params: { cols: %w[title nope] }, headers: json
+
+ expect(response).to have_http_status(:unprocessable_content)
+ expect(columns_of(own_view)).to eq(%w[title occurred_at])
+ end
+
+ it 'takes no list from somebody who may not change it' do
+ sign_in colleague
+ ActsAsTenant.with_tenant(organisation) { create(:smart_folder_share, smart_folder: own_view, user: colleague, can_edit: false) }
+
+ get overview_path, params: { smart_folder_id: own_view.id }
+ expect(response).to have_http_status(:ok)
+ expect(head_keys).to eq(%w[title occurred_at])
+
+ patch columns_organisation_smart_folder_path(organisation, own_view), params: { cols: %w[title project] }, headers: json
+ expect(response).to have_http_status(:found)
+ expect(columns_of(own_view)).to eq(%w[title occurred_at])
+ end
+
+ it 'starts with the columns and pins of the base view of the overview' do
+ ActsAsTenant.with_tenant(organisation) do
+ ViewConfiguration.for_user_organisation(reader, organisation, 'meetings').tap do |config|
+ config.ordered_columns = %w[title project creator]
+ config.pinned_column_keys = %w[creator]
+ config.save!
+ end
+ end
+ sign_in reader
+
+ post create_from_filters_organisation_smart_folders_path(organisation, target_object_type: 'Meeting', return_to: 'meetings'),
+ params: { smart_folder_name: 'Mit Anna', filter: { participant: ['anna müller'] } }
+
+ saved = ActsAsTenant.with_tenant(organisation) { SmartFolder.find_by!(name: 'Mit Anna') }
+ expect(saved.project_id).to be_nil
+ expect(saved.ordered_columns).to eq(%w[title project creator])
+ expect(saved.pinned_column_keys).to eq(%w[creator])
+ end
+
+ it 'starts with the overview defaults when the base view was never saved' do
+ sign_in reader
+
+ post create_from_filters_organisation_smart_folders_path(organisation, target_object_type: 'Meeting', return_to: 'meetings'),
+ params: { smart_folder_name: 'Mit Anna', filter: { participant: ['anna müller'] } }
+
+ saved = ActsAsTenant.with_tenant(organisation) { SmartFolder.find_by!(name: 'Mit Anna') }
+ expect(saved.ordered_columns).to eq(%w[title project occurred_at duration_minutes participants])
+ expect(saved.pinned_column_keys).to eq(%w[project participants])
+ end
+ end
+
+ describe '"für alle Ansichten übernehmen" on the overview' do
+ let(:apply_path) { apply_columns_to_all_organisation_meetings_view_configuration_path(organisation) }
+
+ it 'writes the base view of the overview and the own meeting views without a project, nothing else' do
+ own_overview_view = meeting_view(name: 'Übersicht', owner: reader)
+ own_project_view = meeting_view(name: 'Projekt', owner: reader, view_project: project)
+ colleagues_view = meeting_view(name: 'Kollegin', owner: colleague)
+ own_ticket_view = ActsAsTenant.with_tenant(organisation) do
+ create(:smart_folder, name: 'Tickets', organisation: organisation, project: nil, user: reader,
+ target_object_type: 'Ticket', display_columns: { 'table_columns' => %w[number title] })
+ end
+ sign_in reader
+
+ patch apply_path, params: { view_configuration: { table_columns: %w[project creator nope] } }
+
+ expect(response).to redirect_to(overview_path)
+ expect(flash[:notice]).to eq('Spalten für 2 Ansichten übernommen.')
+ expect(overview_config(reader).ordered_columns).to eq(%w[title project creator])
+ expect(columns_of(own_overview_view)).to eq(%w[title project creator])
+ expect(columns_of(own_project_view)).to eq(%w[title occurred_at])
+ expect(columns_of(colleagues_view)).to eq(%w[title occurred_at])
+ expect(ActsAsTenant.with_tenant(organisation) { own_ticket_view.reload.ordered_columns }).to eq(%w[number title])
+ expect(project_config(reader)).to be_nil
+ end
+
+ it 'refuses a reader without read access to meetings anywhere' do
+ without_meetings = member_with(project => 'no_access')
+ own_view = meeting_view(name: 'Übersicht', owner: without_meetings)
+ sign_in without_meetings
+
+ patch apply_path, params: { view_configuration: { table_columns: %w[project] } }
+
+ expect(response).to have_http_status(:forbidden)
+ expect(columns_of(own_view)).to eq(%w[title occurred_at])
+ end
+ end
+end
diff --git a/spec/requests/organisations/meetings_overview_spec.rb b/spec/requests/organisations/meetings_overview_spec.rb
index d89c087..6a5d481 100644
--- a/spec/requests/organisations/meetings_overview_spec.rb
+++ b/spec/requests/organisations/meetings_overview_spec.rb
@@ -311,15 +311,19 @@ RSpec.describe 'Organisations::MeetingsOverview', type: :request do
end
describe 'phone' do
- it 'renders the list without the table and without its own filters' do
+ # The project page's phone list (PR 2): the table with no ranked column in
+ # its head, every pinned value under the title, and the picker beside it.
+ it 'folds every column under the title and keeps the project and participants readable there' do
create_meeting(project: project_a, title: 'Alpha Kickoff', participants: ['Anna Mueller'])
sign_in reader
page = list(viewport: 'mobile')
- expect(page).to have_css('[data-controller="filter-bar"]')
- expect(page).not_to have_css('#meetings_overview_results table')
- expect(page).to have_css('#meetings_overview_results [data-meeting-id]', text: 'Alpha Kickoff')
- expect(page.find('#meetings_overview_results [data-meeting-id]')).to have_text('Projekt Alpha')
+ expect(page).to have_css('[data-controller="filter-bar"] [data-column-picker-trigger]')
+ expect(page).to have_css('.meeting-mobile-grid #column-picker', visible: :all)
+ expect(page).to have_css('#meetings_overview_results table[data-fit="0"]')
+ row = page.find('#meetings_overview_results tr[data-meeting-id]', text: 'Alpha Kickoff')
+ shown = row.all('.ticket-meta__item:not([hidden])').map { |item| item.text.strip }
+ expect(shown).to eq(['Projekt Alpha', 'Anna Mueller'])
end
end
diff --git a/spec/system/meetings_overview_spec.rb b/spec/system/meetings_overview_spec.rb
index 391c1fd..613e1c8 100644
--- a/spec/system/meetings_overview_spec.rb
+++ b/spec/system/meetings_overview_spec.rb
@@ -3,10 +3,11 @@
require 'rails_helper'
# "Alle Meetings" in the browser (doc/meetings_uebersicht_vereinheitlichen_plan.md,
-# PR 1): the shared filter bar with the condition "Projekt", a view saved on
-# this page and opened again, and the "+" modal, whose save must leave the list
-# with the conditions it had. The request specs cannot see the last one: the
-# modal reads the list state from the list frame in JavaScript.
+# PR 1 and 2): 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, and the column picker. The request specs cannot
+# see these: the modal reads the list state from the list frame in JavaScript,
+# and the picker saves and reloads the frame from the browser.
RSpec.describe 'Meetings overview', type: :system do
before { Prosopite.pause }
after do
@@ -107,13 +108,63 @@ RSpec.describe 'Meetings overview', type: :system do
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
+ def head_keys
+ page.all('#meetings_overview_results thead th').map { |head| head['data-column'] }
+ end
+
+ def overview_columns
+ ActsAsTenant.with_tenant(organisation) do
+ ViewConfiguration.find_by(user: user, organisation: organisation, project: nil, view_type: 'meetings')&.ordered_columns
+ end
+ end
+
+ # PR 2: the project page's column picker, with the column "Projekt" only here.
+ it 'ticks, unticks and moves a column, saves at once and keeps the order through a reload' do
+ page.driver.browser.manage.window.resize_to(1920, 1080)
+ visit organisation_meetings_path(organisation)
+ expect_titles('Alpha Kickoff', 'Beta Retro')
+ expect(head_keys).to eq(%w[title project occurred_at duration_minutes participants])
+
+ find('[data-column-picker-trigger]').click
+ expect(page).to have_css('#column-picker', visible: :visible, wait: 5)
+ expect(page).to have_css('#column-picker li[data-key="project"]')
+
+ find('#column-picker li[data-key="creator"] label').click
+ expect(page).to have_css('#meetings_overview_results th[data-column="creator"]', wait: 5)
+ find('#column-picker li[data-key="duration_minutes"] label').click
+ expect(page).to have_no_css('#meetings_overview_results th[data-column="duration_minutes"]', wait: 5)
+
+ row = find('#column-picker li[data-key="creator"]')
+ row.find('.column-picker__grip').click
+ row.send_keys(%i[alt up])
+ expect(page).to have_css('#meetings_overview_results th[data-column="creator"][data-rank="3"]', wait: 5)
+ row.send_keys(%i[alt up])
+ expect(page).to have_css('#meetings_overview_results th[data-column="creator"][data-rank="2"]', wait: 5)
+ expect(overview_columns).to eq(%w[title project creator occurred_at participants])
+
+ page.refresh
+ expect(page).to have_css('#meetings_overview_results th[data-column="creator"]', wait: 5)
+ expect(head_keys).to eq(%w[title project creator occurred_at participants])
+
+ visit organisation_project_meetings_path(organisation, alpha)
+ find('[data-column-picker-trigger]').click
+ expect(page).to have_css('#column-picker li[data-key="creator"]', visible: :visible, wait: 5)
+ expect(page).to have_no_css('#column-picker li[data-key="project"]')
+ expect(page).to have_no_css('table th[data-column="creator"]')
+ end
+
+ it 'fits a phone of 390 px without scrolling sideways, the project under each title' do
page.driver.browser.manage.window.resize_to(390, 844)
visit organisation_meetings_path(organisation)
- expect(page).to have_css('#meetings_overview_results li[data-meeting-id]', count: 2, wait: 10)
- expect(page).to have_css('[data-controller="filter-bar"]')
+ expect(page).to have_css('#meetings_overview_results tr[data-meeting-id]', count: 2, wait: 10)
+ expect(page).to have_css('[data-controller="filter-bar"] [data-column-picker-trigger]')
+ expect(page).to have_css('#meetings_overview_results tr[data-meeting-id] .ticket-meta__item', text: 'Projekt Alpha')
overflow = page.evaluate_script('document.documentElement.scrollWidth - document.documentElement.clientWidth')
expect(overflow).to be <= 0
+ list_overflow = page.evaluate_script(
+ "(function(){ var box = document.querySelector('#meetings_overview_results table').parentElement; return box.scrollWidth - box.clientWidth })()"
+ )
+ expect(list_overflow).to be <= 0
end
end