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

Sort of 3 optionlist at failsafe tab #3211

Merged
merged 1 commit into from
Jan 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/js/tabs/failsafe.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ failsafe.initialize = function (callback) {
break;
}

// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
$('#failsafeSwitchSelect').sortSelect();
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
$('#failsafeSwitchSelect').sortSelect();
$('select[name="failsafe_switch_mode"]').sortSelect();


// `failsafe_kill_switch` has been renamed to `failsafe_switch_mode`.
// It is backwards compatible with `failsafe_kill_switch`
$('select[name="failsafe_switch_mode"]').val(FC.FAILSAFE_CONFIG.failsafe_switch_mode);
Expand All @@ -265,8 +268,13 @@ failsafe.initialize = function (callback) {
$('input[name="gps_rescue_throttle_max"]').val(FC.GPS_RESCUE.throttleMax);
$('input[name="gps_rescue_throttle_hover"]').val(FC.GPS_RESCUE.throttleHover);
$('input[name="gps_rescue_min_sats"]').val(FC.GPS_RESCUE.minSats);
// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
$('#failsafeGpsRescueItemSanitySelect').sortSelect();
Copy link
Member

Choose a reason for hiding this comment

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

Could we follow similar patter to above of using name instead of id? so we don't need extra property to keep in sync and this would look like:

Suggested change
$('#failsafeGpsRescueItemSanitySelect').sortSelect();
$('select[name"gps_rescue_sanity_checks"]').sortSelect();

$('select[name="gps_rescue_sanity_checks"]').val(FC.GPS_RESCUE.sanityChecks);

// Sort the element, if need to group, do it by lexical sort, ie. by naming of (the translated) selection text
$('#failsafeGpsRescueItemAltitudeSelect').sortSelect();

if (semver.gte(FC.CONFIG.apiVersion, API_VERSION_1_43)) {
$('input[name="gps_rescue_ascend_rate"]').val((FC.GPS_RESCUE.ascendRate / 100).toFixed(2));
$('input[name="gps_rescue_descend_rate"]').val((FC.GPS_RESCUE.descendRate / 100).toFixed(2));
Expand Down
6 changes: 3 additions & 3 deletions src/tabs/failsafe.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="spacer_box">
<div class="number">
<label>
<select class="switchMode" name="failsafe_switch_mode">
<select id="failsafeSwitchSelect" class="switchMode" name="failsafe_switch_mode">
Copy link
Member

Choose a reason for hiding this comment

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

We don't need special ids for this. In general name is a good unique property and is required for accesibility etc.

Suggested change
<select id="failsafeSwitchSelect" class="switchMode" name="failsafe_switch_mode">
<select class="switchMode" name="failsafe_switch_mode">

<option value="0" i18n="failsafeSwitchOptionStage1"></option>
<option value="2" i18n="failsafeSwitchOptionStage2"></option>
<option value="1" i18n="failsafeSwitchOptionKill"></option>
Expand Down Expand Up @@ -181,7 +181,7 @@
</div>
<div class="number">
<label>
<select class="switchMode" name="gps_rescue_altitude_mode">
<select id="failsafeGpsRescueItemAltitudeSelect" class="switchMode" name="gps_rescue_altitude_mode">
<option value="0" i18n="failsafeGpsRescueItemAltitudeModeMaxAlt"></option>
<option value="1" i18n="failsafeGpsRescueItemAltitudeModeFixedAlt"></option>
<option value="2" i18n="failsafeGpsRescueItemAltitudeModeCurrentAlt"></option>
Expand All @@ -191,7 +191,7 @@
</div>
<div class="number">
<label>
<select class="switchMode" name="gps_rescue_sanity_checks">
<select id="failsafeGpsRescueItemSanitySelect" class="switchMode" name="gps_rescue_sanity_checks">
<option value="0" i18n="failsafeGpsRescueItemSanityChecksOff"></option>
<option value="1" i18n="failsafeGpsRescueItemSanityChecksOn"></option>
<option value="2" i18n="failsafeGpsRescueItemSanityChecksFSOnly"></option>
Expand Down