-
Notifications
You must be signed in to change notification settings - Fork 17
IBX-10609: Enhance notification deletion by integrating modal confirmation. #1736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
RopRaptor
wants to merge
4
commits into
4.6
Choose a base branch
from
IBX-10609-delete-modal-in-notification
base: 4.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+44
−29
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
075e553
IBX-10609: Enhance notification deletion by integrating modal confirm…
RopRaptor f600deb
IBX-10609: Enhance notification deletion by integrating modal confirm…
RopRaptor 05537bf
Merge remote-tracking branch 'origin/IBX-10609-delete-modal-in-notifi…
RopRaptor 71ed035
ran " composer run phpstan -- --generate-baseline" to fix the failing…
RopRaptor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,7 +1,10 @@ | ||
| import { controlZIndex } from './helpers/modal.helper'; | ||
|
|
||
| (function (global, doc, ibexa, Translator, Routing) { | ||
| let currentPageLink = null; | ||
| let getNotificationsStatusErrorShowed = false; | ||
| let lastFailedCountFetchNotificationNode = null; | ||
| let selectedNotificationId = null; | ||
| const SELECTOR_MODAL_ITEM = '.ibexa-notifications-modal__item'; | ||
| const SELECTOR_MODAL_RESULTS = '.ibexa-notifications-modal__results .ibexa-scrollable-wrapper'; | ||
| const SELECTOR_MODAL_TITLE = '.ibexa-side-panel__header'; | ||
|
|
@@ -214,9 +217,8 @@ | |
|
|
||
| currentTarget.textContent.trim() === markAsReadLabel ? markAsRead({ currentTarget }) : markAsUnread({ currentTarget }); | ||
| }; | ||
| const deleteNotification = ({ currentTarget }) => { | ||
| const { notificationId } = currentTarget.dataset; | ||
| const deleteLink = Routing.generate('ibexa.notifications.delete', { notificationId }); | ||
| const deleteNotification = () => { | ||
| const deleteLink = Routing.generate('ibexa.notifications.delete', { notificationId: selectedNotificationId }); | ||
| const message = Translator.trans( | ||
| /* @Desc("Cannot delete notification") */ 'notifications.modal.message.error.delete', | ||
| {}, | ||
|
|
@@ -227,11 +229,10 @@ | |
| .then(getJsonFromResponse) | ||
| .then((response) => { | ||
| if (response.status === 'success') { | ||
| const notification = doc.querySelector(`.ibexa-notifications-modal__item[data-notification-id="${notificationId}"]`); | ||
| const menuBranch = currentTarget.closest('.ibexa-multilevel-popup-menu__branch'); | ||
| const menuInstance = ibexa.helpers.objectInstances.getInstance(menuBranch.menuInstanceElement); | ||
| const notification = doc.querySelector( | ||
| `.ibexa-notifications-modal__item[data-notification-id="${selectedNotificationId}"]`, | ||
| ); | ||
|
|
||
| menuInstance.closeMenu(); | ||
| notification.remove(); | ||
| getNotificationsStatus(); | ||
| } else { | ||
|
|
@@ -245,15 +246,26 @@ | |
| const attachActionsListeners = () => { | ||
| const attachListener = (node, callback) => node.addEventListener('click', callback, false); | ||
| const markAsButtons = doc.querySelectorAll('.ibexa-notifications-modal--mark-as'); | ||
| const deleteButtons = doc.querySelectorAll('.ibexa-notifications-modal--delete'); | ||
| const deleteButtons = doc.querySelectorAll('.ibexa-notifications-open-modal-button'); | ||
| const confirmDeleteButton = doc.querySelector('.ibexa-notifications-modal--delete--confirm'); | ||
| const setNotificationId = ({ currentTarget }) => { | ||
| const deleteModal = doc.querySelector('.modal-backdrop.show.fade'); | ||
| controlZIndex(deleteModal, '199'); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not very satisfied with this solution. Opened for suggestions |
||
|
|
||
| selectedNotificationId = currentTarget.dataset.notificationId; | ||
| }; | ||
|
|
||
| markAsButtons.forEach((markAsButton) => { | ||
| attachListener(markAsButton, handleMarkAsAction); | ||
| }); | ||
|
|
||
| deleteButtons.forEach((deleteButton) => { | ||
| attachListener(deleteButton, deleteNotification); | ||
| attachListener(deleteButton, setNotificationId); | ||
| }); | ||
|
|
||
| if (confirmDeleteButton) { | ||
| confirmDeleteButton.addEventListener('click', deleteNotification); | ||
| } | ||
| }; | ||
| const showNotificationPage = (pageHtml) => { | ||
| const modalResults = panel.querySelector(SELECTOR_MODAL_RESULTS); | ||
|
|
||
3 changes: 2 additions & 1 deletion
3
src/bundle/Resources/public/js/scripts/helpers/modal.helper.js
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick - naming convention