Skip to content
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

Tab adjustments: Sort the translated optionlist #3152

Merged
merged 4 commits into from
Dec 28, 2022

Conversation

HThuren
Copy link
Member

@HThuren HThuren commented Dec 17, 2022

When the optionlist are translated to non english, the order was chaotic, now ordered by lexcial sort of translated text

@github-actions

This comment has been minimized.

@blckmn
Copy link
Member

blckmn commented Dec 17, 2022

AUTOMERGE: (FAIL)

  • github identifies PR as mergeable -> FAIL
  • assigned to a milestone -> PASS
  • cooling off period lapsed -> PASS
  • commit count less or equal to three -> FAIL
  • Don't merge label NOT found -> PASS
  • at least one RN: label found -> PASS
  • Tested label found -> FAIL
  • assigned to an approver -> FAIL
  • approver count at least three -> FAIL

haslinghuis
haslinghuis previously approved these changes Dec 17, 2022
@github-actions

This comment has been minimized.

@@ -286,6 +286,14 @@ adjustments.cleanup = function (callback) {
if (callback) callback();
};

$.fn.sortSelect = function() {
const op = this.children("option");
op.sort(function(a, b) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's better to use a locale compare to be sure to order them correctly in any language? For example like here:

if ($(this).text().localeCompare(field.text(), currentLocale, { sensitivity: 'base' }) > 0) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, I give it a try

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also make it into a common util function as we might need it in other places.

@haslinghuis haslinghuis dismissed their stale review December 23, 2022 01:11

Changes requested.

blckmn
blckmn previously requested changes Dec 26, 2022
Copy link
Member

@blckmn blckmn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the other reviewers, any chance this can be done as locale specific and in a common function?

@HThuren
Copy link
Member Author

HThuren commented Dec 26, 2022

As per the other reviewers, any chance this can be done as locale specific and in a common function?

I'll stiil want to give it a try, but had recently spent som time at an EdgeTx PR :-)

@haslinghuis
Copy link
Member

@HThuren see #3167

Have changed the sortSelect function into a common function using a value to stay on top while sorting.

When it's merged you only have to remove the local function and change the call selectFunction.sortSelect(); to

selectFunction.sortSelect(i18n.getMessage("adjustmentsFunction0");

to keep No Changes on top of the list.

@sonarcloud
Copy link

sonarcloud bot commented Dec 27, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@github-actions
Copy link
Contributor

Do you want to test this code? Here you have an automated build:
Betaflight-Configurator-Android
Betaflight-Configurator-Linux
Betaflight-Configurator-macOS
Betaflight-Configurator-Windows
WARNING: It may be unstable and result in corrupted configurations or data loss. Use only for testing!

@HThuren
Copy link
Member Author

HThuren commented Dec 27, 2022

@haslinghuis, thank you for #3167, I was in fact stucked in try to use sortElement with language sort, but that spoiled the sort used in other places (as you now have changed).
Also great to see your handling with a.text.localeCompare(b.text, window.navigator.language, { ignorePunctiaton: true }); ! :-)

@HThuren
Copy link
Member Author

HThuren commented Dec 27, 2022

By the way, this PR require #3167

@HThuren HThuren requested a review from blckmn December 27, 2022 14:02
Copy link
Member

@McGiverGim McGiverGim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved, but waiting for the other PR to be merged.

@haslinghuis haslinghuis merged commit 704970e into betaflight:master Dec 28, 2022
@HThuren
Copy link
Member Author

HThuren commented Dec 28, 2022

Thank you

@HThuren HThuren deleted the sortAdjustmentTable branch December 28, 2022 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants