Skip to content

Refactor var to const/let in UI rendering files (3/4)#3302

Merged
Mips2648 merged 1 commit into
jeedom:developfrom
limad:refactor/var-to-const-ui
May 5, 2026
Merged

Refactor var to const/let in UI rendering files (3/4)#3302
Mips2648 merged 1 commit into
jeedom:developfrom
limad:refactor/var-to-const-ui

Conversation

@limad
Copy link
Copy Markdown
Contributor

@limad limad commented Apr 28, 2026

Summary

Third of four migration PRs splitting #3297 by functional domain. This batch covers 7 files handling UI rendering (views, plans, timeline, history charts, widgets, plugin templates):

view.class.js    plan.class.js     plan3d.class.js
timeline.class.js   history.class.js     widgets.class.js
plugin.template.js

Incidental fixes (caught during migration)

  • history.class.jsvar series was declared in two mutually-exclusive if/else blocks (if (data.result.timelineOnly) { var series = {...} } else { var series = {...} }) but referenced in code located after the block (in addSeries(series) calls, in chart config object, etc.). With var, function-scoped hoisting unified the two declarations and made the reference work. Migrated to const/let, it became block-scoped and threw ReferenceError: series is not defined. Fix: hoisted to a single let series declared before the if/else, with assignments in each branch.
  • plugin.template.jsconst eqLogic at line 300 was reassigned at line 311 by eqLogic = saveEqLogic(eqLogic). Changed to let eqLogic to avoid TypeError: Assignment to constant variable on equipment save flow.

Test plan

  • Open the History page and select a command — verify charts render
  • Toggle the History 'compare' mode — verify both series render correctly (this is the path that exercises the series hoist fix)
  • Open a View page that contains a graph zone — verify rendering and data-option attributes are populated
  • Open a 2D Plan and a 3D Plan if you have them — verify display
  • Open the Timeline page — verify timeline renders
  • Open a plugin equipment, modify a setting, click 'Sauvegarder' — verify save flow (this is the path that exercises the eqLogic const→let fix)

Part of the split following #3297 discussion.

Migration of `var` declarations to `const`/`let` in 7 files handling
UI rendering: view, plan, plan3d, timeline, history, widgets,
plugin.template.

Also includes incidental fixes that surfaced during the migration:
- history.class.js: hoisted `series` out of mutually-exclusive
  if/else blocks. With `var`, hoisting made it visible after the
  block (used in addSeries() and chart config). With `const` it
  would throw "ReferenceError: series is not defined".
- plugin.template.js: changed `const eqLogic` to `let eqLogic` in
  saveEqLogic flow — the variable was reassigned by `eqLogic =
  saveEqLogic(eqLogic)` and would trigger
  "TypeError: Assignment to constant variable".
@Mips2648 Mips2648 added the changelog-dev Use to generate release notes / changelog To be apply on PR label May 5, 2026
@Mips2648 Mips2648 merged commit d734ecb into jeedom:develop May 5, 2026
9 checks passed
@Mips2648 Mips2648 added changelog-other Use to generate release notes and removed changelog-dev Use to generate release notes / changelog To be apply on PR labels May 6, 2026
@Mips2648 Mips2648 added this to the 4.6 milestone May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-other Use to generate release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants