Skip to content

Commit c77b730

Browse files
author
Bogdan Plieshka
committed
MAGETWO-32250: Header
- Fixed header notifications events
1 parent 38b7172 commit c77b730

File tree

6 files changed

+67
-24
lines changed

6 files changed

+67
-24
lines changed

app/code/Magento/AdminNotification/view/adminhtml/templates/toolbar_entry.phtml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@
6969
<li class="notifications-entry notifications-entry-last">
7070
<a
7171
href="<?php echo $block->getUrl('adminhtml/notification/index'); ?>"
72-
class="action-tertiary action-more"><?php echo __('See All (%1 unread)', $notificationCount); ?></a>
72+
class="action-tertiary action-more">
73+
<?php echo __('See All (') ?><span class="notifications-counter"><?php echo $notificationCount ?></span><?php echo __(' unread)'); ?>
74+
</a>
7375
</li>
7476
</ul>
7577
<?php else : ?>

app/code/Magento/AdminNotification/view/adminhtml/web/toolbar_entry.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,14 @@ define([
4040
$('.notifications-action .notifications-counter').text('').hide();
4141
} else {
4242
$('.notifications-action .notifications-counter').text(notificationCount);
43+
$('.notifications-entry-last .notifications-counter').text(notificationCount);
4344
// Modify caption of the 'See All' link
4445
var actionElement = $('.notifications-wrapper .notifications-list .last .action-more');
4546
actionElement.text(actionElement.text().replace(/\d+/, notificationCount));
4647
}
4748
},
4849

49-
// Show popup with notification details
50+
// Show notification details
5051
showNotificationDetails = function (notificationEntry) {
5152
var notificationDescription = notificationEntry.find('.notifications-entry-description'),
5253
notificationDescriptionEnd = notificationEntry.find('.notifications-entry-description-end');
@@ -72,10 +73,21 @@ define([
7273

7374
// Remove corresponding notification from the list and mark it as read
7475
$('.notifications-close').on('click.removeNotification', function (event) {
75-
var notificationEntry = $(this).closest('.notifications-entry'),
76+
var notificationsList = $(this).closest('.notifications-list'),
77+
notificationEntries = notificationsList.find('.notifications-entry'),
78+
notificationEntry = $(this).closest('.notifications-entry'),
7679
notificationId = notificationEntry.attr('data-notification-id');
80+
7781
markNotificationAsRead(notificationId);
7882
removeNotificationFromList(notificationEntry);
83+
84+
// Checking for last unread notification to hide dropdown
85+
if (notificationEntries.length == 2 && notificationCount == 0) {
86+
$('.notifications-wrapper').removeClass('active')
87+
.find('.notifications-action').removeAttr('data-toggle')
88+
.off('click.dropdown');
89+
}
90+
7991
event.stopPropagation();
8092
});
8193

app/code/Magento/Backend/view/adminhtml/templates/page/header.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
<ul class="admin-user-menu">
2626
<?php if ($block->getAuthorization()->isAllowed('Magento_Backend::myaccount')): ?>
2727
<li>
28-
<a href="<?php echo $block->getUrl('adminhtml/system_account/index') ?>" <?php echo $block->getUiId('user', 'account', 'settings')?> title="<?php echo __('Account Setting') ?>"><?php echo __('Account Setting') ?> <span> (<?php echo $block->escapeHtml($block->getUser()->getUsername()); ?>)</span></a>
28+
<a href="<?php echo $block->getUrl('adminhtml/system_account/index') ?>" <?php echo $block->getUiId('user', 'account', 'settings')?> title="<?php echo __('Account Setting') ?>"><?php echo __('Account Setting') ?> (<span class="admin-user-name"><?php echo $block->escapeHtml($block->getUser()->getUsername()); ?></span>)</a>
2929
</li>
3030
<?php endif; ?>
3131
<li><a href="<?php echo $block->getBaseUrl(); ?>" title="<?php echo __('Customer View'); ?>" target="_blank" class="store-front"><?php echo __('Customer View'); ?></a></li>

app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_notifications.less

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,20 @@
7272
top: 1px;
7373
}
7474
}
75-
}
76-
77-
.notifications-counter {
78-
background-color: @notifications-counter__background-color;
79-
border-radius: 1em;
80-
color: @color-white;
81-
display: inline-block;
82-
font-size: @notifications__font-size;
83-
font-weight: @font-weight__bold;
84-
left: 50%;
85-
margin-left: .3em;
86-
margin-top: -1.1em;
87-
padding: .3em .5em;
88-
position: absolute;
89-
top: 50%;
75+
.notifications-counter {
76+
background-color: @notifications-counter__background-color;
77+
border-radius: 1em;
78+
color: @color-white;
79+
display: inline-block;
80+
font-size: @notifications__font-size;
81+
font-weight: @font-weight__bold;
82+
left: 50%;
83+
margin-left: .3em;
84+
margin-top: -1.1em;
85+
padding: .3em .5em;
86+
position: absolute;
87+
top: 50%;
88+
}
9089
}
9190

