mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-27 10:08:11 +08:00
added html_safe to outputed message, hide notifications number when dropdown is toggled, clear all unseen notification form count when the dropdown is toggled, generate notification only to other users
This commit is contained in:
parent
1aa09a2ce2
commit
c9bbab1004
6 changed files with 11 additions and 17 deletions
|
@ -31,6 +31,7 @@
|
|||
animateSpinner($('.notifications-dropdown-header'), false);
|
||||
}
|
||||
});
|
||||
$('#count-notifications').hide();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ class UserNotificationsController < ApplicationController
|
|||
}
|
||||
end
|
||||
end
|
||||
mark_seen_notification @recent_notifications
|
||||
UserNotification.seen_by_user(current_user)
|
||||
end
|
||||
|
||||
def unseen_notification
|
||||
|
@ -25,12 +25,4 @@ class UserNotificationsController < ApplicationController
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def mark_seen_notification(notifications)
|
||||
notifications.each do |notification|
|
||||
notification.seen_by_user(current_user)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,6 +74,7 @@ class Activity < ActiveRecord::Base
|
|||
)
|
||||
|
||||
project.users.each do |project_user|
|
||||
next if project_user == user
|
||||
UserNotification.create(notification: notification, user: project_user)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,11 +10,4 @@ class Notification < ActiveRecord::Base
|
|||
.pluck(:checked)
|
||||
.first
|
||||
end
|
||||
|
||||
def seen_by_user(user)
|
||||
user_notification = UserNotification.where(notification: self, user: user)
|
||||
.first
|
||||
user_notification.checked = true
|
||||
user_notification.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,4 +12,11 @@ class UserNotification < ActiveRecord::Base
|
|||
def self.unseen_notification_count(user)
|
||||
where('user_id = ? AND checked = false', user.id).count
|
||||
end
|
||||
|
||||
def self.seen_by_user(user)
|
||||
where(user: user).map do |n|
|
||||
n.checked = true
|
||||
n.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
|
||||
<div class="col-xs-10">
|
||||
<strong><%= notification.title %></strong> <br>
|
||||
<strong><%= notification.title.html_safe %></strong> <br>
|
||||
<%= l(notification.created_at, format: :full) %> | <%= notification.message %>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue