Skip to content

Commit 77bd73e

Browse files
authored
feat(ui5-view-settings-dialog): add group option (#11950)
This feature introduces a new `Group` option to the `ui5-view-settings-dialog` allowing users to select a group of options and in what way they should be ordered, similar to the `Sort` option. To use the Group option, we introduced a `ui5-group-item` that can be slotted in the `groupItems` slot of a `ui5-view-settings-dialog`. Fixes: #11815
1 parent 8edc111 commit 77bd73e

File tree

15 files changed

+557
-120
lines changed

15 files changed

+557
-120
lines changed

packages/fiori/cypress/specs/ViewSettingsDialog.cy.tsx

Lines changed: 117 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import ViewSettingsDialog from "../../src/ViewSettingsDialog.js";
2+
import GroupItem from "../../src/GroupItem.js";
23
import SortItem from "../../src/SortItem.js";
34
import FilterItem from "../../src/FilterItem.js";
45
import FilterItemOption from "../../src/FilterItemOption.js";
56

6-
describe("View settings dialog - selection", () => {
7-
it("tests clicking on sort items (both on the text and radio button)", () => {
7+
describe("View settings dialog - confirm event", () => {
8+
it("should throw confirm event after selecting sort options and confirm button", () => {
89
cy.mount(
910
<ViewSettingsDialog id="vsd" onConfirm={cy.stub().as("confirm")}>
1011
<SortItem slot="sortItems" text="Name" selected={true}></SortItem>
@@ -86,7 +87,7 @@ describe("View settings dialog - selection", () => {
8687
.should("equal", "Name");
8788
});
8889

89-
it("tests clicking on filter items, and filter item options (both on the text and checkbox)", () => {
90+
it("should throw confirm event after selecting filter options and confirm button", () => {
9091
cy.mount(
9192
<ViewSettingsDialog id="vsd" onConfirm={cy.stub().as("confirm")}>
9293
<FilterItem slot="filterItems" text="Filter 1">
@@ -167,6 +168,61 @@ describe("View settings dialog - selection", () => {
167168
.find("[ui5-dialog]")
168169
.should("not.be.visible");
169170
});
171+
172+
it("should throw confirm event after selecting group options and confirm button", () => {
173+
cy.mount(
174+
<ViewSettingsDialog onConfirm={cy.stub().as("confirm")}>
175+
<GroupItem slot="groupItems" text="Name"></GroupItem>
176+
<GroupItem slot="groupItems" text="Position"></GroupItem>
177+
<GroupItem slot="groupItems" text="(No Group)"></GroupItem>
178+
</ViewSettingsDialog>
179+
);
180+
181+
cy.get("[ui5-view-settings-dialog]")
182+
.as("vsd")
183+
.invoke("prop", "open", true);
184+
185+
cy.get("@vsd")
186+
.shadow()
187+
.find("[group-order] ui5-li")
188+
.as("groupOrderItems");
189+
190+
cy.get("@groupOrderItems")
191+
.should("have.length", 2);
192+
193+
// Select the group order (Descending)
194+
cy.get("@groupOrderItems")
195+
.eq(1)
196+
.realClick();
197+
198+
cy.get("@vsd")
199+
.shadow()
200+
.find("[group-by] ui5-li")
201+
.as("groupByItems");
202+
203+
cy.get("@groupByItems")
204+
.should("have.length", 3);
205+
206+
// Select the group by (No Group)
207+
cy.get("@groupByItems")
208+
.eq(2)
209+
.realClick();
210+
211+
// Confirm the selection
212+
cy.get("@vsd")
213+
.shadow()
214+
.find(".ui5-vsd-footer ui5-button")
215+
.realClick();
216+
217+
// Check the confirm event for groupOrder and groupBy
218+
cy.get("@confirm")
219+
.should("be.calledWithMatch", {
220+
detail: {
221+
groupOrder: "Descending",
222+
groupBy: "(No Group)",
223+
},
224+
});
225+
});
170226
});
171227

172228
describe("ViewSettingsDialog Tests", () => {
@@ -371,6 +427,31 @@ describe("ViewSettingsDialog Tests", () => {
371427
.invoke("prop", "open", false);
372428
});
373429

430+
it("should handle group-only mode", () => {
431+
cy.mount(
432+
<ViewSettingsDialog id="vsdGroup">
433+
<GroupItem slot="groupItems" text="Name"></GroupItem>
434+
<GroupItem slot="groupItems" text="Position"></GroupItem>
435+
<GroupItem slot="groupItems" text="Company"></GroupItem>
436+
<GroupItem slot="groupItems" text="Department"></GroupItem>
437+
</ViewSettingsDialog>
438+
);
439+
440+
cy.get("#vsdGroup")
441+
.as("vsd");
442+
443+
cy.get("@vsd")
444+
.invoke("prop", "open", true);
445+
446+
cy.get("@vsd")
447+
.shadow()
448+
.find("[ui5-segmented-button]")
449+
.should("not.exist");
450+
451+
cy.get("@vsd")
452+
.invoke("prop", "open", false);
453+
});
454+
374455
it("should focus first item in filter options", () => {
375456
cy.mount(
376457
<ViewSettingsDialog id="vsdFilter">
@@ -407,4 +488,37 @@ describe("ViewSettingsDialog Tests", () => {
407488
.first()
408489
.should("be.focused");
409490
});
491+
492+
it("should show a split button with all loaded VSD options", () => {
493+
cy.mount(
494+
<ViewSettingsDialog id="vsd">
495+
<SortItem slot="sortItems" text="Name"></SortItem>
496+
<FilterItem slot="filterItems" text="Filter 1">
497+
<FilterItemOption slot="values" text="Some filter 1"></FilterItemOption>
498+
<FilterItemOption slot="values" text="Some filter 2"></FilterItemOption>
499+
<FilterItemOption slot="values" text="Some filter 3"></FilterItemOption>
500+
</FilterItem>
501+
<GroupItem slot="groupItems" text="Name"></GroupItem>
502+
</ViewSettingsDialog>
503+
);
504+
505+
cy.get("[ui5-view-settings-dialog]")
506+
.as("vsd")
507+
.invoke("prop", "open", true);
508+
509+
cy.get("@vsd")
510+
.shadow()
511+
.find("[ui5-segmented-button]")
512+
.as("segmentedButton");
513+
514+
cy.get("@segmentedButton")
515+
.should("be.visible");
516+
517+
cy.get("@segmentedButton")
518+
.find("[ui5-segmented-button-item]")
519+
.as("items");
520+
521+
cy.get("@items")
522+
.should("have.length", 3);
523+
});
410524
});

packages/fiori/src/FilterItem.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import type FilterItemOption from "./FilterItemOption.js";
99
*
1010
* ### Overview
1111
*
12+
* The `ui5-filter-item` component defines the filtering criteria for data in `ui5-view-settings-dialog`.
13+
* It represents a single filter category that contains multiple filter options that users can select.
14+
*
1215
* ### Usage
1316
*
14-
* For the `ui5-filter-item`
17+
* The `ui5-filter-item` is used within the `ui5-view-settings-dialog` to provide filtering options.
18+
*
1519
* ### ES6 Module Import
1620
*
17-
* `import @ui5/webcomponents-fiori/dist/FilterItem.js";`
21+
* `import "@ui5/webcomponents-fiori/dist/FilterItem.js";`
1822
* @constructor
1923
* @extends UI5Element
2024
* @abstract
@@ -24,23 +28,24 @@ import type FilterItemOption from "./FilterItemOption.js";
2428
@customElement("ui5-filter-item")
2529
class FilterItem extends UI5Element {
2630
/**
27-
* Defines the text of the component.
31+
* Defines the text of the filter item.
2832
* @default undefined
2933
* @public
3034
*/
3135
@property()
3236
text?: string;
3337

3438
/**
35-
* Defines the additional text of the component.
39+
* Defines the additional text of the filter item.
40+
* This text is typically used to show the number of selected filter options within this category.
3641
* @default undefined
3742
* @public
3843
*/
3944
@property()
4045
additionalText?: string;
4146

4247
/**
43-
* Defines the `values` list.
48+
* Defines the filter options available for this filter category.
4449
* @public
4550
*/
4651
@slot()

packages/fiori/src/FilterItemOption.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
77
*
88
* ### Overview
99
*
10+
* The `ui5-filter-item-option` component defines individual filter values within a `ui5-filter-item`.
11+
* It represents a single selectable option that users can choose to filter data.
12+
*
1013
* ### Usage
1114
*
12-
* For the `ui5-filter-item-option`
15+
* The `ui5-filter-item-option` is used as a child component within `ui5-filter-item` in the context
16+
* of `ui5-view-settings-dialog`. Each option represents a specific value that can be used for filtering
17+
*
1318
* ### ES6 Module Import
1419
*
15-
* `import @ui5/webcomponents-fiori/dist/FilterItemOption.js";`
20+
* `import "@ui5/webcomponents-fiori/dist/FilterItemOption.js";`
1621
* @constructor
1722
* @extends UI5Element
1823
* @abstract
@@ -22,15 +27,15 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
2227
@customElement("ui5-filter-item-option")
2328
class FilterItemOption extends UI5Element {
2429
/**
25-
* Defines the text of the component.
30+
* Defines the text of the filter option.
2631
* @default undefined
2732
* @public
2833
*/
2934
@property()
3035
text?: string;
3136

3237
/**
33-
* Defines if the component is selected.
38+
* Defines if the filter option is selected.
3439
* @default false
3540
* @public
3641
*/

packages/fiori/src/GroupItem.ts

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import UI5Element from "@ui5/webcomponents-base/dist/UI5Element.js";
2+
import property from "@ui5/webcomponents-base/dist/decorators/property.js";
3+
import customElement from "@ui5/webcomponents-base/dist/decorators/customElement.js";
4+
5+
/**
6+
* @class
7+
*
8+
* ### Overview
9+
*
10+
* The `ui5-group-item` component defines the grouping criteria for data in `ui5-view-settings-dialog`.
11+
* It represents a single group option that users can select to organize data into logical groups.
12+
*
13+
* ### Usage
14+
*
15+
* The `ui5-group-item` is used within the `ui5-view-settings-dialog` to provide grouping options.
16+
* Each group item represents a column or field by which data can be grouped.
17+
*
18+
* ### ES6 Module Import
19+
*
20+
* `import "@ui5/webcomponents-fiori/dist/GroupItem.js";`
21+
* @constructor
22+
* @extends UI5Element
23+
* @abstract
24+
* @since 2.13.0
25+
* @public
26+
*/
27+
@customElement("ui5-group-item")
28+
class GroupItem extends UI5Element {
29+
/**
30+
* Defines the text of the group item.
31+
* @default undefined
32+
* @public
33+
*/
34+
@property()
35+
text?: string;
36+
37+
/**
38+
* Defines if the group item is selected.
39+
* @default false
40+
* @public
41+
*/
42+
@property({ type: Boolean })
43+
selected = false;
44+
}
45+
46+
GroupItem.define();
47+
48+
export default GroupItem;

packages/fiori/src/SortItem.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,17 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
77
*
88
* ### Overview
99
*
10+
* The `ui5-sort-item` component defines the sorting criteria for data in `ui5-view-settings-dialog`.
11+
* It represents a single sort option that users can select to organize data in ascending or descending order.
12+
*
1013
* ### Usage
1114
*
12-
* For the `ui5-sort-item`
15+
* The `ui5-sort-item` is used within the `ui5-view-settings-dialog` to provide sorting options.
16+
* Each sort item represents a column or field by which data can be sorted.
17+
*
1318
* ### ES6 Module Import
1419
*
15-
* `import @ui5/webcomponents-fiori/dist/SortItem.js";`
20+
* `import "@ui5/webcomponents-fiori/dist/SortItem.js";`
1621
* @constructor
1722
* @extends UI5Element
1823
* @abstract
@@ -22,15 +27,15 @@ import customElement from "@ui5/webcomponents-base/dist/decorators/customElement
2227
@customElement("ui5-sort-item")
2328
class SortItem extends UI5Element {
2429
/**
25-
* Defines the text of the component.
30+
* Defines the text of the sort item.
2631
* @default undefined
2732
* @public
2833
*/
2934
@property()
3035
text?: string;
3136

3237
/**
33-
* Defines if the component is selected.
38+
* Defines if the sort item is selected.
3439
* @default false
3540
* @public
3641
*/

0 commit comments

Comments
 (0)