Skip to content

refactor: extract populateEditorFields to eliminate duplicated form setup#195

Open
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-79
Open

refactor: extract populateEditorFields to eliminate duplicated form setup#195
JuliaKalder wants to merge 1 commit into
mainfrom
fix/issue-79

Conversation

@JuliaKalder
Copy link
Copy Markdown
Owner

Summary

  • Extracted populateEditorFields(template) helper in options/options.js (after the module-level variable declarations), handling both a template object and null for blank forms
  • openEditor (when editing an existing template) now calls populateEditorFields(template) instead of duplicating 20+ lines of form-setup code
  • duplicateTemplate now calls populateEditorFields(template) then overrides nameInput.value with the i18n-prefixed duplicate name (the only intentional difference between the two callers)
  • Removed the now-redundant pendingAttachments pre-assignment in duplicateTemplate (the helper sets it)
  • No behavior changes: all 90 previously-passing tests still pass; the 7 pre-existing migrateV0toV1 failures are unrelated to this change

Verification

  • Ran npm test: 90 pass / 7 fail (same 7 pre-existing failures in template-store.test.js::migrateV0toV1, unrelated to options.js)
  • Diff: 37 insertions / 55 deletions — net removal of ~18 lines of duplicated code

Fixes #79

🤖 Generated with Claude Code

…licateTemplate (#79)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

[MEDIUM] openEditor and duplicateTemplate share ~25 lines of identical form-setup code — extract populateEditorFields helper

1 participant