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
Hide an empty trail and pin the refused re-parent in the list
Guido Boykea69c5b737d1c
diff --git a/app/views/organisations/tickets/_subtasks_section.html.erb b/app/views/organisations/tickets/_subtasks_section.html.erbindex 620bba1..74ce7f3 100644--- a/app/views/organisations/tickets/_subtasks_section.html.erb+++ b/app/views/organisations/tickets/_subtasks_section.html.erb@@ -1,4 +1,4 @@-<%# Sub-tasks section — on every ticket, a sub-task too, since sub-tasks nest to any depth+<%# Sub-tasks section: on every ticket, a sub-task too, since sub-tasks nest to any depth(rendered from _timeline_frame_content). Lists the DIRECT children only.Two states:- EMPTY (no children): just a compact, right-aligned "+ Unteraufgabe hinzufügen" affordancediff --git a/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb b/app/views/organisations/tickets/_ticket_breadcrumbs.html.erbindex 9456ae8..f840f8e 100644--- a/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb+++ b/app/views/organisations/tickets/_ticket_breadcrumbs.html.erb@@ -2,10 +2,10 @@the list with that ticket open (the target of the old "part of" pill), thenthe ticket's own number, not a link. Sub-tasks nest to any depth, so thewhole chain shows and wraps on a narrow screen; nothing is collapsed.- One query for the chain (Tickets::Ancestry). Rendered by the header for a- ticket with a parent; needs ticket, project and current_organisation, which- the header has on the page and in its turbo streams alike. %>-<% ancestors = Tickets::Ancestry.call(ticket: ticket) %>+ The header reads the chain (Tickets::Ancestry, one query) and renders this+ only when it found ancestors. Needs ticket, ancestors, project and+ current_organisation, which the header has on the page and in its turbo+ streams alike. %><nav aria-label="<%= t('views.organisations.tickets.shared.subtasks.breadcrumbs_label') %>"><ol class="flex flex-wrap items-center gap-1 text-xs text-cream-700"><% ancestors.each do |ancestor| %>diff --git a/app/views/organisations/tickets/_ticket_header_show.html.erb b/app/views/organisations/tickets/_ticket_header_show.html.erbindex 7bd2f2c..e425941 100644--- a/app/views/organisations/tickets/_ticket_header_show.html.erb+++ b/app/views/organisations/tickets/_ticket_header_show.html.erb@@ -116,10 +116,15 @@<%= ticket.title %><% end %></h2>- <%# Where a sub-task sits in its tree: every ticket above it, then its own number. %>- <% if ticket.parent_id.present? %>+ <%# Where a sub-task sits in its tree: every ticket above it, then its own number.+ Decided by what the walk finds, not by parent_id alone: a parent it cannot+ reach (deleted meanwhile, legacy data in another project) leaves no+ ancestors, and a trail of the own number alone would say nothing. %>+ <% ancestors = ticket.parent_id.present? ? Tickets::Ancestry.call(ticket: ticket) : [] %>+ <% if ancestors.any? %><%= render 'organisations/tickets/ticket_breadcrumbs',- ticket: ticket, project: project, current_organisation: current_organisation %>+ ticket: ticket, ancestors: ancestors, project: project,+ current_organisation: current_organisation %><% end %></div>diff --git a/spec/requests/organisations/tickets_subtasks_render_spec.rb b/spec/requests/organisations/tickets_subtasks_render_spec.rbindex 627c320..4546ab4 100644--- a/spec/requests/organisations/tickets_subtasks_render_spec.rb+++ b/spec/requests/organisations/tickets_subtasks_render_spec.rb@@ -122,6 +122,23 @@ RSpec.describe 'Tickets sub-tasks (detail rendering)', type: :request doexpect(statements.grep(/WITH RECURSIVE ancestors/).size).to eq(1)end+ # The header asks the database, not parent_id: a parent the walk cannot reach (deleted+ # meanwhile, or legacy data in another project) leaves no ancestors, and a trail of the+ # ticket's own number alone would say nothing. Written past the model on purpose.+ it 'shows no trail when the parent lies in another project' do+ other_project = create(:project, organisation: organisation)+ foreign = create(:ticket, project: other_project, creator: user)+ orphan = create(:ticket, project: project, creator: user)+ orphan.update_column(:parent_id, foreign.id)++ statements = capture_sql { get detail_path(orphan) }++ expect(response).to have_http_status(:ok)+ expect(breadcrumbs).to be_nil+ expect(response.body).not_to include("##{foreign.number}</a>")+ expect(statements.grep(/WITH RECURSIVE ancestors/).size).to eq(1)+ end+it 'shows no trail on a top-level ticket' dolone = create(:ticket, project: project, creator: user)diff --git a/spec/requests/ticket_subtask_count_column_spec.rb b/spec/requests/ticket_subtask_count_column_spec.rbindex b1b5ad4..32addad 100644--- a/spec/requests/ticket_subtask_count_column_spec.rb+++ b/spec/requests/ticket_subtask_count_column_spec.rb@@ -282,16 +282,29 @@ RSpec.describe 'Ticket table: sub-ticket column', type: :request doend# A saved ticket keeps its parent (Ticket#parent_unchanged): an edit that names- # another parent changes nothing, so no row has a new count to show.- it 'keeps the parent when an edit names another one, and the other stays empty' do+ # another parent is refused in the writing surface, and no row is redrawn. The+ # error text is what makes this bite: without the rule the edit saves, the+ # answer is the success branch, and the new parent's cell gets a stream.+ it 'refuses an edit that names another parent and redraws no row' donew_parent = create(:ticket, project: project, creator: user)sub = child('Offen')patch organisation_project_ticket_path(organisation, project, sub),params: { ticket: { title: sub.title, parent_id: new_parent.id } }, headers: stream_headers+ expect(response).to have_http_status(:ok)expect(sub.reload.parent_id).to eq(parent.id)- expect(parent_cell(of: new_parent).to_s).to eq('')++ streams = Nokogiri::HTML(response.body).css('turbo-stream')+ surface = streams.find { |node| node['target'] == 'writing_surface' }+ expect(surface).to be_present+ expect(surface['action']).to eq('replace')+ message = Ticket.new.errors.full_message(+ :parent_id, I18n.t('activerecord.errors.models.ticket.attributes.parent_id.cannot_change')+ )+ expect(message).to start_with(Ticket.human_attribute_name(:parent_id))+ expect(surface.text).to include(message)+ expect(streams.map { |node| node['targets'].to_s }.grep(/#{new_parent.id}/)).to be_emptyend# Finding 2 of the second review: the unread dot on the parent's number