9291
.notifications-list {
@@ -108,14 +107,17 @@
108107
background-color: @notifications-entry__hover__background-color;
109108
}
110109
&.notifications-entry-last {
111-
border-top: 1px solid @color-light-gray;
112110
margin: 0 @notifications-action__padding-side;
113-
padding: .3rem 0 .6rem;
111+
padding: .3rem 0 1.3rem;
114112
text-align: center;
115113
&:hover {
116114
background-color: transparent;
117115
}
118116
}
117+
+ .notifications-entry-last {
118+
padding-bottom: .6rem;
119+
border-top: 1px solid @color-light-gray;
120+
}
119121
// Case with cutted message description
120122
._cutted {
121123
cursor: pointer;
@@ -143,6 +145,9 @@
143145

144146
.notifications-entry-description-end {
145147
display: none;
148+
&._show {
149+
display: inline;
150+
}
146151
}
147152

148153
.notifications-entry-time {

app/design/adminhtml/Magento/backend/Magento_Backend/web/css/source/module/header/actions-group/_user.less

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
max-width: @user-menu__min-width - @user-account__padding-left - @user-account__padding-right - 2rem;
8282
overflow: hidden;
8383
text-overflow: ellipsis;
84+
white-space: nowrap;
8485
}
8586

8687
.admin-user-menu {
@@ -113,4 +114,12 @@
113114
}
114115
}
115116
}
117+
.admin-user-name {
118+
display: inline-block;
119+
max-width: @user-menu__min-width;
120+
overflow: hidden;
121+
text-overflow: ellipsis;
122+
white-space: nowrap;
123+
vertical-align: text-top;
124+
}
116125
}

app/design/adminhtml/Magento/backend/web/css/override.less

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2599,6 +2599,7 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
25992599
max-width: 11.2rem;
26002600
overflow: hidden;
26012601
text-overflow: ellipsis;
2602+
white-space: nowrap;
26022603
}
26032604
.admin-user-menu {
26042605
line-height: 1.4;
@@ -2626,6 +2627,14 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
26262627
bottom: -1px;
26272628
position: relative;
26282629
}
2630+
.admin-user-menu .admin-user-name {
2631+
display: inline-block;
2632+
max-width: 20rem;
2633+
overflow: hidden;
2634+
text-overflow: ellipsis;
2635+
white-space: nowrap;
2636+
vertical-align: text-top;
2637+
}
26292638
.search-global {
26302639
float: right;
26312640
margin-right: -0.3rem;
@@ -2767,7 +2776,7 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
27672776
position: relative;
27682777
top: 1px;
27692778
}
2770-
.notifications-counter {
2779+
.notifications-action .notifications-counter {
27712780
background-color: #e22626;
27722781
border-radius: 1em;
27732782
color: #ffffff;
@@ -2799,14 +2808,17 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
27992808
background-color: #e0f6fe;
28002809
}
28012810
.notifications-entry.notifications-entry-last {
2802-
border-top: 1px solid #dddddd;
28032811
margin: 0 2rem;
2804-
padding: .3rem 0 .6rem;
2812+
padding: .3rem 0 1.3rem;
28052813
text-align: center;
28062814
}
28072815
.notifications-entry.notifications-entry-last:hover {
28082816
background-color: transparent;
28092817
}
2818+
.notifications-entry + .notifications-entry-last {
2819+
padding-bottom: .6rem;
2820+
border-top: 1px solid #dddddd;
2821+
}
28102822
.notifications-entry ._cutted {
28112823
cursor: pointer;
28122824
}
@@ -2828,6 +2840,9 @@ fieldset[disabled] .admin__control-text + .ui-datepicker-trigger {
28282840
.notifications-entry-description-end {
28292841
display: none;
28302842
}
2843+
.notifications-entry-description-end._show {
2844+
display: inline;
2845+
}
28312846
.notifications-entry-time {
28322847
color: #777777;
28332848
font-size: 1.1rem;

0 commit comments

Comments
 (0)