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
Show a new sub-task in the ticket list beside it
Guido Boyke44138b371970
diff --git a/app/views/organisations/tickets/subtasks/create.turbo_stream.erb b/app/views/organisations/tickets/subtasks/create.turbo_stream.erbindex 7d8e997..f6014de 100644--- a/app/views/organisations/tickets/subtasks/create.turbo_stream.erb+++ b/app/views/organisations/tickets/subtasks/create.turbo_stream.erb@@ -16,3 +16,9 @@<%# The parent's Subs cell in the list counts its sub-tickets (TicketListColumns). %><%= safe_join(ticket_list_parent_streams(@child)) %>++<%# The new sub-task is a row of the list too. Its place, and whether the filter shows it, only+ the list's query knows, so the frame reloads from the page's live address. No frame on this+ page (the inbox, a standalone ticket): the action does nothing. The quick-add sits outside+ the frame and keeps its focus. %>+<%= turbo_stream.action(:reloadFrame, 'tickets_list_frame') %>diff --git a/app/views/organisations/tickets/subtasks/create_first.turbo_stream.erb b/app/views/organisations/tickets/subtasks/create_first.turbo_stream.erbindex bc55568..f08e216 100644--- a/app/views/organisations/tickets/subtasks/create_first.turbo_stream.erb+++ b/app/views/organisations/tickets/subtasks/create_first.turbo_stream.erb@@ -9,3 +9,9 @@<%# The parent's Subs cell in the list counts its sub-tickets (TicketListColumns). %><%= safe_join(ticket_list_parent_streams(@child)) %>++<%# The new sub-task is a row of the list too. Its place, and whether the filter shows it, only+ the list's query knows, so the frame reloads from the page's live address. No frame on this+ page (the inbox, a standalone ticket): the action does nothing. The quick-add sits outside+ the frame and keeps its focus. %>+<%= turbo_stream.action(:reloadFrame, 'tickets_list_frame') %>diff --git a/spec/requests/organisations/tickets_subtasks_quick_add_spec.rb b/spec/requests/organisations/tickets_subtasks_quick_add_spec.rbindex 68c30b8..c9d82c9 100644--- a/spec/requests/organisations/tickets_subtasks_quick_add_spec.rb+++ b/spec/requests/organisations/tickets_subtasks_quick_add_spec.rb@@ -57,6 +57,43 @@ RSpec.describe 'Tickets sub-tasks quick-add', type: :request doexpect(response.body).to include('Bilder besorgen')end+ # A new sub-task is a ticket of the list. Which row it takes, and whether the filter shows it at+ # all, only the list's own query knows, so the page reloads the frame from its live address.+ describe 'the ticket list' do+ def reloads_the_list?+ Nokogiri::HTML(response.body).css('turbo-stream').any? do |stream|+ stream['action'] == 'reloadFrame' && stream['target'] == 'tickets_list_frame'+ end+ end++ it 'reloads after the first sub-task' do+ post organisation_project_ticket_subtasks_path(organisation, project, parent),+ params: { title: 'Texte liefern' }, as: :turbo_stream++ expect(response).to have_http_status(:ok)+ expect(reloads_the_list?).to be(true)+ end++ it 'reloads after a further sub-task' do+ create(:ticket, project: project, creator: user, parent: parent)++ post organisation_project_ticket_subtasks_path(organisation, project, parent),+ params: { title: 'Bilder besorgen' }, as: :turbo_stream++ expect(response).to have_http_status(:ok)+ expect(reloads_the_list?).to be(true)+ end++ it 'stays as it is when nothing was created' do+ post organisation_project_ticket_subtasks_path(organisation, project, parent),+ params: { title: '' }, as: :turbo_stream++ expect(response).to have_http_status(:unprocessable_content)+ expect(response.body).to include('turbo-stream')+ expect(reloads_the_list?).to be(false)+ end+ end+it 'first child for a "compact" user comes back expanded so the next can be typed' doViewConfiguration.for_user_project(user, project, 'tickets').update!(detail_settings: { 'subtasks_display' => 'compact' })diff --git a/spec/system/subtasks_quick_add_spec.rb b/spec/system/subtasks_quick_add_spec.rbindex 2b8f5f2..191e53f 100644--- a/spec/system/subtasks_quick_add_spec.rb+++ b/spec/system/subtasks_quick_add_spec.rb@@ -42,4 +42,38 @@ RSpec.describe 'Sub-tasks inline quick-add', type: :system doexpect(find_field(placeholder).value).to eq('')expect(ActsAsTenant.with_tenant(organisation) { parent.children.count }).to eq(1)end++ # The address names `items`, so the list frame's src equals it after the first reload. Each+ # assignment to src fetches, even an unchanged one. A frame.reload() behind it fetched again,+ # the duplicate guard in application.js blocked that, and the second row never came.+ it 'shows every new sub-task in the ticket list beside it, with no page change' do+ placeholder = I18n.t('views.organisations.tickets.shared.subtasks.add_placeholder')+ parent++ visit organisation_project_tickets_path(organisation, project, ticket_id: parent.id, items: 20)+ page.execute_script('window.__quickAddPageMark = true')++ within('#ticket_display_frame') do+ find('[data-timeline-filter-target="stateWord"]').click+ find('[data-timeline-filter-target="subtasksToggleButton"]').click+ find('[data-timeline-filter-target="stateWord"]').click++ fill_in placeholder, with: 'Texte liefern'+ find_field(placeholder).send_keys(:enter)+ end+ within('#tickets_list_frame') { expect(page).to have_content('Texte liefern') }++ # A person's pace: the same guard drops a second POST to this address inside 500 ms.+ sleep 0.6+ within('#ticket_display_frame') do+ fill_in placeholder, with: 'Bilder besorgen'+ find_field(placeholder).send_keys(:enter)+ end+ within('#tickets_list_frame') do+ expect(page).to have_content('Texte liefern')+ expect(page).to have_content('Bilder besorgen')+ end++ expect(page.evaluate_script('window.__quickAddPageMark === true')).to be(true)+ endend