-
Notifications
You must be signed in to change notification settings - Fork 273
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
fix(ui5-view-settings-dialog): improve the options returned by the confurn event #4772
Changes from 4 commits
8f1022c
630434d
1c402b5
2aeb0f2
8516301
45ba71b
09ab9c5
e71f371
ed452cd
327e533
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 |
---|---|---|
|
@@ -404,6 +404,7 @@ class ViewSettingsDialog extends UI5Element { | |
return { | ||
text: item.text, | ||
selected: item.selected, | ||
associatedItem: item, | ||
}; | ||
}); | ||
} | ||
|
@@ -412,11 +413,11 @@ class ViewSettingsDialog extends UI5Element { | |
return [ | ||
{ | ||
text: this._ascendingLabel, | ||
selected: true, | ||
selected: !this.sortDescending, | ||
}, | ||
{ | ||
text: this._descendingLabel, | ||
selected: false, | ||
selected: this.sortDescending, | ||
}, | ||
]; | ||
} | ||
|
@@ -548,11 +549,14 @@ class ViewSettingsDialog extends UI5Element { | |
const _currentSortOrderSelected = this._currentSettings.sortOrder.filter(item => item.selected)[0], | ||
_currentSortBySelected = this._currentSettings.sortBy.filter(item => item.selected)[0], | ||
sortOrder = _currentSortOrderSelected && _currentSortOrderSelected.text, | ||
sortBy = _currentSortBySelected && _currentSortBySelected.text; | ||
|
||
sortDescending = !this._currentSettings.sortOrder[0].selected, | ||
sortBy = _currentSortBySelected && _currentSortBySelected.text, | ||
sortByItem = sortBy && this.initSortByItems.filter(item => item.text === sortBy)[0].associatedItem; | ||
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. Just to make sure I won't overlook something. What will happen if the app developer uses two sort items with the same name (although does not make sense). this.initSortByItems.filter(item => item.text === sortBy)[0].associatedItem; Discovering the associated item by filtering the sort items by text does not seem robust. Check it out and if it fails as described above, please create a separate issue, so that this is improved in future or you can try fixing it here. One way or another, you can see a solution pattern in the Shellbar.js/ShellBar.hbs where const sortByItem = this.initSortByItems.find(item => {
return item._id === refItemId;
}); 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. IMO using the same named Sort Items is not a good idea in general... |
||
return { | ||
sortOrder, | ||
sortDescending, | ||
sortBy, | ||
sortByItem, | ||
filters: this.selectedFilters, | ||
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. 'confirm' and 'cancel' events 'detail' description don't inlcude newly added 'sortDescending' and 'sortByItem' properties, please fix this! |
||
}; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,11 +88,20 @@ <h3> ViewSettingsDialog</h3> | |
</ui5-filter-item> | ||
</ui5-view-settings-dialog> | ||
|
||
<br> | ||
<br> | ||
<ui5-input id="sortByItem" style="display: none"></ui5-input> | ||
<ui5-input id="sortOrder" style="display: none"></ui5-input> | ||
|
||
<script> | ||
btnOpenDialog.addEventListener("click", function () { | ||
vsd.show(); | ||
}); | ||
vsd.addEventListener("confirm", function(evt) { | ||
vsd.addEventListener("ui5-confirm", function(evt) { | ||
const sortByItemTagName = evt.detail.sortByItem && evt.detail.sortByItem.tagName; | ||
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. Let's stick to es5 for the moment as we do everywhere in the test pages I think |
||
const isSortDescending = evt.detail.sortDescending; | ||
sortByItem.value = `${sortByItemTagName} with text ${evt.detail.sortBy}`; | ||
sortOrder.value = isSortDescending; | ||
alert("OK button clicked, returned info is: " + JSON.stringify(evt.detail)); | ||
}); | ||
btnOpenDialogSort.addEventListener("click", function () { | ||
|
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.
Is "item2" an existing field, somehow did not find it in the change?
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.
yes, I forgot to delete it