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
Save meeting columns without a project, and keep project pages off overview views
Guido Boykee727d07b844f
diff --git a/app/controllers/organisations/smart_folders_controller.rb b/app/controllers/organisations/smart_folders_controller.rbindex 24c7b0f..7446c2f 100644--- a/app/controllers/organisations/smart_folders_controller.rb+++ b/app/controllers/organisations/smart_folders_controller.rb@@ -264,21 +264,25 @@ class Organisations::SmartFoldersController < Organisations::BaseController# S3): cols[] as the picker wrote it into the address. One trivial write, so it# stays here (seam rule). A key the reader may not see in this project is# refused as a whole (422), not sliced away: the bar would otherwise record a- # list as saved that the server never stored. An org-wide folder has no project- # of its own; the list sends its project_id along, as update_from_filters does.+ # list as saved that the server never stored. An org-wide ticket folder has no+ # project of its own; the list sends its project_id along, as+ # update_from_filters does. A meeting folder without a project is different:+ # it belongs to "Alle Meetings", whose columns it takes (the column "Projekt"+ # among them), and a project_id from the request does not change that.def columnsauthorize @smart_folder, :update?- project = @smart_folder.project || selectable_projects.find_by(id: params[:project_id])+ overview_view = overview_meeting_folder?+ project = @smart_folder.project || (selectable_projects.find_by(id: params[:project_id]) unless overview_view)keys, unknown = resolved_column_keys(project)- refused = project.nil? || keys.nil? || unknown.any?+ refused = (project.nil? && !overview_view) || keys.nil? || unknown.any?return render json: { success: false, error: t('components.column_picker.columns_unknown') }, status: :unprocessable_content if refused# The pins belong to the same view, so they go in the same write (see# ViewConfigurationsController#columns). Order matters here: the folder# keeps both lists in ONE hash, and the pin writer reads the table list.@smart_folder.ordered_columns = keys- @smart_folder.pinned_column_keys = Array(params[:pins]).map(&:to_s).uniq & ViewConfiguration.available_columns_for(project, @smart_folder.column_view_type, user: current_user).pluck(:key) if params.key?(:pins)+ @smart_folder.pinned_column_keys = Array(params[:pins]).map(&:to_s).uniq & known_column_keys(project) if params.key?(:pins)@smart_folder.save!render json: { success: true, columns: @smart_folder.ordered_columns }, status: :okend@@ -304,13 +308,16 @@ class Organisations::SmartFoldersController < Organisations::BaseControllerreturnend- # A new ticket view starts with the reader's base view columns of the project- # ("Alle Tickets" is the template, plan D6) and stands alone from then on.- # A view without a project has no base view to start from (columns come with- # PR 2 of doc/meetings_uebersicht_vereinheitlichen_plan.md).+ # A new view starts with the reader's base view columns of its list ("Alle+ # Tickets" is the template, plan D6) and stands alone from then on. A meeting+ # view without a project starts from the base view of "Alle Meetings"; a+ # ticket view without a project has no base view to start from.target = filter_save_target_object_typeview_type = target == 'Meeting' ? 'meetings' : 'tickets'- base_columns = ViewConfiguration.for_user_project(current_user, project, view_type) if project+ if project || view_type.in?(ViewConfiguration::ORGANISATION_WIDE_VIEW_TYPES)+ base_columns = ViewConfiguration.for_list(user: current_user, organisation: @current_organisation,+ project: project, view_type: view_type)+ endinherited = base_columns.ordered_columns if base_columns && target.in?(%w[Ticket All Meeting])result = Actors::SaveSmartFolderFromFilters.call(project: project,@@ -561,14 +568,24 @@ class Organisations::SmartFoldersController < Organisations::BaseControllerend# cols[] from the address, normalised, against what this reader may see in- # the project (ViewConfiguration.available_columns_for). Answers [keys, unknown],- # or nil when the request carries no list at all.+ # the folder's list (ViewConfiguration.available_columns_for; project nil is+ # "Alle Meetings"). Answers [keys, unknown], or nil when the request carries+ # no list at all.def resolved_column_keys(project)- return nil if params[:cols].blank? || project.nil?+ return nil if params[:cols].blank?keys = ViewConfiguration.normalize_columns(params[:cols], @smart_folder.column_view_type)- known = ViewConfiguration.available_columns_for(project, @smart_folder.column_view_type, user: current_user).map { |column| column[:key] }- [keys, keys - known]+ [keys, keys - known_column_keys(project)]+ end++ def known_column_keys(project)+ ViewConfiguration.available_columns_for(project, @smart_folder.column_view_type, user: current_user).pluck(:key)+ end++ # A meeting view without a project shows only on "Alle Meetings"+ # (meetings_uebersicht_vereinheitlichen_plan.md, decision 3).+ def overview_meeting_folder?+ @smart_folder.project_id.nil? && @smart_folder.column_view_type.in?(ViewConfiguration::ORGANISATION_WIDE_VIEW_TYPES)end# PE-B: "Save as Smart Folder" adopts the type of the source pagediff --git a/app/controllers/organisations/view_configurations_controller.rb b/app/controllers/organisations/view_configurations_controller.rbindex 37c3e6a..171dc00 100644--- a/app/controllers/organisations/view_configurations_controller.rb+++ b/app/controllers/organisations/view_configurations_controller.rb@@ -1,10 +1,21 @@# frozen_string_literal: true+# The base view's settings of a list: columns, pins, view mode. Two routes lead+# here. The project route (resource :view_configuration under a project) serves+# tickets and the meetings of a project. The organisation route (resource+# :meetings_view_configuration) serves the base view of "Alle Meetings", which+# has no project (meetings_uebersicht_vereinheitlichen_plan.md, PR 2): only+# columns and apply_columns_to_all, view_type pinned to meetings by the route.+# One controller, so both lists refuse and store keys and pins the same way.class Organisations::ViewConfigurationsController < Organisations::BaseControllerinclude ProjectController+ # Whether the route names a project is read from the path, never from the+ # query: a project_id in the address of the organisation route stays a+ # query param and changes nothing.+ skip_before_action :set_project, unless: :project_route?skip_before_action :authorize_project_access!- before_action :authorize_project_show+ before_action :authorize_list_accessbefore_action :set_view_configurationdef update@@ -60,7 +71,8 @@ class Organisations::ViewConfigurationsController < Organisations::BaseControlledef apply_columns_to_allkeys = ViewConfiguration.normalize_columns(params.dig(:view_configuration, :table_columns), column_view_type)known = @view_configuration.available_columns.map { |column| column[:key] }- actor = Actors::ApplyColumnsToViews.new(project: @project, current_user: current_user, columns: keys & known, view_type: column_view_type)+ actor = Actors::ApplyColumnsToViews.new(project: @project, organisation: @current_organisation, current_user: current_user,+ columns: keys & known, view_type: column_view_type)result = actor.callif result.success?@@ -86,6 +98,20 @@ class Organisations::ViewConfigurationsController < Organisations::BaseControlleprivate+ def project_route?+ request.path_parameters.key?(:project_id)+ end++ def authorize_list_access+ return authorize_project_show if @project++ # "Alle Meetings": the page's own gate (MeetingsOverviewController#require_meetings_access),+ # read access to meetings in at least one project of this organisation.+ head :forbidden unless AccessCheck::ProjectAccessService.accessible_project_ids(+ current_user, @current_organisation, action: :read, area: :meetings+ ).any?+ end+def authorize_project_showauthorize @project, :show?head :forbidden unless policy(@project).area_access?(column_view_type.to_sym, :read)@@ -96,12 +122,18 @@ class Organisations::ViewConfigurationsController < Organisations::BaseControlleenddef column_list_path+ return organisation_meetings_path(@current_organisation) unless @project+column_view_type == 'meetings' ? organisation_project_meetings_path(@current_organisation, @project) : organisation_project_tickets_path(@current_organisation, @project)end+ # Always the reader's own row in this organisation (ViewConfigurationPolicy:+ # owner only, no admin bypass).def set_view_configuration- @view_configuration = ViewConfiguration.for_user_project(current_user, @project, column_view_type)+ @view_configuration = ViewConfiguration.for_list(user: current_user, organisation: @current_organisation,+ project: @project, view_type: column_view_type)@view_configuration.organisation = @current_organisation+ authorize @view_configuration, :update?enddef view_configuration_paramsdiff --git a/app/services/actors/apply_columns_to_views.rb b/app/services/actors/apply_columns_to_views.rbindex 812cd07..c54221c 100644--- a/app/services/actors/apply_columns_to_views.rb+++ b/app/services/actors/apply_columns_to_views.rb@@ -4,12 +4,22 @@## Tier-1 actor behind the column picker's "für alle Ansichten übernehmen"# (doc/spaltenwahl_plan.md, D5 and S5): ONE ordered column list into the-# reader's base view of the project (ViewConfiguration) and into every matching-# view of the reader's OWN that shows in this project (project-bound and-# org-wide folders the reader owns). Views other people own or share stay-# untouched: this is the reader's exception, not a broadcast. Several records,-# one transaction, hence an actor and not a controller write. applied_count-# says how many views took the list, for the flash.+# reader's base view of the list (ViewConfiguration) and into every matching+# view of the reader's OWN that shows in that list. Views other people own or+# share stay untouched: this is the reader's exception, not a broadcast. Several+# records, one transaction, hence an actor and not a controller write.+# applied_count says how many views took the list, for the flash.+#+# Which views show in a list depends on the list type:+#+# tickets project_id = the project OR IS NULL (a project list+# shows the org-wide folders too)+# meetings, project project_id = the project+# meetings, no project ("Alle Meetings") project_id IS NULL+#+# A meeting view without a project belongs to "Alle Meetings" and shows only+# there (meetings_uebersicht_vereinheitlichen_plan.md, decision 3). Until PR 2+# of that plan a project page still wrote into it here.module Actorsclass ApplyColumnsToViews < BaseActorattr_reader :applied_count@@ -28,9 +38,12 @@ module Actorsupdated_at = :nowSQL- def initialize(project:, current_user:, columns:, view_type: 'tickets')+ # project: nil is the list of the whole organisation, which only meetings+ # have; it names its organisation, a project brings its own.+ def initialize(project:, current_user:, columns:, view_type: 'tickets', organisation: project&.organisation)super()@project = project+ @organisation = organisation@current_user = current_user@columns = columns@view_type = view_type@@ -42,8 +55,9 @@ module Actorsenddef perform- @view_configuration = ViewConfiguration.for_user_project(@current_user, @project, @view_type)- @view_configuration.organisation ||= @project.organisation+ @view_configuration = ViewConfiguration.for_list(user: @current_user, organisation: @organisation,+ project: @project, view_type: @view_type)+ @view_configuration.organisation ||= @organisation@view_configuration.ordered_columns = @columns@view_configuration.save!@applied_count = 1@@ -60,10 +74,15 @@ module Actorsprivate- # Own folders of the requested list type visible in this project.+ # Own folders of the requested list type that show in this list (see the+ # table in the header).def own_views- SmartFolder.where(user: @current_user, organisation: @project.organisation, target_object_type: (@view_type == 'meetings' ? %w[Meeting] : %w[Ticket All]))- .where('project_id IS NULL OR project_id = ?', @project.id)+ if @view_type == 'meetings'+ SmartFolder.where(user: @current_user, organisation: @organisation, target_object_type: 'Meeting', project_id: @project&.id)+ else+ SmartFolder.where(user: @current_user, organisation: @organisation, target_object_type: %w[Ticket All])+ .where('project_id IS NULL OR project_id = ?', @project.id)+ endendendenddiff --git a/config/routes.rb b/config/routes.rbindex 2f12934..1cb99ed 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -326,6 +326,15 @@ Rails.application.routes.draw do# project-nested MeetingsController (which is bound to @project).get 'meetings', to: 'meetings_overview#index', as: :meetings+ # The column picker of "Alle Meetings" saves the overview's base view here:+ # the controller of the project route (view_configuration under a project),+ # without a project. The path default pins the list type; a view_type in the+ # query cannot override it.+ resource :meetings_view_configuration, controller: 'view_configurations', only: [], defaults: { view_type: 'meetings' } do+ patch :columns+ patch :apply_columns_to_all+ end+# Teilnehmer-Claim (Nachtrag): org-level link/reject of external participations to# an org member. NOT project-nested — a claim spans every project the acting user# may write meetings in. Both are writes → POST; link goes through an actor,diff --git a/spec/requests/organisations/view_configurations_apply_columns_spec.rb b/spec/requests/organisations/view_configurations_apply_columns_spec.rbindex debed32..1608c6a 100644--- a/spec/requests/organisations/view_configurations_apply_columns_spec.rb+++ b/spec/requests/organisations/view_configurations_apply_columns_spec.rb@@ -74,4 +74,34 @@ RSpec.describe 'Organisations::ViewConfigurations#apply_columns_to_all', type: :expect(flash[:notice]).to eq('Spalten für eine Ansicht übernommen.')end++ # A meeting view without a project belongs to "Alle Meetings" and shows only+ # there (meetings_uebersicht_vereinheitlichen_plan.md, decision 3). Until PR 2+ # the project page's "für alle Ansichten übernehmen" still wrote into it, so a+ # click on a project page changed the columns of a list it does not show.+ # Ticket views without a project keep showing in every project list and keep+ # taking the list (first example).+ describe 'meeting views' do+ def meeting_folder(name:, owner:, project:)+ ActsAsTenant.with_tenant(organisation) do+ create(:smart_folder, name: name, organisation: organisation, project: project, user: owner,+ target_object_type: 'Meeting', display_columns: { 'table_columns' => %w[title occurred_at] })+ end+ end++ it 'writes the own meeting views of this project and none of the overview' do+ own_project_view = meeting_folder(name: 'Projekt', owner: user, project: project)+ own_overview_view = meeting_folder(name: 'Übersicht', owner: user, project: nil)+ own_elsewhere = meeting_folder(name: 'Anderswo', owner: user, project: other_project)++ patch apply_columns_to_all_organisation_project_view_configuration_path(organisation, project, view_type: 'meetings'),+ params: { view_configuration: { table_columns: %w[creator] } }++ expect(response).to redirect_to(organisation_project_meetings_path(organisation, project))+ expect(flash[:notice]).to eq('Spalten für 2 Ansichten übernommen.')+ expect(columns_of(own_project_view)).to eq(%w[title creator])+ expect(columns_of(own_overview_view)).to eq(%w[title occurred_at])+ expect(columns_of(own_elsewhere)).to eq(%w[title occurred_at])+ end+ endend