Skip to content

Commit 3ad5a90

Browse files
authored
feat(ui5-list): growintButtonText property added (#8349)
Fixes: #7028
1 parent b56477c commit 3ad5a90

File tree

6 files changed

+75
-4
lines changed

6 files changed

+75
-4
lines changed

packages/main/src/List.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
<div
8585
tabindex="0"
8686
role="button"
87-
id="{{_id}}-growing-btn"
87+
id="{{_id}}-growing-btn"
8888
aria-labelledby="{{_id}}-growingButton-text"
8989
?active="{{_loadMoreActive}}"
9090
@click="{{_onLoadMoreClick}}"

packages/main/src/List.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,19 @@ class List extends UI5Element {
332332
@property({ type: ListGrowingMode, defaultValue: ListGrowingMode.None })
333333
growing!: `${ListGrowingMode}`;
334334

335+
/**
336+
* Defines the text that will be displayed inside the growing button.
337+
*
338+
* **Note:** If not specified a built-in text will be displayed.
339+
*
340+
* **Note:** This property takes effect if the `growing` property is set to the `Button`.
341+
* @default ""
342+
* @since 1.24
343+
* @public
344+
*/
345+
@property()
346+
growingButtonText!: string;
347+
335348
/**
336349
* Defines if the component would display a loading indicator over the list.
337350
* @default false
@@ -585,7 +598,7 @@ class List extends UI5Element {
585598
}
586599

587600
get _growingButtonText(): string {
588-
return List.i18nBundle.getText(LOAD_MORE_TEXT);
601+
return this.growingButtonText || List.i18nBundle.getText(LOAD_MORE_TEXT);
589602
}
590603

591604
get busyIndPosition() {

packages/main/test/pages/List.html

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@
3737

3838
<br/><br/>
3939

40+
<h2>List growing="Button" and growing-button-text property used</h2>
41+
<ui5-list id="infiniteScrollEx2" growing="Button" growing-button-text="Custom growing-button-text" class="list3auto">
42+
<ui5-li-groupheader>New Items</ui5-li-groupheader>
43+
<ui5-li image="./img/HT-1000.jpg" icon="navigation-right-arrow" additional-text="Available">Voluptate do eu cupidatat elit est culpa. Reprehenderit eiusmod voluptate ex est dolor nostrud Lorem Lorem do nisi laborum veniam. Sint do non culpa aute occaecat labore ipsum veniam minim tempor est. Duis pariatur aute culpa irure ad excepteur pariatur culpa culpa ea duis occaecat aute irure. Ipsum velit culpa non exercitation ex laboris deserunt in eu non officia in. Laborum sunt aliqua labore cupidatat sunt labore.</ui5-li>
44+
<ui5-li image="./img/portrait.jpg" icon="navigation-right-arrow" additional-text="Re-stock" description="#12331232131" additional-text-state="Error">Laptop Lenovo</ui5-li>
45+
<ui5-li image="./img/HT-1022.jpg" icon="navigation-right-arrow" additional-text="Re-stock" description="#12331232131" additional-text-state="Information">IPhone 3</ui5-li>
46+
</ui5-list>
47+
48+
<br/><br/>
49+
4050
<h2>ui5-list</h2>
4151

4252
<ui5-list header-text="API: GroupHeaderListItem" mode="MultiSelect">
@@ -458,6 +468,18 @@ <h3 id="infoLbl">Items 3/3</h3>
458468
}, 1000);
459469
});
460470

471+
472+
infiniteScrollEx2.addEventListener("ui5-load-more", function(e) {
473+
var el = infiniteScrollEx2;
474+
el.busy = true;
475+
476+
setTimeout(function() {
477+
insertItems(el, 3);
478+
el.busy = false;
479+
result.textContent = (++loadedCount) + " times " + (itemsLoadedTotal += itemsToLoad);
480+
}, 1000);
481+
});
482+
461483
</script>
462484
</body>
463-
</html>
485+
</html>

packages/main/test/pages/List_test_page.html

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@
3939

4040
<br><br><br>
4141

42+
<ui5-list id="infiniteScrollEx2" class="list_test_page2auto" growing="Button" growing-button-text="Custom text">
43+
<ui5-li>Laptop Lenovo</ui5-li>
44+
<ui5-li>IPhone 3</ui5-li>
45+
<ui5-li>HP Monitor 24</ui5-li>
46+
<ui5-li>Audio cabel</ui5-li>
47+
<ui5-li>DVD set</ui5-li>
48+
<ui5-li>HP Monitor 24</ui5-li>
49+
<ui5-li>Audio cabel</ui5-li>
50+
<ui5-li id="lastItem">Last Item</ui5-li>
51+
</ui5-list>
52+
4253
<br/>
4354
<ui5-list id="listEvents" mode="SingleSelectEnd">
4455
<ui5-li id="country1">Argentina</ui5-li>
@@ -390,6 +401,15 @@ <h2 id="testHeader">Test aria</h2>
390401
loadMoreResult.value= ++loadMoreCounter;
391402
});
392403

404+
infiniteScrollEx2.addEventListener("ui5-loadMore", function(e) {
405+
for(var i = 0; i < 3; i++) {
406+
var li = document.createElement("ui5-li");
407+
li.textContent = "Title" + i;
408+
infiniteScrollEx2.appendChild(li);
409+
}
410+
loadMoreResult.value= ++loadMoreCounter;
411+
});
412+
393413
detailListItem.addEventListener("ui5-detail-click", function(e) {
394414
detailPressCounter.innerHTML = parseInt(detailPressCounter.innerHTML) + 1;
395415
});
@@ -448,4 +468,4 @@ <h2 id="testHeader">Test aria</h2>
448468
</ui5-list>
449469
<div id="tabIndexChangeResult"></div>
450470
</body>
451-
</html>
471+
</html>

packages/main/test/specs/List.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,4 +615,19 @@ describe("List Tests", () => {
615615
assert.strictEqual(rootTooltip, newTooltip, "Tooltip of root element is updated correctly at runtime.");
616616
assert.strictEqual(rootTooltip, innerTooltip, "Tooltip of root element and title of inner li element are equal after runtime change.");
617617
});
618+
619+
it("Tests the growingButtonText property", async () => {
620+
const list = await browser.$("#infiniteScrollEx2");
621+
const btnText = "Custom text"
622+
let growingBtnText = await list.getProperty("growingButtonText");
623+
624+
assert.strictEqual(growingBtnText, btnText, "GrowingButtonText property is correctly set to the list.");
625+
626+
const newBtnText = "New custom text";
627+
await list.setProperty("growingButtonText", newBtnText);
628+
growingBtnText = await list.getProperty("growingButtonText");
629+
630+
assert.strictEqual(growingBtnText, newBtnText, "GrowingButtonText property is correctly changed.");
631+
632+
});
618633
});

packages/playground/_stories/main/List/List.stories.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const Template: UI5StoryArgs<List, StoryArgsSlots> = (args) => {
2222
?busy="${ifDefined(args.busy)}"
2323
?indent="${ifDefined(args.indent)}"
2424
?growing="${ifDefined(args.growing)}"
25+
growing-button-text="${ifDefined(args.growingButtonText)}"
2526
busy-delay="${ifDefined(args.busyDelay)}"
2627
separators="${ifDefined(args.separators)}"
2728
header-text="${ifDefined(args.headerText)}"

0 commit comments

Comments
 (0)