Skip to content

Commit eede822

Browse files
committed
Trash notification fixes & display filter validation
1 parent 2f46e6e commit eede822

File tree

9 files changed

+42
-53
lines changed

9 files changed

+42
-53
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
deleteBtn.disabled = !isAnythingSelected;
168168
markAsReadBtn.disabled =
169169
!isAnythingSelected ||
170-
!checkedNotifications.every(
170+
!checkedNotifications.some(
171171
(checkbox) =>
172172
checkbox.closest('.ibexa-table__row').querySelector('.ibexa-notification-view-all__notice-dot').dataset.isRead ===
173173
'false',

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

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,15 @@
55
const SELECTOR_MODAL_ITEM = '.ibexa-notifications-modal__item';
66
const SELECTOR_MODAL_RESULTS = '.ibexa-notifications-modal__results .ibexa-scrollable-wrapper';
77
const SELECTOR_MODAL_TITLE = '.ibexa-side-panel__header';
8-
const SELECTOR_DESC_TEXT = '.description__text';
98
const SELECTOR_LIST = '.ibexa-list--notifications';
10-
const CLASS_ELLIPSIS = 'description__text--ellipsis';
11-
const CLASS_PAGINATION_LINK = 'page-link';
129
const CLASS_MODAL_LOADING = 'ibexa-notifications-modal--loading';
1310
const INTERVAL = 30000;
1411
const panel = doc.querySelector('.ibexa-notifications-modal');
1512
const { showErrorNotification, showWarningNotification } = ibexa.helpers.notification;
1613
const { getJsonFromResponse, getTextFromResponse } = ibexa.helpers.request;
1714
const handleNotificationClickRequest = (notification, response) => {
18-
if (response.status === 'success') {
15+
if (response.status === 'success' && response.redirect) {
1916
notification.classList.add('ibexa-notifications-modal__item--read');
20-
}
21-
22-
if (response.redirect) {
2317
global.location = response.redirect;
2418
}
2519
};
@@ -32,21 +26,6 @@
3226

3327
fetch(request).then(getJsonFromResponse).then(handleNotificationClickRequest.bind(null, notification)).catch(showErrorNotification);
3428
};
35-
const handleTableClick = (event) => {
36-
if (event.target.classList.contains('description__read-more')) {
37-
event.target.closest(SELECTOR_MODAL_ITEM).querySelector(SELECTOR_DESC_TEXT).classList.remove(CLASS_ELLIPSIS);
38-
39-
return;
40-
}
41-
42-
const notification = event.target.closest(SELECTOR_MODAL_ITEM);
43-
44-
if (!notification) {
45-
return;
46-
}
47-
48-
handleNotificationClick(notification);
49-
};
5029

5130
const getNotificationsStatus = () => {
5231
const notificationsTable = panel.querySelector(SELECTOR_LIST);
@@ -249,6 +228,7 @@
249228

250229
menuInstance.closeMenu();
251230
notification.remove();
231+
getNotificationsStatus();
252232
} else {
253233
showErrorNotification(message);
254234
}
@@ -305,27 +285,14 @@
305285
fetch(request).then(getTextFromResponse).then(showNotificationPage).catch(showErrorNotification);
306286
};
307287
const handleModalResultsClick = (event) => {
308-
const isPaginationBtn = event.target.classList.contains(CLASS_PAGINATION_LINK);
309288
const isActionBtn = event.target.closest('.ibexa-notifications-modal__actions');
289+
const notification = event.target.closest(SELECTOR_MODAL_ITEM);
310290

311-
if (isActionBtn) {
312-
return;
313-
}
314-
315-
if (isPaginationBtn) {
316-
handleNotificationsPageChange(event);
317-
291+
if (isActionBtn || !notification) {
318292
return;
319293
}
320294

321-
handleTableClick(event);
322-
};
323-
const handleNotificationsPageChange = (event) => {
324-
event.preventDefault();
325-
326-
const notificationsPageLink = event.target.href;
327-
328-
fetchNotificationPage(notificationsPageLink);
295+
handleNotificationClick(notification);
329296
};
330297

331298
if (!panel) {

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
&__type-content {
5959
width: 100%;
6060
font-size: $ibexa-text-font-size-medium;
61+
cursor: default;
6162

6263
p {
6364
margin-bottom: 0;
@@ -130,7 +131,7 @@
130131
.description__text {
131132
width: 100%;
132133
margin-bottom: 0;
133-
max-width: 50ch;
134+
max-width: calculateRem(350px);
134135
float: left;
135136

136137
+ .description__read-more {
@@ -247,21 +248,21 @@
247248
max-width: 100%;
248249
overflow: hidden;
249250

250-
.type__text {
251-
white-space: nowrap;
251+
.type__text,
252+
.description__title {
253+
flex-shrink: 0;
252254
}
253-
254255
.ibexa-notifications-modal__description {
255256
display: flex;
256257
max-width: 100%;
257258
}
258-
259259
.description__text {
260260
flex: 1;
261261
min-width: 0;
262262
white-space: nowrap;
263263
overflow: hidden;
264264
text-overflow: ellipsis;
265+
max-width: 25vw;
265266
}
266267
}
267268

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
}
5858

5959
&__filters-wrapper {
60-
width: calculateRem(360px);
60+
width: calculateRem(400px);
6161
border-radius: 0 $ibexa-border-radius $ibexa-border-radius 0;
6262
border: calculateRem(1px) solid $ibexa-color-light;
6363
background-color: $ibexa-color-white;

src/bundle/Resources/translations/ibexa_notifications.en.xliff

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,11 @@
136136
<target state="new">Sent to Trash</target>
137137
<note>key: notification.trashed</note>
138138
</trans-unit>
139+
<trans-unit id="d643e1117bad8f0bac7d8b158f54e2109ea1f482" resname="notification.trashed.info">
140+
<source>moved to Trash</source>
141+
<target state="new">moved to Trash</target>
142+
<note>key: notification.trashed.info</note>
143+
</trans-unit>
139144
<trans-unit id="f5bf4310647081193250ff28773cf5f4880a0fe2" resname="notification.unread">
140145
<source>Unread</source>
141146
<target state="new">Unread</target>

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
'data-seconds': 0,
4343
}
4444
}) }}
45+
<div class="ibexa-form-error">
46+
{{ form_errors(form.children.min) }}
47+
</div>
4548
</div>
4649

4750
<div class="form-group">
@@ -53,6 +56,9 @@
5356
'data-seconds': 0,
5457
}
5558
}) }}
59+
<div class="ibexa-form-error">
60+
{{ form_errors(form.children.max) }}
61+
</div>
5662
</div>
5763
{% endblock %}
5864
{% endembed %}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
{% embed '@ibexadesign/ui/component/table/table_body_cell.html.twig' with { class: 'ibexa-notifications-modal__type-content' } %}
6969
{% block content %}
7070
<strong>{{ notification_type }}</strong>
71-
{{ message }}
71+
<div class="ibexa-notifications-modal__description">{{ message }}</div>
7272
<div class="ibexa-notifications-modal__item--date">
7373
{{ notification.created|ibexa_short_datetime }}
7474
</div>

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
{% endblock %}
2525

