diff --git a/app/controllers/access_controller.rb b/app/controllers/access_controller.rb index 6f3518d5..5b6dea6e 100644 --- a/app/controllers/access_controller.rb +++ b/app/controllers/access_controller.rb @@ -38,7 +38,9 @@ class AccessController < ApplicationController # who we then send an email to user = User.find(user_id) mail = MapMailer.invite_to_edit_email(@map, current_user, user) - user.notify(mail.subject, 'invite to edit', UserMap.find_by(user: user, map: @map), true, MAILBOXER_CODE_INVITED_TO_EDIT) + user.notify(mail.subject, 'invite to edit', + UserMap.find_by(user: user, map: @map), + true, MAILBOXER_CODE_INVITED_TO_EDIT) end @map.remove_old_collaborators(user_ids) diff --git a/app/controllers/notifications_controller.rb b/app/controllers/notifications_controller.rb index 4759ef20..16049fc0 100644 --- a/app/controllers/notifications_controller.rb +++ b/app/controllers/notifications_controller.rb @@ -5,7 +5,7 @@ class NotificationsController < ApplicationController before_action :set_receipt, only: [:show, :mark_read, :mark_unread] def index - @notifications = current_user.mailbox.notifications + @notifications = current_user.mailbox.notifications.page(params[:page]).per(25) respond_to do |format| format.html diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 6b771d6f..1defb323 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -95,6 +95,8 @@ class UsersController < ApplicationController private def user_params - params.require(:user).permit(:name, :email, :image, :password, :password_confirmation, :emails_allowed) + params.require(:user).permit( + :name, :email, :image, :password, :password_confirmation, :emails_allowed + ) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 45a5d565..96b5a2b2 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -40,7 +40,7 @@ module ApplicationHelper def user_unread_notification_count return 0 if current_user.nil? - @user_unread_notification_count ||= current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt| + @uunc ||= current_user.mailboxer_notification_receipts.reduce(0) do |total, receipt| receipt.is_read ? total : total + 1 end end diff --git a/app/models/access_request.rb b/app/models/access_request.rb index d062ab79..c433f7cc 100644 --- a/app/models/access_request.rb +++ b/app/models/access_request.rb @@ -7,10 +7,10 @@ class AccessRequest < ApplicationRecord self.answered = true self.save - Mailboxer::Notification.where(notified_object: self).each do |notification| + Mailboxer::Notification.where(notified_object: self).find_each do |notification| Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) end - + user_map = UserMap.create(user: user, map: map) mail = MapMailer.invite_to_edit_email(map, map.user, user) user.notify(mail.subject, 'invite to edit', user_map, true, MAILBOXER_CODE_INVITED_TO_EDIT) @@ -21,7 +21,7 @@ class AccessRequest < ApplicationRecord self.answered = true self.save - Mailboxer::Notification.where(notified_object: self).each do |notification| + Mailboxer::Notification.where(notified_object: self).find_each do |notification| Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) end end diff --git a/app/models/user_map.rb b/app/models/user_map.rb index 3aa87b03..c1cdc58e 100644 --- a/app/models/user_map.rb +++ b/app/models/user_map.rb @@ -4,7 +4,7 @@ class UserMap < ApplicationRecord belongs_to :user def mark_invite_notifications_as_read - Mailboxer::Notification.where(notified_object: self).each do |notification| + Mailboxer::Notification.where(notified_object: self).find_each do |notification| Mailboxer::Receipt.where(notification: notification).update_all(is_read: true) end end diff --git a/app/views/notifications/index.html.erb b/app/views/notifications/index.html.erb index bd8022e5..e030e483 100644 --- a/app/views/notifications/index.html.erb +++ b/app/views/notifications/index.html.erb @@ -30,6 +30,13 @@ <% end %> + + <% if @notifications.total_pages > 1 %> + + <% end %> + <%= render partial: 'shared/back_to_mapping' %> diff --git a/frontend/src/Metamaps/GlobalUI/NotificationIcon.js b/frontend/src/Metamaps/GlobalUI/NotificationIcon.js index 2f13adba..1e9ff3bd 100644 --- a/frontend/src/Metamaps/GlobalUI/NotificationIcon.js +++ b/frontend/src/Metamaps/GlobalUI/NotificationIcon.js @@ -8,7 +8,7 @@ import NotificationIconComponent from '../../components/NotificationIcon' const NotificationIcon = { unreadNotificationsCount: null, - + init: function(serverData) { const self = NotificationIcon self.unreadNotificationsCount = serverData.unreadNotificationsCount @@ -18,7 +18,7 @@ const NotificationIcon = { if (newUnreadCount !== null) { NotificationIcon.unreadNotificationsCount = newUnreadCount } - + if (Active.Mapper !== null) { ReactDOM.render(React.createElement(NotificationIconComponent, { unreadNotificationsCount: NotificationIcon.unreadNotificationsCount @@ -27,4 +27,4 @@ const NotificationIcon = { } } -export default NotificationIcon \ No newline at end of file +export default NotificationIcon diff --git a/frontend/src/components/NotificationIcon.js b/frontend/src/components/NotificationIcon.js index 98782a75..5a1e820f 100644 --- a/frontend/src/components/NotificationIcon.js +++ b/frontend/src/components/NotificationIcon.js @@ -9,14 +9,14 @@ class NotificationIcon extends Component { } render = () => { - var linkClasses = "notificationsIcon upperRightEl upperRightIcon " - + let linkClasses = 'notificationsIcon upperRightEl upperRightIcon ' + if (this.props.unreadNotificationsCount > 0) { - linkClasses += "unread" + linkClasses += 'unread' } else { - linkClasses += "read" + linkClasses += 'read' } - + return (
@@ -26,8 +26,7 @@ class NotificationIcon extends Component {
)}
- - + ) } }