- Replace hardcoded position strings with POSITIONS.* constants - Prefix unused variables with _ to resolve no-unused-vars warnings - Fix no-prototype-builtins with Object.prototype.hasOwnProperty.call() - Extract menuUtils.js (543 lines) into 6 focused modules under menu/ - menuUtils.js now 35 lines, delegates via prototype mixin pattern - Add 158 unit tests for ConfigManager, MeasurementContainer, ValidationUtils Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
35 lines
965 B
JavaScript
35 lines
965 B
JavaScript
/**
|
|
* MenuUtils — UI menu helper for Node-RED editor.
|
|
* Methods are split across focused modules under ./menu/ and mixed onto the prototype.
|
|
*/
|
|
|
|
const toggles = require('./menu/toggles');
|
|
const dataFetching = require('./menu/dataFetching');
|
|
const urlUtils = require('./menu/urlUtils');
|
|
const dropdownPopulation = require('./menu/dropdownPopulation');
|
|
const htmlGeneration = require('./menu/htmlGeneration');
|
|
|
|
class MenuUtils {
|
|
constructor() {
|
|
this.isCloud = false;
|
|
this.configData = null;
|
|
}
|
|
}
|
|
|
|
// Mix all method groups onto the prototype
|
|
const mixins = [toggles, dataFetching, urlUtils, dropdownPopulation, htmlGeneration];
|
|
for (const mixin of mixins) {
|
|
for (const [name, fn] of Object.entries(mixin)) {
|
|
if (typeof fn === 'function') {
|
|
Object.defineProperty(MenuUtils.prototype, name, {
|
|
value: fn,
|
|
writable: true,
|
|
configurable: true,
|
|
enumerable: false,
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = MenuUtils;
|