Skip to content

feat: extract ScheduleManager IIFE module from JavaScript.html (Phase 1 PR6/7) - #150

Merged
cheerc merged 1 commit into
mainfrom
refactor/phase1-pr6-schedule-manager
Jun 24, 2026
Merged

feat: extract ScheduleManager IIFE module from JavaScript.html (Phase 1 PR6/7)#150
cheerc merged 1 commit into
mainfrom
refactor/phase1-pr6-schedule-manager

Conversation

@cheerc

@cheerc cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

What

Extract 11 schedule management methods from JavaScript.html into a new ScheduleManager.js.html IIFE module — the final PR of Phase 1 Wave B (#129).

After this PR, JavaScript.html contains only 3 methods: init, applyTagFilters, printScheduleToPdf.

Methods Extracted (11)

Method Type Notes
showFirstTimeScheduleSelector sync Modal + DOM
handleEditClassroom sync State + UI + history
loadInitialSchedules sync Routing logic
loadSchedule sync Core schedule loading, lock acquire/release
saveSchedulesToLocal sync One-liner localStorage
handleAddSchedule async ServerApi + state
handleScheduleListClick async Rename/delete/copy branches
handleScheduleSelectChange async Schedule switching + All Schedules view
isCurrentUserAdmin sync Trivial helper
canManageCurrentScheduleSettings sync Permission check
handleDrop sync Drag-and-drop reorder

How

  • Created ScheduleManager.js.html with IIFE pattern (function(App) { ... })(App)
  • Converted all this.xxxApp.xxx references
  • Added include in Index.html after DataIO.js, before App.init()
  • Updated 4 test files (see below)

Test Updates (⚠️ most test changes in Phase 1)

Test File Changes
appWiringContracts.test.js IIFE_EXTRACTED +11, EXTRACTED_TO_LIB emptied, NOT_EXTRACTABLE 8→3, count 14→3
syncMethodsWiring.test.js +scheduleManagerSource, method existence + wiring patterns (this→App)
asyncMethodsWiring.test.js +scheduleManagerSource, SCHEDULE_MANAGER_ASYNC_METHODS, resolveSource
lifecycleRegression.test.js +scheduleManagerSource, loadInitialSchedules + loadSchedule source + this→App

Scope (7 files)

  • ScheduleManager.js.html (new, 300+ lines)
  • JavaScript.html (removed 11 methods, only init + applyTagFilters + printScheduleToPdf remain)
  • Index.html (+1 include line)
  • tests/unit/appWiringContracts.test.js
  • tests/unit/syncMethodsWiring.test.js
  • tests/unit/asyncMethodsWiring.test.js
  • tests/unit/lifecycleRegression.test.js

Verification

  • npm test: 1147 tests passed (36 files) ✅
  • npx eslint --ext .html .: 0 errors (8 pre-existing warnings) ✅
  • bash scripts/check-structure.sh: all present
  • Scope gate: only expected 7 files changed ✅

refs #129

…odule

Extract showFirstTimeScheduleSelector, handleEditClassroom, loadInitialSchedules,
loadSchedule, saveSchedulesToLocal, handleAddSchedule, handleScheduleListClick,
handleScheduleSelectChange, isCurrentUserAdmin, canManageCurrentScheduleSettings,
and handleDrop from JavaScript.html into ScheduleManager.js.html IIFE module.

JavaScript.html now contains only: init, applyTagFilters, printScheduleToPdf (3 methods).

Convert all this.xxx references to App.xxx. Update 4 test files:
- appWiringContracts: IIFE_EXTRACTED +11, empty EXTRACTED_TO_LIB, count 14→3
- syncMethodsWiring: scheduleManagerSource + App\. patterns
- asyncMethodsWiring: SCHEDULE_MANAGER_ASYNC_METHODS + resolveSource
- lifecycleRegression: scheduleManagerSource + App\. patterns

All 1147 tests pass. ESLint 0 errors.

refs #129
Closes t-20260624080352928153-40473-17

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

Agend-Agent: cb-team-impl
Agend-Task: t-20260624080352928153-40473-17
Agend-Branch: refactor/phase1-pr6-schedule-manager
Agend-Issued-At: 2026-06-24T08:04:56.217587+00:00
@cheerc

cheerc commented Jun 24, 2026

Copy link
Copy Markdown
Owner Author

✅ VERIFIED

Reviewed HEAD: 5ad8508efa9aa6acfa94eff32450cd923402e6dd
Reviewer: cb-team-reviewer
Audit mode: standard (D2, blast_radius: caller-scan)

Files Reviewed (7)

  • ScheduleManager.js.html (new, +405) — IIFE module with 11 extracted methods
  • JavaScript.html (-372) — only init, applyTagFilters, printScheduleToPdf remain
  • Index.html (+1) — include after DataIO.js, before App.init()
  • tests/unit/appWiringContracts.test.js — IIFE_EXTRACTED +11, EXTRACTED_TO_LIB emptied, NOT_EXTRACTABLE 8→3, count 14→3
  • tests/unit/syncMethodsWiring.test.js — +scheduleManagerSource, this→App patterns
  • tests/unit/asyncMethodsWiring.test.js — SCHEDULE_MANAGER_ASYNC_METHODS, resolveSource
  • tests/unit/lifecycleRegression.test.js — scheduleManagerSource, this→App patterns

Stage 1 — Correctness

  • All 11 methods correctly extracted with thisApp conversion (0 residual this.)
  • IIFE pattern (function(App) { ... })(App) consistent with PR1-PR5
  • Load order: DataIO → ScheduleManagerApp.init()
  • JavaScript.html correctly reduced to 3 methods (init, applyTagFilters, printScheduleToPdf)
  • Cross-module callers verified:
    • Interaction.js.html: 5 callers via app.xxx (captured ref) ✓
    • DataIO.js.html: 3 callers via App.xxx (circular dep, runtime resolution) ✓
    • UI.js.html: 1 caller app.handleDrop
  • Test count: 48 - 7(PR1) - 4(PR2) - 11(PR3) - 7(PR4) - 5(PR5) - 11(PR6) = 3 ✓
  • EXTRACTED_TO_LIB correctly emptied (Phase 1 complete)
  • NOT_EXTRACTABLE correctly reduced: init, applyTagFilters, printScheduleToPdf
  • async methods: 3 moved to SCHEDULE_MANAGER_ASYNC_METHODS, resolveSource updated
  • lifecycleRegression: loadInitialSchedules + loadSchedule source + all this\\.App\\. patterns
  • No conflict markers (all 7 files clean)

Stage 2 — Adversarial

  • handleScheduleSelectChange All Schedules view: cross-module calls (DataCollection, FilterEngine) resolve at runtime ✓
  • loadSchedule lock management: acquireLock/releaseLock correctly via App.xxx ✓
  • handleDrop optional chaining preserved (App.scheduleData[fromClassroom]?.[fromDay]) ✓
  • Circular dependency DataIO↔ScheduleManager safe (runtime App.xxx calls, not load-time) ✓
  • No scope leak from IIFE wrapper ✓

REVIEWER.md Accessibility Test (F2 action item)

Path accessible: /Users/cheerc/agend-customization/dispatch_books/classroombooking/REVIEWER.md — readable (6534 bytes). Previous sessions failed due to find within workspace root only; the file is outside the workspace at /Users/cheerc/agend-customization/.

graphify skip rationale

Skipped — diff is mechanical IIFE extraction (blast_radius: caller-scan), grep sufficient for caller verification. No architecture exploration needed.

Evidence

  • ran: gh pr checks 150 → validate: SUCCESS (via CI-ready signal)
  • ran: grep this\\. ScheduleManager.js.html → No this. references found
  • ran: conflict marker scan (7 files) → all 0
  • ran: grep callers in Interaction.js.html → 5 references
  • ran: grep callers in DataIO.js.html → 5 references (circular dep)
  • ran: grep callers in UI.js.html → 1 reference (handleDrop)
  • ran: grep remaining methods in JavaScript.html → 3 (init, applyTagFilters, printScheduleToPdf)
  • cited: ScheduleManager.js.html:19 — (function(App) { (IIFE entry)
  • cited: ScheduleManager.js.html:405 — })(App); (IIFE closure)
  • cited: Index.html:481 — ScheduleManager.js after DataIO.js
  • cited: appWiringContracts.test.js:130 — expect(publicMethods.length).toBe(3)

@cheerc
cheerc merged commit bbe1bce into main Jun 24, 2026
1 check passed
@cheerc
cheerc deleted the refactor/phase1-pr6-schedule-manager branch June 24, 2026 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant