From f2ae480694243d55413b16b1ed41ba5ec849373a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 2 Nov 2024 16:47:56 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20[2.1.59]=20Fix=20undef=20handlin?= =?UTF-8?q?g,=20use=20checkbox=20group?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 6 ++ abm/js/editview.js | 63 ++++++------- abm/js/schema.js | 217 +++++++++++++++++++++++++++++++++------------ package.json | 2 +- 4 files changed, 200 insertions(+), 88 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8cfc7c..59f3959 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ The following enhancements and changes have been made to ***Auto Build Marlin***. +## 2.1.59 +- Fix handling of #undef +- Identify macro defines +- Use checkbox groups for optional items +- Add checkbox groups for like-named items + ## 2.1.58 - Fix filtering options by axis - Implement radio grouping for LCD items diff --git a/abm/js/editview.js b/abm/js/editview.js index 35e2de5..2138210 100755 --- a/abm/js/editview.js +++ b/abm/js/editview.js @@ -229,31 +229,19 @@ $(function () { * @param {dict} fields - The fields to replace in the option. */ function commitChange(optref, fields) { - // Mark fields as dirty - fields.dirty = true; + // Assign new field values to the option reference + Object.assign(optref, fields); - // Save original values if not already marked as dirty - if (optref.dirty === undefined || optref.dirty == false) { - optref.orig = { value: optref.value, enabled: optref.enabled }; - } - // Reset dirty flag if values are unchanged - else if ( (fields.value === undefined || optref.orig.value == fields.value) - && (fields.enabled === undefined || optref.orig.enabled == fields.enabled) - ) { - fields.dirty = false; - delete optref.orig; - } + // Is the value / enabled state different from the original? + const dirty = optref.orig.enabled != optref.enabled || (optref.value !== undefined && optref.orig.value != optref.value); + optref.dirty = dirty; // Log and update UI - log(`Setting Dirty flag: ${fields.dirty}`); - $(`div.line.sid-${optref.sid}`).toggleClass('dirty', fields.dirty); + log("commitChange", [ optref, fields ]); + $(`div.line.sid-${optref.sid}`).toggleClass('dirty', dirty); - // Assign new field values to the option reference - Object.assign(optref, fields); - log("Updated Option:", [ optref, fields ]); - - // Refresh UI and state - schema.refreshRequiresAfter(optref.sid); + // Refresh UI and state) + schema.refreshRequiresAfter(optref.name == 'EXTRUDERS' ? 1 : optref.sid); refreshVisibleItems(); saveWebViewState(); @@ -294,10 +282,28 @@ $(function () { //! @brief Handle a checkbox change event. function handleCheckbox(e) { - console.log("handleCheckbox", e); applyEnableCheckbox($(e.target)); } + //! @brief Handle a checkbox event in a mutual-exclusive group. + function handleCheckboxGroup(e) { + start_multi_update(); + + const cb = e.target, $cb = $(cb), // The checkbox. + $sdiv = $('div.section-inner'), // Some groups cross sections + clas = $cb.prop('class'); + + $sdiv.find(`.${clas}:checked`).each(function(i,o) { + if (o === cb) return; + const $acb = $(o); + $acb.prop('checked', false); + applyEnableCheckbox($acb); + }); + applyEnableCheckbox($cb); + + end_multi_update(); + } + //! @brief Handle enabling an item in a mutual-exclusive "radio button" group. function handleRadioGroup(e) { start_multi_update(); @@ -522,7 +528,7 @@ $(function () { * @param {item} data : An option to add to the form * @param {jquery} $inner : The element to append to */ - const option_defaults = { type: '', value: '', options: '', depth: 0, dirty: false, evaled: true }; + const option_defaults = { type: '', value: '', options: '', group: '', depth: 0, dirty: false, evaled: true }; function addOptionLine(data, $inner) { // Add defaults for missing fields const item = { ...option_defaults, ...data }; @@ -539,15 +545,10 @@ $(function () { // Prepare the div, label, label text, and option enable checkbox / radio const $linediv = $("
", { id: `-${name.toID()}-${item.sid}`, class: `line sid-${item.sid}` }), $linelabel = $("