Skip to content

Commit 1d98d20

Browse files
committed
🚸 [2.1.84] Preserve button selection
1 parent e253c36 commit 1d98d20

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
The following enhancements and changes have been made to ***Auto Build Marlin***.
44

5+
## 2.1.84
6+
- Config Editor: Keep buttons selected after refresh on value change
7+
- Config Editor: Full refresh for non-contiguous implicit and later dependencies
8+
- Schema: Extend the list of extruder-dependent config options
9+
510
## 2.1.83
611
- Config Editor: Show filter in sections sidebar
712
- Schema: Update temp-sensor-dependent config options, add comments

abm/js/editview.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -275,10 +275,16 @@ $(function () {
275275
log("commitChange", [ optref, fields ]);
276276
$(`div.line.sid-${optref.sid}`).toggleClass('dirty', dirty);
277277

278-
// Refresh UI and state
279-
//schema.refreshAllRequires();
280-
schema.refreshRequiresAfter(optref.sid);
278+
// Refresh UI and state. Refresh All if the option can affect earlier things.
279+
// Otherwise just refresh those that follow it.
280+
if (['EXTRUDERS'].includes(optref.name))
281+
schema.refreshAllRequires();
282+
else
283+
schema.refreshRequiresAfter(optref.sid);
284+
285+
// Now refresh the UI based on the updated evaluated states.
281286
refreshVisibleItems();
287+
// Save the web view state for VSCode restoration later.
282288
saveWebViewState();
283289

284290
// This update should be ignored when it triggers onDidChangeTextDocument
@@ -520,16 +526,18 @@ $(function () {
520526
var allbutton_title = '⭐️ ALL';
521527

522528
// Refresh nav buttons for the form's unfiltered sections
523-
// TODO: Preserve selection if the section is still visible
524-
// and only then stay on ALL. Then show() all sections
525-
// so the ".hide" class can take precedence.
526529
function refreshNavButtons($inform=$form) {
527530
const $nav = $('#left-nav');
531+
532+
// Get the active button, if any, to re-activate after refresh.
533+
const $active = $nav.find('button.active'),
534+
activeid = $active.length > 0 ? $active.attr('id') : 'button-all';
535+
528536
$nav.empty();
529537
const $sects = $inform.find('fieldset.section:not(.hide)');
530538

531539
// All button shows all the sections with direct styling.
532-
const $allbutton = $('<button id="all-button" class="active"></button>').text(allbutton_title);
540+
const $allbutton = $('<button id="button-all" class="active"></button>').text(allbutton_title);
533541
$allbutton.click((e) => {
534542
$(e.target).addClass('active').siblings().removeClass('active');
535543
$sects.show();
@@ -539,10 +547,9 @@ $(function () {
539547
// Other buttons one section, with direct styling.
540548
for (const sect of $sects) {
541549
const $sect = $(sect),
550+
sectid = $sect[0].classList[1],
542551
title = $sect.find('legend span.section-title').text(),
543-
$button = $(`<button>${title}</button>`);
544-
545-
const sectid = $sect[0].classList[1];
552+
$button = $(`<button id="button-${sectid}">${title}</button>`);
546553

547554
// Bind the button on click to hide all other sections but its own.
548555
$button.click((e) => {
@@ -553,6 +560,9 @@ $(function () {
553560
});
554561
$nav.append($button);
555562
}
563+
564+
// Re-activate the previous active button by simulating a click on the button
565+
$(`#${activeid}`).trigger('click');
556566
}
557567

558568
/**

abm/js/schema.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ class ConfigSchema {
560560
'SINGLENOZZLE',
561561
'DUAL_X_CARRIAGE',
562562
'PARKING_EXTRUDER', 'MAGNETIC_PARKING_EXTRUDER',
563-
'SWITCHING_TOOLHEAD', 'MAGNETIC_SWITCHING_TOOLHEAD', 'ELECTROMAGNETIC_SWITCHING_TOOLHEAD'
563+
'SWITCHING_TOOLHEAD', 'MAGNETIC_SWITCHING_TOOLHEAD', 'ELECTROMAGNETIC_SWITCHING_TOOLHEAD',
564+
'MIXING_EXTRUDER'
564565
],
565566

566567
// Axis Homing Submenus
@@ -736,11 +737,11 @@ class ConfigSchema {
736737
}
737738

738739
// The item is enabled by its E < EXTRUDERS.
739-
function HAS_EAXIS(eindex) {
740+
function HAS_EAXIS(eindex, name=null) {
740741
const extruders = priorItemNamed('EXTRUDERS') || priorItemNamed('EXTRUDERS', Infinity);
741742
if (extruders == null) return false;
742743
const stat = eindex < extruders.value;
743-
//console.log(`HAS_EAXIS(${eindex}) == ${stat ? 'true' : 'false'}`, extruders);
744+
//console.log(`HAS_EAXIS(${eindex}, ${name}) == ${stat ? 'true' : 'false'}`, extruders);
744745
return stat;
745746
}
746747

@@ -1022,6 +1023,7 @@ class ConfigSchema {
10221023
}
10231024

10241025
// Refresh all requires that follow a changed item.
1026+
// TODO: Add a flag for items whose visibility in the UI depends on a later item (like En_DRIVER_TYPE depending on EXTRUDERS).
10251027
refreshRequiresAfter(after) {
10261028
for (const item of this.iterateDataBySID(after + 1)) delete item.evaled;
10271029
for (const item of this.iterateDataBySID(after + 1)) this.evaluateRequires(item);
@@ -1619,10 +1621,24 @@ class ConfigSchema {
16191621
|| name.match(/^TEMP_SENSOR_(\d)$/)
16201622
|| name.match(/^FIL_RUNOUT(\d)_(STATE|PULL(UP|DOWN))$/);
16211623
if (m1) return m1[1];
1622-
if (['DISABLE_IDLE_E', 'STEP_STATE_E', 'NOZZLE_PARK_FEATURE', 'NOZZLE_CLEAN_FEATURE'].includes(name)) return '0';
1624+
if ([
1625+
'STEP_STATE_E','DEFAULT_NOMINAL_FILAMENT_DIA',
1626+
'SINGLENOZZLE','SWITCHING_EXTRUDER','MECHANICAL_SWITCHING_EXTRUDER',
1627+
'SWITCHING_NOZZLE','MECHANICAL_SWITCHING_NOZZLE',
1628+
'PARKING_EXTRUDER','MAGNETIC_PARKING_EXTRUDER',
1629+
'DIFFERENTIAL_EXTRUDER',
1630+
'SWITCHING_TOOLHEAD','MAGNETIC_SWITCHING_TOOLHEAD','ELECTROMAGNETIC_SWITCHING_TOOLHEAD',
1631+
'MIXING_EXTRUDER',
1632+
'HOTEND_OFFSET_X','HOTEND_OFFSET_Y','HOTEND_OFFSET_Z',
1633+
'DISABLE_IDLE_E','DISABLE_E','DISABLE_OTHER_EXTRUDERS',
1634+
'NOZZLE_PARK_FEATURE','NOZZLE_CLEAN_FEATURE',
1635+
'DISTINCT_E_FACTORS','DEFAULT_RETRACT_ACCELERATION',
1636+
'PIDTEMP','MPCTEMP','BANG_MAX'
1637+
].includes(name)) return '0';
16231638
}
16241639

16251640
// Items that depend on *_DRIVER_TYPE to be enabled.
1641+
// Return the part of the given 'name' that matches an axis name, for use in test conditions.
16261642
function is_axis_item(name) {
16271643
const m1 = name.match(/^([XYZIJKUVW]\d?)_(CHAIN_POS|CS_PIN|CURRENT(_HOME)?|ENABLE_ON|HOLD_MULTIPLIER|HOME_DIR|HYBRID_THRESHOLD|INTERPOLATE|MAX_CURRENT|M(AX|IN)_ENDSTOP_(INVERTING|HIT_STATE)|M(AX|IN)_POS|MICROSTEPS|RSENSE|SAFETY_STOP|SENSE_RESISTOR|SLAVE_ADDRESS|STALL_SENSITIVITY)$/)
16281644
|| name.match(/^(?:CHOPPER_TIMING|DISABLE(?:_INACTIVE|_IDLE)?|M(?:AX|IN)_SOFTWARE_ENDSTOP|SAFE_BED_LEVELING_START|STEALTHCHOP|STEP_STATE)_([XYZIJKUVW]\d?)$/)
@@ -1660,7 +1676,7 @@ class ConfigSchema {
16601676
extend_requires(`HAS_AXIS(${axis})`);
16611677
define_info.requires = define_info.requires.replace(` && defined(${axis}_DRIVER_TYPE)`, '');
16621678
}
1663-
if (eindex) extend_requires(`HAS_EAXIS(${eindex})`);
1679+
if (eindex) extend_requires(`HAS_EAXIS(${eindex}, ${define_name})`);
16641680
if (hindex) extend_requires(`HAS_SENSOR(${hindex})`);
16651681
if (tindex) extend_requires(`ANY_THERMISTOR_IS(${tindex})`);
16661682
if (sindex) extend_requires(`HAS_SERIAL(${sindex})`);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "auto-build",
33
"displayName": "Auto Build Marlin",
44
"description": "Provides an interface to configure, build, and upload Marlin Firmware.",
5-
"version": "2.1.83",
5+
"version": "2.1.84",
66
"preview": false,
77
"publisher": "marlinfirmware",
88
"icon": "icon.png",

0 commit comments

Comments
 (0)