-
Notifications
You must be signed in to change notification settings - Fork 263
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-filter-item, ui5-sort-item,..): add filterItems
to ui5-confirm
event details
#9838
base: main
Are you sure you want to change the base?
Changes from 7 commits
78a3dd7
ab2b240
e4e1f81
59c0812
6ccbf80
ab08238
a04afc3
9aeefa8
122495d
9bff115
0a56a65
602adc0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ type ViewSettingsDialogCancelEventDetail = VSDSettings & { | |
} | ||
|
||
// Common properties for several VSDInternalSettings fields | ||
type VSDItem = {text?: string, selected: boolean} | ||
type VSDItem = {text?: string, itemKey?: string, selected: boolean} | ||
|
||
// Used for the private properties _initialSettings, _confirmedSettings and _currentSettings | ||
type VSDInternalSettings = { | ||
|
@@ -75,6 +75,12 @@ type VSDInternalSettings = { | |
filters: Array<VSDItem & {filterOptions: Array<VSDItem>}>, | ||
} | ||
|
||
type FilterSelection = { | ||
filterItem: VSDItem & { | ||
filterOptions: Array<VSDItem>; | ||
}; | ||
}; | ||
|
||
/** | ||
* @class | ||
* ### Overview | ||
|
@@ -447,10 +453,12 @@ class ViewSettingsDialog extends UI5Element { | |
filters: this.filterItems.map(item => { | ||
return { | ||
text: item.text || "", | ||
itemKey: item.itemKey || "", | ||
selected: false, | ||
filterOptions: item.values.map(optionValue => { | ||
return { | ||
text: optionValue.text || "", | ||
itemKey: optionValue.itemKey || "", | ||
selected: optionValue.selected, | ||
}; | ||
}), | ||
|
@@ -624,6 +632,7 @@ class ViewSettingsDialog extends UI5Element { | |
sortBy, | ||
sortByItem, | ||
filters: this.selectedFilters, | ||
filterItems: this.selectedFilterItems, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this new field really necessary? Can't the app do this if they need such information? Or is this code required by the control somewhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The app cannot do this themself because until now we only return the text of the provided filters in the details, therefore we would have to provide the |
||
}; | ||
} | ||
|
||
|
@@ -648,6 +657,30 @@ class ViewSettingsDialog extends UI5Element { | |
return result; | ||
} | ||
|
||
get selectedFilterItems() { | ||
const result: Array<FilterSelection> = []; | ||
|
||
this._currentSettings.filters.forEach(filter => { | ||
const selectedOptions: Array<VSDItem> = []; | ||
|
||
filter.filterOptions.forEach(option => { | ||
if (option.selected) { | ||
selectedOptions.push(option); | ||
} | ||
}); | ||
|
||
if (selectedOptions.length) { | ||
const filterItemObject: FilterSelection = { | ||
filterItem: filter, | ||
}; | ||
|
||
result.push(filterItemObject); | ||
} | ||
}); | ||
|
||
return result; | ||
} | ||
|
||
/** | ||
* If the dialog is closed by [Escape] key, do the same as if the `Cancel` button is pressed. | ||
* @param evt | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change to:
item: optionValue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe I can even remove that line, as we can just return the slotted
filterItems
in theget eventsParams()
. This way the app developers could execute their own logic for filtering the selected items based on their HTML Property they have provided (f.edata-key
);