OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
fixed filter behavior
Jonas Jabarib09c50d0288e
diff --git a/app/components/work_packages/activities_tab/journals/day_component.html.erb b/app/components/work_packages/activities_tab/journals/day_component.html.erbindex 3b547089447..f221b92151b 100644--- a/app/components/work_packages/activities_tab/journals/day_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/day_component.html.erb@@ -9,7 +9,7 @@journals.each do |journal|journals_of_day_container.with_row dorender(- WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal:)+ WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal:, filter:))endenddiff --git a/app/components/work_packages/activities_tab/journals/day_component.rb b/app/components/work_packages/activities_tab/journals/day_component.rbindex 2b72d553e33..5ddc32cc8a3 100644--- a/app/components/work_packages/activities_tab/journals/day_component.rb+++ b/app/components/work_packages/activities_tab/journals/day_component.rb@@ -36,17 +36,18 @@ module WorkPackagesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(day_as_date:, journals:, work_package:)+ def initialize(day_as_date:, journals:, work_package:, filter:)super@work_package = work_package@day_as_date = day_as_date@journals = journals+ @filter = filterendprivate- attr_reader :work_package, :day_as_date, :journals+ attr_reader :work_package, :day_as_date, :journals, :filterdef insert_target_modified?truediff --git a/app/components/work_packages/activities_tab/journals/index_component.html.erb b/app/components/work_packages/activities_tab/journals/index_component.html.erbindex fdac77e9d30..6eed26bc545 100644--- a/app/components/work_packages/activities_tab/journals/index_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/index_component.html.erb@@ -5,7 +5,7 @@journals_grouped_by_day.each do |day, journals|journals_index_container.with_row dorender(- WorkPackages::ActivitiesTab::Journals::DayComponent.new(day_as_date: day, journals:, work_package:)+ WorkPackages::ActivitiesTab::Journals::DayComponent.new(day_as_date: day, journals:, work_package:, filter:))endenddiff --git a/app/components/work_packages/activities_tab/journals/index_component.rb b/app/components/work_packages/activities_tab/journals/index_component.rbindex 5dc61aedbf5..d2dfa17857e 100644--- a/app/components/work_packages/activities_tab/journals/index_component.rb+++ b/app/components/work_packages/activities_tab/journals/index_component.rb@@ -63,7 +63,6 @@ module WorkPackagesresult = work_package.journals.includes(:user, :notifications).reorder(version: journal_sorting)result = result.where.not(notes: "") if filter == :only_comments- result = result.where(notes: "") if filter == :only_changesresult.group_by { |journal| journal.created_at.in_time_zone(User.current.time_zone).to_date }enddiff --git a/app/components/work_packages/activities_tab/journals/item_component.html.erb b/app/components/work_packages/activities_tab/journals/item_component.html.erbindex 0a8d45e5a9d..50613ac1021 100644--- a/app/components/work_packages/activities_tab/journals/item_component.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component.html.erb@@ -1,8 +1,8 @@<%=component_wrapper(data: wrapper_data_attributes, class: "work-packages-activities-tab-journals-item-component") doflex_layout do |journal_container|- if journal.notes.present?- journal_container.with_row do+ if show_comment_container?+ journal_container.with_row(classes: "comment-border-box") dorender(border_box_container(id: "activity-#{journal.version}", padding: :condensed)) do |border_box_component|border_box_component.with_header(px: 2, py: 0) doflex_layout(align_items: :center, justify_content: :space_between) do |header_container|@@ -73,7 +73,7 @@endendjournal_container.with_row do- render(WorkPackages::ActivitiesTab::Journals::ItemComponent::Details.new(journal:, has_unread_notifications: notification_on_details?))+ render(WorkPackages::ActivitiesTab::Journals::ItemComponent::Details.new(journal:, has_unread_notifications: notification_on_details?, filter:))endendenddiff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rbindex 7b7042b8231..67048023500 100644--- a/app/components/work_packages/activities_tab/journals/item_component.rb+++ b/app/components/work_packages/activities_tab/journals/item_component.rb@@ -34,11 +34,12 @@ module WorkPackagesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(journal:, state: :show)+ def initialize(journal:, filter:, state: :show)super@journal = journal@state = state+ @filter = filterenddef content@@ -52,14 +53,14 @@ module WorkPackagesprivate- attr_reader :journal, :state+ attr_reader :journal, :state, :filterdef wrapper_uniq_byjournal.idenddef child_component_params- { journal: }.compact+ { journal:, filter: }.compactenddef wrapper_data_attributes@@ -70,6 +71,10 @@ module WorkPackages}end+ def show_comment_container?+ journal.notes.present? && filter != :only_changes+ end+def activity_url"#{project_work_package_url(journal.journable.project, journal.journable)}/activity#{activity_anchor}"end@@ -110,7 +115,7 @@ module WorkPackagesdef edit_action_item(menu)menu.with_item(label: t("js.label_edit_comment"),- href: edit_work_package_activity_path(journal.journable, journal),+ href: edit_work_package_activity_path(journal.journable, journal, filter:),content_arguments: {data: { "turbo-stream": true }}) do |item|diff --git a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb b/app/components/work_packages/activities_tab/journals/item_component/details.html.erbindex 384c3c0a532..561ee79a863 100644--- a/app/components/work_packages/activities_tab/journals/item_component/details.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/details.html.erb@@ -1,14 +1,21 @@<%=component_wrapper(class: "work-packages-activities-tab-journals-item-component-details") do- if journal.details.any?+ if journal.details.any? && filter != :only_commentsflex_layout(my: 0, border: :left, classes: "details-container") do |details_container|- if journal.notes.present?+ if journal.notes.present? && filter != :only_changesrender_details(details_container)elserender_details_header(details_container)render_details(details_container)endend+ elsif journal.details.empty?+ unless filter == :only_changes+ flex_layout(my: 0, border: :left, classes: "details-container details-container--empty--#{journal_sorting}") do |details_container|+ # empty row to render the flex layout with its minimal height+ render_empty_line(details_container)+ end+ endelseflex_layout(my: 0, border: :left, classes: "details-container details-container--empty--#{journal_sorting}") do |details_container|# empty row to render the flex layout with its minimal heightdiff --git a/app/components/work_packages/activities_tab/journals/item_component/details.rb b/app/components/work_packages/activities_tab/journals/item_component/details.rbindex 776d8db809e..1152bc0ddca 100644--- a/app/components/work_packages/activities_tab/journals/item_component/details.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/details.rb@@ -36,16 +36,17 @@ module WorkPackagesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(journal:, has_unread_notifications: false)+ def initialize(journal:, filter:, has_unread_notifications: false)super@journal = journal@has_unread_notifications = has_unread_notifications+ @filter = filterendprivate- attr_reader :journal, :has_unread_notifications+ attr_reader :journal, :has_unread_notifications, :filterdef wrapper_uniq_byjournal.iddiff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erbindex 47bbd8e0bf8..a17fb186d2f 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.html.erb@@ -6,7 +6,7 @@model: journal,method: :put,data: { turbo: true, turbo_stream: true },- url: work_package_activity_path(work_package_id: work_package.id, id: journal.id),+ url: work_package_activity_path(work_package_id: work_package.id, id: journal.id, filter:),) do |f|flex_layout do |form_container|form_container.with_row do@@ -18,7 +18,7 @@scheme: :secondary,size: :medium,tag: :a,- href: cancel_edit_work_package_activity_path(work_package.id, id: journal.id),+ href: cancel_edit_work_package_activity_path(work_package.id, id: journal.id, filter:),data: { "turbo-stream": true })) dot("button_cancel")diff --git a/app/components/work_packages/activities_tab/journals/item_component/edit.rb b/app/components/work_packages/activities_tab/journals/item_component/edit.rbindex 8bf22a5f7a8..a6bc75b2207 100644--- a/app/components/work_packages/activities_tab/journals/item_component/edit.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/edit.rb@@ -34,16 +34,17 @@ module WorkPackagesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(journal:)+ def initialize(journal:, filter:)super@journal = journal@work_package = journal.journable+ @filter = filterendprivate- attr_reader :journal, :work_package+ attr_reader :journal, :work_package, :filterdef wrapper_uniq_byjournal.iddiff --git a/app/components/work_packages/activities_tab/journals/item_component/show.rb b/app/components/work_packages/activities_tab/journals/item_component/show.rbindex a461cd5e43e..e3abc222206 100644--- a/app/components/work_packages/activities_tab/journals/item_component/show.rb+++ b/app/components/work_packages/activities_tab/journals/item_component/show.rb@@ -36,15 +36,16 @@ module WorkPackagesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(journal:)+ def initialize(journal:, filter:)super@journal = journal+ @filter = filterendprivate- attr_reader :journal+ attr_reader :journal, :filterdef wrapper_uniq_byjournal.iddiff --git a/app/controllers/work_packages/activities_tab_controller.rb b/app/controllers/work_packages/activities_tab_controller.rbindex f304d4abc29..3c2c42c722c 100644--- a/app/controllers/work_packages/activities_tab_controller.rb+++ b/app/controllers/work_packages/activities_tab_controller.rb@@ -76,7 +76,8 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerupdate_via_turbo_stream(component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal: @journal,- state: :edit+ state: :edit,+ filter: params[:filter]&.to_sym || :all))@@ -87,7 +88,8 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerupdate_via_turbo_stream(component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal: @journal,- state: :show+ state: :show,+ filter: params[:filter]&.to_sym || :all))@@ -111,15 +113,14 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerupdate_via_turbo_stream(component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal: call.result,- state: :show+ state: :show,+ filter: params[:filter]&.to_sym || :all))endgenerate_time_based_update_streams(params[:last_update_timestamp], params[:filter])end- # clear_form_via_turbo_stream-respond_with_turbo_streamsend@@ -132,7 +133,8 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerupdate_via_turbo_stream(component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal: call.result,- state: :show+ state: :show,+ filter: params[:filter]&.to_sym || :all))end@@ -185,28 +187,27 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerenddef generate_time_based_update_streams(last_update_timestamp, filter)+ filter = filter&.to_sym || :all# TODO: prototypical implementationjournals = @work_package.journals- if filter == "only_comments"+ if filter == :only_commentsjournals = journals.where.not(notes: "")end- if filter == "only_changes"- journals = journals.where(notes: "")- end-journals.where("updated_at > ?", last_update_timestamp).find_each do |journal|update_via_turbo_stream(# only use the show component in order not to loose an edit statecomponent: WorkPackages::ActivitiesTab::Journals::ItemComponent::Show.new(- journal:+ journal:,+ filter:))update_via_turbo_stream(# only use the show component in order not to loose an edit statecomponent: WorkPackages::ActivitiesTab::Journals::ItemComponent::Details.new(- journal:+ journal:,+ filter:))end@@ -214,28 +215,32 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerlatest_journal_visible_for_user = journals.where(created_at: ..last_update_timestamp).lastjournals.where("created_at > ?", last_update_timestamp).find_each do |journal|- append_or_prepend_latest_journal_via_turbo_stream(journal, latest_journal_visible_for_user)+ append_or_prepend_latest_journal_via_turbo_stream(journal, latest_journal_visible_for_user, filter)endend- def append_or_prepend_latest_journal_via_turbo_stream(journal, latest_journal)+ def append_or_prepend_latest_journal_via_turbo_stream(journal, latest_journal, filter)if latest_journal.created_at.to_date == journal.created_at.to_datetarget_component = WorkPackages::ActivitiesTab::Journals::DayComponent.new(work_package: @work_package,day_as_date: journal.created_at.to_date,- journals: [journal] # we don't need to pass all actual journals of this day as we do not really render this component+ journals: [journal], # we don't need to pass all actual journals of this day as we do not really render this component+ filter:)component = WorkPackages::ActivitiesTab::Journals::ItemComponent.new(- journal:+ journal:,+ filter:)elsetarget_component = WorkPackages::ActivitiesTab::Journals::IndexComponent.new(- work_package: @work_package+ work_package: @work_package,+ filter:)component = WorkPackages::ActivitiesTab::Journals::DayComponent.new(work_package: @work_package,day_as_date: journal.created_at.to_date,- journals: [journal]+ journals: [journal],+ filter:)endstream_config = {@@ -250,18 +255,4 @@ class WorkPackages::ActivitiesTabController < ApplicationControllerprepend_via_turbo_stream(**stream_config)endend-- def update_journal_via_turbo_stream(journal)- update_via_turbo_stream(- component: WorkPackages::ActivitiesTab::Journals::ItemComponent.new(journal:)- )- end-- def clear_form_via_turbo_stream- update_via_turbo_stream(- component: WorkPackages::ActivitiesTab::Journals::NewComponent.new(- work_package: @work_package- )- )- endenddiff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.tsindex 097eb712e87..aff02ebe912 100644--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts@@ -347,12 +347,19 @@ export default class IndexController extends Controller {// TODO: I wasn't able to find a pure CSS solution// Didn't want to identify on server-side which element is last in the list in order to avoid n+1 queries// happy to get rid of this hacky JS solution!- this.element.querySelectorAll('.details-container--empty--last--asc').forEach((container) => container.classList.remove('details-container--empty--last--asc'));-- const containers = this.element.querySelectorAll('.details-container--empty--asc');- if (containers.length > 0) {- const lastContainer = containers[containers.length - 1] as HTMLElement;- lastContainer.classList.add('details-container--empty--last--asc');- }+ //+ // Note: below works but not if filter is changed, skipping for now+ //+ // this.element.querySelectorAll('.details-container--empty--last--asc').forEach((container) => container.classList.remove('details-container--empty--last--asc'));++ // const containers = this.element.querySelectorAll('.details-container--empty--asc');+ // if (containers.length > 0) {+ // const lastContainer = containers[containers.length - 1] as HTMLElement;+ // // only apply for stem part after comment box+ // if (lastContainer?.parentElement?.parentElement?.previousElementSibling?.classList.contains('comment-border-box')) {+ // lastContainer.classList.add('details-container--empty--last--asc');+ // }+ // // lastContainer.classList.add('details-container--empty--last--asc');+ // }}}