Skip to content

Commit fd9a221

Browse files
authored
feat(ui5-li-notification, ui5-li-notification-group): add busy property (#1674)
Add "busy" property to NotificationList(Group)ItemBase to enable users show busy state on notification item and group level. FIXES: #1672
1 parent 6790647 commit fd9a221

10 files changed

+83
-3
lines changed

packages/fiori/src/NotificationListGroupItem.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,8 @@
7474
<ui5-list class="ui5-nli-group-items">
7575
<slot></slot>
7676
</ui5-list>
77+
78+
{{#if busy}}
79+
<ui5-busyindicator active size="Medium" class="ui5-nli-busy"></ui5-busyindicator>
80+
{{/if}}
7781
</li>

packages/fiori/src/NotificationListGroupItem.js

+18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { fetchI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
22
import Priority from "@ui5/webcomponents/dist/types/Priority.js";
33
import List from "@ui5/webcomponents/dist/List.js";
44
import Button from "@ui5/webcomponents/dist/Button.js";
5+
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
56
import Icon from "@ui5/webcomponents/dist/Icon.js";
67
import Popover from "@ui5/webcomponents/dist/Popover.js";
78
import NotificationListItemBase from "./NotificationListItemBase.js";
@@ -125,11 +126,28 @@ class NotificationListGroupItem extends NotificationListItemBase {
125126
return NotificationListGroupItemTemplate;
126127
}
127128

129+
onBeforeRendering() {
130+
if (this.busy) {
131+
this.clearChildBusyIndicator();
132+
}
133+
}
134+
135+
/**
136+
* Clears child items busy state to show a single busy over the entire group,
137+
* instead of multiple BusyIndicator instances
138+
*/
139+
clearChildBusyIndicator() {
140+
this.items.forEach(item => {
141+
item.busy = false;
142+
});
143+
}
144+
128145
static async onDefine() {
129146
await Promise.all([
130147
List.define(),
131148
Button.define(),
132149
Icon.define(),
150+
BusyIndicator.define(),
133151
Popover.define(),
134152
fetchI18nBundle("@ui5/webcomponents-fiori"),
135153
]);

packages/fiori/src/NotificationListItem.hbs

+4
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,8 @@
9191
<div class="ui5-nli-avatar">
9292
<slot name="avatar"></slot>
9393
</div>
94+
95+
{{#if busy}}
96+
<ui5-busyindicator active size="Medium" class="ui5-nli-busy"></ui5-busyindicator>
97+
{{/if}}
9498
</li>

packages/fiori/src/NotificationListItem.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
55

66
import Priority from "@ui5/webcomponents/dist/types/Priority.js";
77
import Button from "@ui5/webcomponents/dist/Button.js";
8+
import BusyIndicator from "@ui5/webcomponents/dist/BusyIndicator.js";
89
import Link from "@ui5/webcomponents/dist/Link.js";
910
import Icon from "@ui5/webcomponents/dist/Icon.js";
1011
import Popover from "@ui5/webcomponents/dist/Popover.js";
@@ -199,6 +200,7 @@ class NotificationListItem extends NotificationListItemBase {
199200
await Promise.all([
200201
Button.define(),
201202
Icon.define(),
203+
BusyIndicator.define(),
202204
Link.define(),
203205
Popover.define(),
204206
fetchI18nBundle("@ui5/webcomponents-fiori"),

packages/fiori/src/NotificationListItemBase.js

+11
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,17 @@ const metadata = {
5555
showClose: {
5656
type: Boolean,
5757
},
58+
59+
/**
60+
* Defines if a busy indicator would be displayed over the item.
61+
* @type {boolean}
62+
* @defaultvalue false
63+
* @public
64+
* @since 1.0.0-rc.8
65+
*/
66+
busy: {
67+
type: Boolean,
68+
},
5869
},
5970
slots: /** @lends sap.ui.webcomponents.fiori.NotificationListItemBase.prototype */ {
6071

packages/fiori/src/themes/NotificationListItemBase.css

+12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
pointer-events: none;
2828
}
2929

30+
:host([busy]) {
31+
opacity: 0.6;
32+
pointer-events: none;
33+
}
34+
35+
:host([busy]) .ui5-nli-busy {
36+
position: absolute;
37+
top: 50%;
38+
left: 50%;
39+
transform: translate(-50%, -50%);
40+
}
41+
3042
.ui5-nli-action {
3143
flex-shrink: 0;
3244
margin-right: 0.5rem;

packages/fiori/test/pages/NotificationListGroupItem.html

+14-1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ <h3>Events on ui5-list level</h3>
108108
priority="High"
109109
>
110110
<ui5-li-notification
111+
busy
111112
show-close
112113
heading="New order (#2900) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc."
113114
priority="High"
@@ -151,12 +152,14 @@ <h3>Events on ui5-list level</h3>
151152
</ui5-li-notification-group>
152153

153154
<ui5-li-notification-group
155+
id="busyGroup"
154156
show-close
155157
show-counter
156158
priority="High"
157159
heading="Meetings With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc."
158160
>
159161
<ui5-li-notification
162+
busy
160163
show-close
161164
heading="New order (#35001) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc."
162165
priority="High"
@@ -195,7 +198,7 @@ <h3>Events on ui5-list level</h3>
195198
<span slot="footnotes">3 Days</span>
196199
</ui5-li-notification>
197200

198-
<ui5-notification-overflow-action icon="accept" text="Accept All" slot="actions"></ui5-notification-overflow-action>
201+
<ui5-notification-overflow-action id="btnMakeGroupBusy"icon="accept" text="Accept All" slot="actions"></ui5-notification-overflow-action>
199202
</ui5-li-notification-group>
200203
</ui5-list>
201204

@@ -313,6 +316,16 @@ <h3>Events on ui5-list level</h3>
313316
notificationsPopover.openBy(openNotifications);
314317
});
315318

319+
btnMakeGroupBusy.addEventListener("click", function(event) {
320+
busyGroup.busy = true;
321+
322+
setTimeout(function() {
323+
busyGroup.busy = false;
324+
}, 2000);
325+
});
326+
327+
328+
316329
shellbar.addEventListener("ui5-notificationsClick", function(event) {
317330
event.preventDefault();
318331
notificationsPopover.openBy(event.detail.targetRef);

packages/fiori/test/pages/NotificationListItem.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ <h3>Events on ui5-list level</h3>
5252
<ui5-list id="notificationList" header-text="Notifications heading and content 'truncates'">
5353

5454
<ui5-li-notification
55+
busy
5556
show-close
5657
heading="New order (#2525) With a very long title - Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent feugiat, turpis vel scelerisque pharetra, tellus odio vehicula dolor, nec elementum lectus turpis at nunc."
5758
>
@@ -247,8 +248,15 @@ <h3>Events on ui5-list level</h3>
247248
});
248249

249250
notificationList2.addEventListener("itemClick", function(event) {
250-
event.detail.item.read = true;
251-
wcToastBS.textContent = event.detail.item.heading;
251+
var item = event.detail.item;
252+
253+
setTimeout(function() {
254+
item.busy = false;
255+
item.read = true;
256+
}, 1000);
257+
258+
item.busy = true;
259+
wcToastBS.textContent = item.heading;
252260
wcToastBS.show();
253261
});
254262

packages/fiori/test/pages/NotificationList_test_page.html

+1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@
124124

125125
<ui5-li-notification
126126
id="nli4"
127+
busy
127128
wrap
128129
show-close
129130
heading="New payment #2901"

packages/fiori/test/specs/NotificationList.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ describe("Notification List Item Tests", () => {
105105
"The custom actions are hidden when the group is collapsed");
106106
});
107107

108+
it("tests busy indicator is displayed", () => {
109+
const busyItem = $("#nli4");
110+
const busyIndicator = busyItem.shadow$(".ui5-nli-busy");
111+
112+
assert.ok(busyIndicator.isExisting(), "The busy indicator is displayed");
113+
});
114+
108115
it("tests List Group Item ACC invisible text", () => {
109116
const EXPECTED_RESULT = "Notification group High Priority Counter 2";
110117
const firstGroupItem = $("#nlgi1");

0 commit comments

Comments
 (0)