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
Move mark all as read to backend
Oliver Günther3619bcab130e
diff --git a/app/components/notifications/index_page_header_component.html.erb b/app/components/notifications/index_page_header_component.html.erbindex a62c00710c1..55a36394b15 100644--- a/app/components/notifications/index_page_header_component.html.erb+++ b/app/components/notifications/index_page_header_component.html.erb@@ -18,7 +18,8 @@header.with_action_button(tag: :a,mobile_icon: :'op-read-all',mobile_label: I18n.t("js.notifications.center.mark_all_read"),- href: notifications_path,+ href: mark_all_read_notifications_path({ filter: @filter_type, name: @filter_name }.compact),+ data: { method: :post },size: :medium,aria: { label: I18n.t("js.notifications.center.mark_all_read") }) do |button|button.with_leading_visual_icon(icon: :'op-read-all')diff --git a/app/components/notifications/index_page_header_component.rb b/app/components/notifications/index_page_header_component.rbindex 334def67af7..c21893380b1 100644--- a/app/components/notifications/index_page_header_component.rb+++ b/app/components/notifications/index_page_header_component.rb@@ -32,12 +32,14 @@ module Notificationsclass IndexPageHeaderComponent < ApplicationComponentinclude ApplicationHelper- attr_reader :facet+ attr_reader :facet, :filter_type, :filter_name- def initialize(project: nil, facet: nil)+ def initialize(project: nil, facet: nil, filter_type: nil, filter_name: nil)super@project = project@facet = facet+ @filter_type = filter_type+ @filter_name = filter_nameenddef page_titlediff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rbindex a5c02f9c920..27862273f08 100644--- a/app/controllers/notifications_controller.rb+++ b/app/controllers/notifications_controller.rb@@ -28,11 +28,39 @@class NotificationsController < ApplicationControllerbefore_action :require_login- no_authorization_required! :index+ before_action :filtered_query, only: :mark_all_read+ no_authorization_required! :index, :mark_all_readdef index# Frontend will handle rendering# but we will need to render with notification specific layoutrender layout: "angular/notifications"end++ def mark_all_read+ if filtered_query.valid?+ filtered_query.results.update_all(read_ian: true, updated_at: Time.zone.now)+ else+ flash[:error] = filtered_query.errors.full_messages.join(", ")+ end++ redirect_back fallback_location: notifications_path+ end++ private++ def filtered_query+ query = Queries::Notifications::NotificationQuery.new(user: current_user)+ query.where(:read_ian, "=", "f")++ case params[:filter]+ when "project"+ id = params[:name].to_i+ query.where(:project, "=", [id])+ when "reason"+ query.where(:reason, "=", [params[:name]])+ end++ @filtered_query = query+ endenddiff --git a/app/helpers/mail_notification_helper.rb b/app/helpers/mail_notification_helper.rbindex 6adcbea006e..4861127d90f 100644--- a/app/helpers/mail_notification_helper.rb+++ b/app/helpers/mail_notification_helper.rb@@ -36,7 +36,7 @@ module MailNotificationHelperenddef notifications_path(id)- notifications_center_url(["details", id, "activity"])+ details_notifications_path(id)enddef type_color(type, default_fallback)diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erbindex de32f527398..0ac45abbc7e 100644--- a/app/views/notifications/index.html.erb+++ b/app/views/notifications/index.html.erb@@ -1,4 +1,8 @@<% html_title t("js.notifications.title") %>-<%= render(Notifications::IndexPageHeaderComponent.new(facet: params[:facet])) %>+<%= render(Notifications::IndexPageHeaderComponent.new(+ facet: params[:facet],+ filter_name: params[:name],+ filter_type: params[:filter]+)) %><%= angular_component_tag "opce-notification-center" %>diff --git a/config/locales/js-en.yml b/config/locales/js-en.ymlindex f661fc015bf..368692d6721 100644--- a/config/locales/js-en.yml+++ b/config/locales/js-en.yml@@ -713,7 +713,7 @@ en:empty_state:no_notification: "Looks like you are all caught up."no_notification_with_current_project_filter: "Looks like you are all caught up with the selected project."- no_notification_with_current_filter: "Looks like you are all caught up for %{filter} filter."+ no_notification_with_current_filter: "Looks like you are all caught up for this filter."no_selection: "Click on a notification to view all activity details."new_notifications:message: "There are new notifications."diff --git a/config/routes.rb b/config/routes.rbindex 18e058eb23a..efa4c5ae5bd 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -700,13 +700,14 @@ Rails.application.routes.draw doroot to: "account#login"concern :with_split_view do |options|- get "details/:id(/:tab)", on: :collection, action: options.fetch(:action, :index)+ get "details/:id(/:tab)", on: :collection, action: options.fetch(:action, :index), as: :detailsendresources :notifications, only: :index doconcerns :with_split_viewcollection do+ post :mark_all_readresource :menu, module: :notifications, only: %i[show], as: :notifications_menuendenddiff --git a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.tsindex 40cc9cd5ca8..054dd5f2c12 100644--- a/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts+++ b/frontend/src/app/features/in-app-notifications/center/in-app-notification-center.component.ts@@ -114,7 +114,7 @@ export class InAppNotificationCenterComponent implements OnInit {text = {no_notification: this.I18n.t('js.notifications.center.empty_state.no_notification'),no_notification_with_current_filter_project: this.I18n.t('js.notifications.center.empty_state.no_notification_with_current_project_filter'),- no_notification_with_current_filter: this.I18n.t('js.notifications.center.empty_state.no_notification_with_current_filter', { filter: this.selectedFilter }),+ no_notification_with_current_filter: this.I18n.t('js.notifications.center.empty_state.no_notification_with_current_filter'),no_selection: this.I18n.t('js.notifications.center.empty_state.no_selection'),change_notification_settings: this.I18n.t('js.notifications.settings.change_notification_settings',@@ -157,6 +157,11 @@ export class InAppNotificationCenterComponent implements OnInit {if (!hasNotifications) {return this.text.no_notification;}- return (this.urlParams.get('filter') ? this.text.no_notification_with_current_filter_project : this.text.no_notification_with_current_filter);++ if (this.urlParams.get('filter') === 'project') {+ return this.text.no_notification_with_current_filter_project;+ }++ return this.text.no_notification_with_current_filter;}}diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.tsindex 7eea38d17f5..4b46ac6528c 100644--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts@@ -261,17 +261,6 @@ export class IanCenterService extends UntilDestroyedMixin {);}- markAllAsRead():void {- const filters = this.params.filters;- if (filters === undefined) {- return;- }-- this.actions$.dispatch(- markNotificationsAsReadByFilters({ origin: this.id, filters }),- );- }-// eslint-disable-next-line @typescript-eslint/no-inferrable-typesopenSplitScreen(workPackageId:string|null, tabIdentifier:string = 'activity'):void {void this.state.go(