Skip to content

Commit

Permalink
Merge pull request #10184 from eduardoj/fix_10173_notifications_prese…
Browse files Browse the repository at this point in the history
…rve_pagination

Marking a notification as read: couple of fixes
  • Loading branch information
dmarcoux committed Sep 21, 2020
2 parents 72ec942 + e0adca5 commit 993e9c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Expand Up @@ -79,7 +79,8 @@ def fetch_notifications
else
NotificationsFinder.new(notifications_for_subscribed_user).for_notifiable_type(params[:type])
end
params['show_all'] ? show_all(notifications) : notifications.page(params[:page])
params[:page] = notifications.page(params[:page]).total_pages if notifications.page(params[:page]).out_of_range?
params[:show_all] ? show_all(notifications) : notifications.page(params[:page])
end

def notifications_filter
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/helpers/webui/notification_helper.rb
@@ -1,6 +1,6 @@
module Webui::NotificationHelper
def link_to_all
parameters = params.slice(:show_all, :type, :project, :page).permit!
parameters = params.slice(:show_all, :type, :project).permit!
all_or_less = parameters[:show_all] ? 'less' : 'all'
parameters[:show_all] = parameters[:show_all] ? nil : '1'
link_to("Show #{all_or_less}", my_notifications_path(parameters), class: 'btn btn-sm btn-secondary ml-2')
Expand Down
Expand Up @@ -12,7 +12,7 @@
- else
.text-center
%span.ml-3= page_entries_info notifications, entry_name: 'notification'
= link_to_all unless notifications.total_pages == 1 && params['show_all'].nil?
= link_to_all unless notifications.total_pages == 1 && params[:show_all].nil?

.list-group.list-group-flush.mt-3
- notifications.each do |n|
Expand All @@ -29,7 +29,8 @@
= link_to(notification.notifiable_link[:text], notification.notifiable_link[:path], class: 'mx-1 text-word-break-all')
.actions.ml-auto.align-self-end.align-self-md-start
- title, icon = notification.unread? ? ['Mark as "Read"', 'fa-check'] : ['Mark as "Unread"', 'fa-undo']
- update_path = my_notification_path(id: notification, type: selected_filter[:type], project: selected_filter[:project])
- update_path = my_notification_path(id: notification, type: selected_filter[:type], project: selected_filter[:project],
page: params[:page], show_all: params[:show_all])
= link_to(update_path, id: format('update-notification-%d', notification.id),
method: :put, class: 'btn btn-sm btn-outline-success px-3', title: title, remote: true) do
%i.fas{ class: "#{icon}" }
Expand Down

0 comments on commit 993e9c1

Please sign in to comment.