Skip to content

Commit 3d6cccd

Browse files
authored
feat: add option to configure a default to expand all group tags (#2330)
1 parent 5d754f2 commit 3d6cccd

File tree

7 files changed

+36
-0
lines changed

7 files changed

+36
-0
lines changed

src/components/operations/operation-list/ko/operationListEditor.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@
3333
</label>
3434
</div>
3535

36+
<div class="form-group">
37+
<label for="defaultAllGroupTagsExpanded" class="form-label">
38+
<input type="checkbox" id="defaultAllGroupTagsExpanded" name="defaultAllGroupTagsExpanded" data-bind="checked: defaultAllGroupTagsExpanded" />
39+
Default to expand all GroupTags
40+
</label>
41+
</div>
42+
3643
<div class="form-group">
3744
<label for="hyperlink" class="form-label">
3845
Link to operation details page

src/components/operations/operation-list/ko/operationListEditor.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class OperationListEditor {
1414
public readonly showToggleUrlPath: ko.Observable<boolean>;
1515
public readonly defaultShowUrlPath: ko.Observable<boolean>;
1616
public readonly defaultGroupByTagToEnabled: ko.Observable<boolean>;
17+
public readonly defaultAllGroupTagsExpanded: ko.Observable<boolean>;
1718
public readonly hyperlink: ko.Observable<HyperlinkModel>;
1819
public readonly hyperlinkTitle: ko.Computed<string>;
1920

@@ -23,6 +24,7 @@ export class OperationListEditor {
2324
this.showToggleUrlPath = ko.observable();
2425
this.defaultShowUrlPath = ko.observable();
2526
this.defaultGroupByTagToEnabled = ko.observable(false);
27+
this.defaultAllGroupTagsExpanded = ko.observable(false);
2628
this.hyperlink = ko.observable();
2729
this.hyperlinkTitle = ko.computed<string>(() => this.hyperlink() ? this.hyperlink().title : "Add a link...");
2830
}
@@ -40,13 +42,15 @@ export class OperationListEditor {
4042
this.showToggleUrlPath(this.model.showToggleUrlPath);
4143
this.defaultShowUrlPath(this.model.defaultShowUrlPath);
4244
this.defaultGroupByTagToEnabled(this.model.defaultGroupByTagToEnabled);
45+
this.defaultAllGroupTagsExpanded(this.model.defaultAllGroupTagsExpanded);
4346
this.hyperlink(this.model.detailsPageHyperlink);
4447

4548
this.allowSelection.subscribe(this.applyChanges);
4649
this.wrapText.subscribe(this.applyChanges);
4750
this.showToggleUrlPath.subscribe(this.applyChanges);
4851
this.defaultShowUrlPath.subscribe(this.applyChanges);
4952
this.defaultGroupByTagToEnabled.subscribe(this.applyChanges);
53+
this.defaultAllGroupTagsExpanded.subscribe(this.applyChanges);
5054
}
5155

5256
private applyChanges(): void {
@@ -55,6 +59,7 @@ export class OperationListEditor {
5559
this.model.showToggleUrlPath = this.showToggleUrlPath();
5660
this.model.defaultShowUrlPath = this.defaultShowUrlPath();
5761
this.model.defaultGroupByTagToEnabled = this.defaultGroupByTagToEnabled();
62+
this.model.defaultAllGroupTagsExpanded = this.defaultAllGroupTagsExpanded();
5863
this.model.detailsPageHyperlink = this.hyperlink();
5964
this.onChange(this.model);
6065
}

src/components/operations/operation-list/ko/operationListViewModelBinder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export class OperationListViewModelBinder implements ViewModelBinder<OperationLi
1616
showToggleUrlPath: state.showToggleUrlPath,
1717
defaultShowUrlPath: state.defaultShowUrlPath,
1818
defaultGroupByTagToEnabled: state.defaultGroupByTagToEnabled,
19+
defaultAllGroupTagsExpanded: state.defaultAllGroupTagsExpanded,
1920
detailsPageUrl: state.detailsPageUrl
2021
}));
2122
}
@@ -26,6 +27,7 @@ export class OperationListViewModelBinder implements ViewModelBinder<OperationLi
2627
state.showToggleUrlPath = model.showToggleUrlPath;
2728
state.defaultShowUrlPath = model.defaultShowUrlPath;
2829
state.defaultGroupByTagToEnabled = model.defaultGroupByTagToEnabled;
30+
state.defaultAllGroupTagsExpanded = model.defaultAllGroupTagsExpanded;
2931
state.detailsPageUrl = model.detailsPageHyperlink
3032
? model.detailsPageHyperlink.href
3133
: undefined

