-
Notifications
You must be signed in to change notification settings - Fork 437
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to mark multiple notifications as read/unread
When dealing with a big amount of notifications, it is very time consuming to mark them one by one. Therefore a way to update multiple notifications at once is required. Co-authored-by: Eduardo Navarro <enavarro@suse.com>
- Loading branch information
1 parent
d1f2cdd
commit 0004b34
Showing
9 changed files
with
139 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function setSelectAllCheckbox() { | ||
$('#select-all-notifications').change(function() { | ||
var checkboxes = $(this).closest('form').find('input[type=checkbox]'); | ||
checkboxes.prop('checked', $(this).is(':checked')); | ||
}); | ||
} | ||
|
||
function setCheckboxCounterAndSubmitButton() { | ||
var amountBoxesChecked = 0; | ||
$("input[id^='notification_ids_']").each(function() { | ||
if($(this).is(':checked')){ | ||
amountBoxesChecked += 1; | ||
} | ||
}); | ||
|
||
if(amountBoxesChecked <= 0) { | ||
$('#done-button').addClass('disabled'); | ||
$('#select-all-label').text('Select all'); | ||
} else { | ||
$('#done-button').removeClass('disabled'); | ||
$('#select-all-label').text(amountBoxesChecked + ' selected'); | ||
} | ||
} | ||
|
||
function handleNotificationCheckboxSelection() { // jshint ignore:line | ||
setCheckboxCounterAndSubmitButton(); | ||
setSelectAllCheckbox(); | ||
$('input[type="checkbox"]').change(function() { | ||
setCheckboxCounterAndSubmitButton(); | ||
}); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
class NotificationPolicy < ApplicationPolicy | ||
def update? | ||
return true if record.subscriber_type == 'User' && record.subscriber_id == user.id | ||
return true if record.subscriber_type == 'Group' && record.subscriber_id.include?(user.groups.ids) | ||
class Scope < Scope | ||
def resolve | ||
NotificationsFinder.new(scope).for_subscribed_user(user) | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
src/api/app/views/webui/users/notifications/_notification_action_bar.html.haml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.card.sticky-top#notification-action-bar | ||
.card-body.py-3 | ||
.row.px-0.px-md-1 | ||
.col | ||
.custom-control.custom-checkbox | ||
= check_box_tag('select-all-notifications', 1, false, class: 'custom-control-input') | ||
%label.custom-control-label.align-middle.mr-4#select-all-label{ for: 'select-all-notifications' } Select All | ||
- button_text = type == 'read' ? "Mark as 'Unread'" : "Mark as 'Read'" | ||
= button_tag(type: 'submit', class: 'btn btn-sm btn-outline-success px-3 disabled', id: 'done-button') do | ||
= button_text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters