Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
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';
Expand Down Expand Up @@ -214,9 +215,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',
{},
Expand All @@ -227,11 +227,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 {
Expand All @@ -245,15 +244,23 @@
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 }) => {
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);
Expand Down
8 changes: 8 additions & 0 deletions src/bundle/Resources/public/scss/_modals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,11 @@
}
}
}

.modal-backdrop {
&.fade {
&.show {
z-index: 199;
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is the best solution?

I need to overwrite $ibexa-backdrop-zindex: 2175; from
image

with a lower index

Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,30 @@
} %}
{% block tbody %}
{% if pager.count is same as(0) %}
<div class="ibexa-notifications-modal__empty">
<img
src="{{ empty_image|default(asset('/bundles/ibexaadminui/img/ibexa-empty-table.svg')) }}"
/>
<h2 class="ibexa-notifications-modal__empty-text">{{ 'notifications.list.empty'|trans|desc('You don\'t have any notifications.') }}</h2>
</div>
<div class="ibexa-notifications-modal__empty">
<img
src="{{ empty_image|default(asset('/bundles/ibexaadminui/img/ibexa-empty-table.svg')) }}"
/>
<h2 class="ibexa-notifications-modal__empty-text">{{ 'notifications.list.empty'|trans|desc('You don\'t have any notifications.') }}</h2>
</div>
{% else %}
{% for notification in sidebarNotifications %}
{{ notification|raw }}
{% endfor %}
{% endif %}

{% embed '@ibexadesign/ui/modal/delete_confirmation.html.twig' with {
id: 'delete-notification-modal',
message: 'notification.modal.delete.confirm_message'|trans|desc('Are you sure you want to delete this notification?'),
} %}

{% trans_default_domain 'ibexa_product_catalog' %}

{% block confirm_button %}
<button class="btn ibexa-btn ibexa-btn--primary ibexa-notifications-modal--delete--confirm" data-bs-dismiss="modal">
{{ 'modal.delete'|trans|desc('Delete') }}
</button>
{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,18 @@

{% set popup_items = popup_items|merge([{
label: notification.isPending == 0 ? 'notification.mark_as_unread'|trans|desc('Mark as unread') : 'notification.mark_as_read'|trans|desc('Mark as read'),
action_attr: {
class: 'ibexa-notifications-modal--mark-as ibexa-notifications-modal--mark-as-' ~ (notification.isPending == 0 ? 'unread' : 'read'),
action_attr: {
class: 'ibexa-notifications-modal--mark-as ibexa-notifications-modal--mark-as-' ~ (notification.isPending == 0 ? 'unread' : 'read'),
'data-notification-id': notification.id },
}]) %}

{% set popup_items = popup_items|merge([{
label: 'notification.delete'|trans|desc('Delete'),
action_attr: { class: 'ibexa-notifications-modal--delete', 'data-notification-id': notification.id },
action_attr: {
class: 'ibexa-notifications-open-modal-button',
'data-notification-id': notification.id,
'data-bs-toggle': 'modal',
'data-bs-target': '#delete-notification-modal', }
}]) %}

{% embed '@ibexadesign/ui/component/table/table_body_row.html.twig' with {
Expand All @@ -71,7 +75,7 @@
<strong>{{ notification_type }}</strong>
<div class="ibexa-notifications-modal__description">{{ message }}</div>
<div class="ibexa-notifications-modal__item--date">
{{ notification.created|ibexa_short_datetime }}
{{ notification.created|ibexa_short_datetime }}
</div>
{% endblock %}
{% endembed %}
Expand Down
Loading