src/components/operations/operation-list/ko/runtime/operation-list.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export class OperationList {
5858
this.groupByTag = ko.observable(false);
5959
this.defaultGroupByTagToEnabled = ko.observable(false);
6060
this.groupTagsExpanded = ko.observable(new Set<string>());
61+
this.defaultAllGroupTagsExpanded = ko.observable(false);
6162
this.pattern = ko.observable();
6263
this.tags = ko.observable([]);
6364
this.pageNumber = ko.observable(1);
@@ -82,6 +83,9 @@ export class OperationList {
8283
@Param()
8384
public defaultGroupByTagToEnabled: ko.Observable<boolean>;
8485

86+
@Param()
87+
public defaultAllGroupTagsExpanded: ko.Observable<boolean>;
88+
8589
@Param()
8690
public detailsPageUrl: ko.Observable<string>;
8791

@@ -113,6 +117,12 @@ export class OperationList {
113117

114118
this.pageNumber
115119
.subscribe(this.loadOperations);
120+
121+
if (this.defaultAllGroupTagsExpanded()) {
122+
let groups = new Set<string>()
123+
this.operationGroups().map(g => {groups.add(g.tag)})
124+
this.groupTagsExpanded(groups);
125+
}
116126
}
117127

118128
private async onRouteChange(): Promise<void> {

src/components/operations/operation-list/operationListContract.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ export interface OperationListContract extends Contract {
3131
*/
3232
defaultGroupByTagToEnabled?: boolean;
3333

34+
/**
35+
* Default to expand all GroupTags.
36+
*/
37+
defaultAllGroupTagsExpanded: boolean;
38+
3439
/**
3540
* Link to a page that contains operation details.
3641
*/

src/components/operations/operation-list/operationListModel.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ export class OperationListModel {
2727
*/
2828
public defaultGroupByTagToEnabled: boolean;
2929

30+
/**
31+
* Default to expand all GroupTags.
32+
*/
33+
public defaultAllGroupTagsExpanded: boolean;
34+
3035
/**
3136
* Link to a page that contains operation details.
3237
*/

src/components/operations/operation-list/operationListModelBinder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export class OperationListModelBinder implements IModelBinder<OperationListModel
1414
model.showToggleUrlPath = contract.showToggleUrlPath;
1515
model.defaultShowUrlPath = contract.defaultShowUrlPath;
1616
model.defaultGroupByTagToEnabled = contract.defaultGroupByTagToEnabled === true;
17+
model.defaultAllGroupTagsExpanded = contract.defaultAllGroupTagsExpanded === true;
1718
model.styles = contract.styles ?? {};
1819

1920
if (contract.detailsPageHyperlink) {
@@ -31,6 +32,7 @@ export class OperationListModelBinder implements IModelBinder<OperationListModel
3132
showToggleUrlPath: model.showToggleUrlPath,
3233
defaultShowUrlPath: model.defaultShowUrlPath,
3334
defaultGroupByTagToEnabled: model.defaultGroupByTagToEnabled,
35+
defaultAllGroupTagsExpanded: model.defaultAllGroupTagsExpanded,
3436
detailsPageHyperlink: model.detailsPageHyperlink
3537
? {
3638
target: model.detailsPageHyperlink.target,

0 commit comments

Comments
 (0)