Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui5-busy-indicator): add new "delay" property #3419

Merged
merged 10 commits into from
Jun 14, 2021
5 changes: 4 additions & 1 deletion packages/fiori/src/NotificationListGroupItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
</ui5-list>

{{#if busy}}
<ui5-busy-indicator active size="Medium" class="ui5-nli-busy"></ui5-busy-indicator>
<ui5-busy-indicator
busyDelay="{{delay}}"
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
active size="Medium"
class="ui5-nli-busy"></ui5-busy-indicator>
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
{{/if}}
</li>
6 changes: 5 additions & 1 deletion packages/fiori/src/NotificationListItem.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@
</div>

{{#if busy}}
<ui5-busy-indicator active size="Medium" class="ui5-nli-busy"></ui5-busy-indicator>
<ui5-busy-indicator
busyDelay="{{delay}}"
active
size="Medium"
class="ui5-nli-busy"></ui5-busy-indicator>
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
{{/if}}
</li>
13 changes: 13 additions & 0 deletions packages/fiori/src/NotificationListItemBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { isSpace } from "@ui5/webcomponents-base/dist/Keys.js";
import { getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";

import ListItemBase from "@ui5/webcomponents/dist/ListItemBase.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import Priority from "@ui5/webcomponents/dist/types/Priority.js";

// Icons
Expand Down Expand Up @@ -85,6 +86,18 @@ const metadata = {
busy: {
type: Boolean,
},

/**
* Defines the delay in milliseconds, after which the busy indicator will show up for this control.
*
* @type {Integer}
* @defaultValue 1000
* @public
*/
busyDelay: {
type: Integer,
defaultValue: 1000,
},
},
slots: /** @lends sap.ui.webcomponents.fiori.NotificationListItemBase.prototype */ {

Expand Down
4 changes: 2 additions & 2 deletions packages/main/src/BusyIndicator.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="{{classes.root}}">
{{#if active}}
{{#if _isBusy}}
<div
class="ui5-busy-indicator-busy-area"
title="{{ariaTitle}}"
Expand All @@ -25,7 +25,7 @@

<slot></slot>

{{#if active}}
{{#if _isBusy}}
<span data-ui5-focus-redirect tabindex="0" @focusin="{{_redirectFocus}}"></span>
{{/if}}
</div>
39 changes: 39 additions & 0 deletions packages/main/src/BusyIndicator.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
import { isTabNext } from "@ui5/webcomponents-base/dist/Keys.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import BusyIndicatorSize from "./types/BusyIndicatorSize.js";
import Label from "./Label.js";

Expand Down Expand Up @@ -78,6 +79,27 @@ const metadata = {
active: {
type: Boolean,
},

/**
* Defines the delay in milliseconds, after which the busy indicator will be visible on the screen.
*
* @type {Integer}
* @defaultValue 1000
* @public
*/
delay: {
type: Integer,
defaultValue: 1000,
},

/**
* Defines if the control is currently in busy state.
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
* @private
*/
_isBusy: {
type: Boolean,
noAttribute: true,
},
},
};

Expand Down Expand Up @@ -188,6 +210,23 @@ class BusyIndicator extends UI5Element {
};
}

onBeforeRendering() {
if (this.active) {
if (!this._isBusy && !this._busyTimeoutId) {
this._busyTimeoutId = setTimeout(() => {
delete this._busyTimeoutId;
this._isBusy = true;
}, Math.max(0, this.delay));
}
} else {
if (this._busyTimeoutId) {
clearTimeout(this._busyTimeoutId);
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
delete this._busyTimeoutId;
}
this._isBusy = false;
}
}

_handleKeydown(event) {
if (!this.active) {
return;
Expand Down
4 changes: 3 additions & 1 deletion packages/main/src/List.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@
{{#if busy}}
<div class="ui5-list-busy-row">
<ui5-busy-indicator
active size="Medium"
busyDelay="{{delay}}"
active
size="Medium"
class="ui5-list-busy-ind"
style="{{styles.busyInd}}"
></ui5-busy-indicator>
Expand Down
13 changes: 13 additions & 0 deletions packages/main/src/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
import { renderFinished } from "@ui5/webcomponents-base/dist/Render.js";
import { getLastTabbableElement } from "@ui5/webcomponents-base/dist/util/TabbableElements.js";
import { isTabNext, isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import NavigationMode from "@ui5/webcomponents-base/dist/types/NavigationMode.js";
import { getEffectiveAriaLabelText } from "@ui5/webcomponents-base/dist/util/AriaLabelHelper.js";
import { fetchI18nBundle, getI18nBundle } from "@ui5/webcomponents-base/dist/i18nBundle.js";
Expand Down Expand Up @@ -185,6 +186,18 @@ const metadata = {
type: Boolean,
},

/**
* Defines the delay in milliseconds, after which the busy indicator will show up for this control.
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
*
* @type {Integer}
* @defaultValue 1000
* @public
*/
busyDelay: {
type: Integer,
defaultValue: 1000,
},

/**
* @type {String}
* @defaultvalue ""
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/Table.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
{{#*inline "busyRow"}}
<div tabindex="-1" class="ui5-table-busy-row">
<ui5-busy-indicator
busyDelay="{{delay}}"
class="ui5-table-busy-ind"
style="{{styles.busy}}"
active
Expand Down
13 changes: 13 additions & 0 deletions packages/main/src/Table.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
import litRender from "@ui5/webcomponents-base/dist/renderer/LitRenderer.js";
import ResizeHandler from "@ui5/webcomponents-base/dist/delegate/ResizeHandler.js";
import ItemNavigation from "@ui5/webcomponents-base/dist/delegate/ItemNavigation.js";
import Integer from "@ui5/webcomponents-base/dist/types/Integer.js";
import NavigationMode from "@ui5/webcomponents-base/dist/types/NavigationMode.js";
import { isIE } from "@ui5/webcomponents-base/dist/Device.js";
import { isSpace, isEnter } from "@ui5/webcomponents-base/dist/Keys.js";
Expand Down Expand Up @@ -167,6 +168,18 @@ const metadata = {
type: Boolean,
},

/**
* Defines the delay in milliseconds, after which the busy indicator will show up for this control.
*
* @type {Integer}
* @defaultValue 1000
* @public
*/
busyDelay: {
type: Integer,
defaultValue: 1000,
},

/**
* Determines whether the column headers remain fixed at the top of the page during
* vertical scrolling as long as the Web Component is in the viewport.
Expand Down
5 changes: 2 additions & 3 deletions packages/main/test/pages/BusyIndicator.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,9 @@
</div>
</ui5-dialog>
<script>
var busyIndicator = document.getElementById("busy-container");
var list = document.getElementById("fetch-list");

document.getElementById("fetch-btn").addEventListener("click", function(event) {
var busyIndicator = document.getElementById("busy-container");
var list = document.getElementById("fetch-list");
busyIndicator.setAttribute("active", "");

setTimeout(function() {
Expand Down
13 changes: 0 additions & 13 deletions packages/main/test/specs/BusyIndicator.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ describe("BusyIndicator general interaction", () => {
assert.strictEqual(input.getProperty("value"), "0", "itemClick is not thrown");
});

it("tests focus handling", () => {
TeodorTaushanov marked this conversation as resolved.
Show resolved Hide resolved
const busyIndicator = browser.$("#indicator1");
busyIndicator.click();

let innerFocusElement = browser.execute(() => {
return document.getElementById("indicator1").shadowRoot.activeElement;
});

innerFocusElement = $(innerFocusElement);

assert.strictEqual(innerFocusElement.getAttribute("class"), "ui5-busy-indicator-busy-area", "The correct inner element is focused");
});

it("tests internal focused element attributes", () => {
const busyIndicator = browser.$("#indicator1");
busyIndicator.click();
Expand Down