2626
{% block message %}
27-
{% block content %}
28-
<p class="description__title">
29-
{{ 'notification.title'|trans|desc('Title:') }}
30-
<span class="description__title-item"><strong>{{ title }}</strong></span>
31-
</p>
32-
<p class="description__text description__text--permanently-deleted">{{ 'notification.no_longer_available'|trans({}, 'ibexa_notifications')|desc('The Content item is no longer available')}}</p>
33-
{% endblock %}
27+
{% block content %}
28+
<p class="description__title">
29+
{{ 'notification.title'|trans|desc('Title:') }}
30+
<span class="description__title-item"><strong>{{ title }}</strong></span>
31+
</p>
32+
<p class="description__text description__text--permanently-deleted">{{ 'notification.no_longer_available'|trans({}, 'ibexa_notifications')|desc('The Content item is no longer available')}}</p>
33+
{% endblock %}
3434
{% endblock %}

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,13 @@
1515
{{ 'notification.trashed'|trans|desc('Sent to Trash')}}
1616
</span>
1717
{% endblock %}
18+
19+
{% block message %}
20+
{% block content %}
21+
<p class="description__title">
22+
{{ 'notification.title'|trans|desc('Title:') }}
23+
<span class="description__title-item"><strong>{{ title }}</strong></span>
24+
</p>
25+
<p class="description__text">{{ 'notification.trashed.info'|trans({}, 'ibexa_notifications')|desc('moved to Trash')}}</p>
26+
{% endblock %}
27+
{% endblock %}

0 commit comments

Comments
 (0)