Skip to content

Commit 0353234

Browse files
committed
Mark multiple as read & notification list view expansion
1 parent 1d23083 commit 0353234

File tree

8 files changed

+64
-52
lines changed

8 files changed

+64
-52
lines changed

src/bundle/Resources/config/routing.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,11 @@ ibexa.notifications.mark_as_read:
939939

940940
ibexa.notifications.mark_multiple_as_read:
941941
path: /notifications/read
942+
options:
943+
expose: true
942944
defaults:
943945
_controller: 'Ibexa\Bundle\AdminUi\Controller\NotificationController::markNotificationsAsReadAction'
944-
methods: [ POST ]
946+
methods: [POST]
945947

946948
ibexa.notifications.mark_all_as_read:
947949
path: /notifications/read-all

src/bundle/Resources/public/js/scripts/admin.notifications.list.js

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,52 +29,41 @@
2929
});
3030
};
3131

32-
//TODO:
3332
const markSelectedAsRead = () => {
34-
const checkedElements = doc.querySelectorAll('.ibexa-notification-list__mark-row-checkbox:checked');
35-
const notificationIds = [...checkedElements].map((element) => element.dataset.notificationId);
36-
const bulkOperations = getBulkOperations(notificationIds);
37-
const request = new Request('/api/ibexa/v2/bulk', {
33+
const selectedNotifications = [...checkboxes]
34+
.filter((checkbox) => checkbox.checked)
35+
.map((checkbox) => checkbox.dataset.notificationId);
36+
37+
const markAsReadLink = Routing.generate('ibexa.notifications.mark_multiple_as_read');
38+
const request = new Request(markAsReadLink, {
3839
method: 'POST',
3940
headers: {
40-
Accept: 'application/vnd.ibexa.api.BulkOperationResponse+json',
41-
'Content-Type': 'application/vnd.ibexa.api.BulkOperation+json',
41+
'Content-Type': 'application/json',
4242
},
43+
mode: 'same-origin',
44+
credentials: 'same-origin',
4345
body: JSON.stringify({
44-
bulkOperations: {
45-
operations: bulkOperations,
46-
},
46+
ids: selectedNotifications,
4747
}),
48-
mode: 'same-origin',
49-
credentials: 'include',
5048
});
51-
const errorMessage = Translator.trans(
52-
/*@Desc("Cannot mark selected notifications as read")*/ 'notifications.modal.message.error.mark_selected_as_read',
53-
{},
54-
'ibexa_notifications',
55-
);
5649

5750
fetch(request)
5851
.then(getJsonFromResponse)
59-
.catch(() => ibexa.helpers.notification.showErrorNotification(errorMessage));
52+
.then((response) => {
53+
if (response.status === 'success') {
54+
global.location.reload();
55+
}
56+
})
57+
.catch(() => {
58+
const message = Translator.trans(
59+
/* @Desc("Cannot mark notifications as read") */
60+
'notifications.modal.message.error.mark_as_read',
61+
{},
62+
'ibexa_notifications',
63+
);
64+
showErrorNotification(message);
65+
});
6066
};
61-
const getBulkOperations = (notificationIds) =>
62-
notificationIds.reduce((total, notificationId) => {
63-
const markAsReadLink = Routing.generate('ibexa.notifications.mark_as_read', { notificationId });
64-
65-
total[markAsReadLink] = {
66-
uri: markAsReadLink,
67-
method: 'GET',
68-
mode: 'same-origin',
69-
headers: {
70-
Accept: 'application/vnd.ibexa.api.ContentType+json',
71-
'X-Requested-With': 'XMLHttpRequest',
72-
},
73-
credentials: 'same-origin',
74-
};
75-
76-
return total;
77-
}, {});
7867

7968
const handleNotificationClick = (notification, isToggle = false) => {
8069
const notificationRow = notification.closest('.ibexa-table__row');
@@ -169,11 +158,15 @@
169158
);
170159
};
171160
const handleCheckboxChange = (checkbox) => {
172-
const checkboxFormId = checkbox.dataset?.formRemoveId;
173-
const formRemoveCheckbox = doc.getElementById(checkboxFormId);
161+
const checkboxFormId = checkbox.dataset?.formCheckboxId;
162+
const formRemoveCheckbox = doc.querySelector(
163+
`[data-toggle-button-id="#confirm-notification_selection_remove"] input#${checkboxFormId}`,
164+
);
165+
174166
if (formRemoveCheckbox) {
175167
formRemoveCheckbox.checked = checkbox.checked;
176168
}
169+
177170
toggleActionButtonState();
178171
};
179172

src/bundle/Resources/public/js/scripts/admin.notifications.modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
};
9090
const updateModalTitleTotalInfo = (notificationsCount) => {
9191
const modalTitle = panel.querySelector(SELECTOR_MODAL_TITLE);
92-
const modalFooter = panel.querySelector('.ibexa-notifications__view-all-btn--count');
92+
const modalFooter = panel.querySelector('.ibexa-notifications-modal__view-all-btn--count');
9393
modalFooter.textContent = ` (${notificationsCount})`;
9494
modalTitle.dataset.notificationsTotal = `(${notificationsCount})`;
9595

src/bundle/Resources/public/scss/_notifications-modal.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,12 @@
5555
&__item {
5656
position: relative;
5757
border: 1px solid $ibexa-color-light;
58-
border-bottom: none;
58+
border-top: none;
5959

6060
&--wrapper {
6161
display: flex;
6262
}
6363

64-
&:first-of-type {
65-
border-top: none;
66-
}
67-
6864
.description__text {
6965
font-size: $ibexa-text-font-size-medium;
7066

@@ -93,6 +89,12 @@
9389
color: $ibexa-color-white;
9490
}
9591

92+
&__view-all-btn {
93+
&--count {
94+
padding-left: calculateRem(2px);
95+
}
96+
}
97+
9698
&__item--read {
9799
.ibexa-notifications-modal__notice-dot,
98100
.ibexa-notification-view-all__notice-dot {

src/bundle/Resources/public/scss/_notifications.scss

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,17 @@
88

99
.ibexa-notification-list {
1010
display: flex;
11-
align-items: strech;
11+
align-items: stretch;
1212
margin-bottom: calculateRem(48px);
1313

14+
&__container {
15+
.container.container {
16+
@media (min-width: 1200px) {
17+
max-width: calculateRem(2000px);
18+
}
19+
}
20+
}
21+
1422
.ibexa-table__header-cell {
1523
padding: calculateRem(16px) calculateRem(8px);
1624
&:first-child {
@@ -20,6 +28,7 @@
2028
padding-right: calculateRem(16px);
2129
}
2230
}
31+
2332
.ibexa-table__cell {
2433
padding: calculateRem(8px);
2534
&:first-child {
@@ -29,6 +38,7 @@
2938
padding-right: calculateRem(16px);
3039
}
3140
}
41+
3242
.ibexa-container {
3343
padding: 0 calculateRem(16px) calculateRem(16px);
3444
margin-bottom: 0;
@@ -47,6 +57,7 @@
4757
}
4858

4959
&__data-grid-wrapper {
60+
width: 100%;
5061
border-radius: $ibexa-border-radius 0 0 $ibexa-border-radius;
5162
border: calculateRem(1px) solid $ibexa-color-light;
5263
border-right: none;

src/bundle/Resources/views/themes/admin/account/notifications/list_all.html.twig

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
{% form_theme form_remove '@ibexadesign/ui/form_fields.html.twig' %}
88
{% import _self as macros %}
99

10+
{% block main_container_class %}{{ parent() }} ibexa-notification-list__container {% endblock %}
11+
1012
{% block title %}{{ 'ibexa_notifications'|trans|desc('Notifications') }}{% endblock %}
1113

1214
{% block header %}
@@ -43,10 +45,10 @@
4345
}) }}
4446
{{ form_end(form_remove) }}
4547
{{ form_start(search_form, {
46-
attr: { class: 'ibexa-al-list-search-form' }
48+
attr: { class: 'ibexa-list-search-form' }
4749
}) }}
4850
<div class="ibexa-notification-list">
49-
<section class="ibexa-notification-list__data-grid-wrapper container ibexa-container">
51+
<section class="ibexa-notification-list__data-grid-wrapper ibexa-container">
5052
{% embed '@ibexadesign/ui/component/table/table.html.twig' with {
5153
headline: custom_results_headline ?? results_headline(pager.getNbResults()),
5254
head_cols: [
@@ -97,15 +99,17 @@
9799
</div>
98100
</div>
99101
{{ form_end(search_form) }}
102+
{{dump()}}
100103
{% endblock %}
101104

102105
{% block javascripts %}
103106
{{ encore_entry_script_tags('ibexa-admin-notifications-list-js', null, 'ibexa') }}
104107
{% endblock %}
105-
{% macro table_header_tools(form) %}
108+
{% macro table_header_tools(form,) %}
106109
{% set modal_data_target = 'modal-' ~ form.remove.vars.id %}
107110
<div class="ibexa-notification-list__table-btns">
108111
<button
112+
id="confirm-mark-selected-as-read"
109113
type="button"
110114
class="btn ibexa-btn ibexa-btn--ghost ibexa-notification-list__btn--mark-as-read"
111115
disabled
@@ -138,4 +142,4 @@
138142
'message': 'notifications.list.action.remove.confirmation.text'|trans|desc('Are you sure you want to permanently delete the selected notification(s)?'),
139143
'data_click': '#' ~ form.remove.vars.id,
140144
} %}
141-
{% endmacro %}
145+
{% endmacro %}

src/bundle/Resources/views/themes/admin/account/notifications/list_item_all.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
<div class="form-check">
7878
<input
7979
data-notification-id="{{ notification.id }}"
80-
data-form-remove-id="notification_remove_notifications_{{ notification.id}}"
80+
data-form-checkbox-id="notification_selection_notifications_{{ notification.id}}"
8181
type="checkbox"
8282
class="ibexa-input ibexa-input--checkbox ibexa-notification-list__mark-row-checkbox form-check-input"
8383
/>

src/bundle/Resources/views/themes/admin/account/notifications/side_panel.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434

3535
{% block footer %}
3636
<div class="ibexa-notifications-modal__footer">
37-
<a class="btn ibexa-btn ibexa-btn--ghost ibexa-notifications__view-all-btn" href="{{ path('ibexa.notifications.render.all') }}">
37+
<a class="btn ibexa-btn ibexa-btn--ghost ibexa-notifications-modal__view-all-btn" href="{{ path('ibexa.notifications.render.all') }}">
3838
{{ 'side_panel.view_all'|trans|desc('View all') }}
39-
<span class="ibexa-notifications__view-all-btn--count"></span>
39+
<span class="ibexa-notifications-modal__view-all-btn--count"></span>
4040
</a>
4141
</div>
4242
{% endblock %}

0 commit comments

Comments
 (0)