Skip to content

fix(ui): replace dept add/edit prompt with in-app modal - #35

Merged
argszero merged 1 commit into
mainfrom
feat/ui-dept-modal
Aug 17, 2026
Merged

argszero merged 1 commit into
mainfrom
feat/ui-dept-modal

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fix the unresponsive "添加部门" (Add department) button by replacing window.prompt with an in-app form modal. The host reported the button appeared to do nothing — window.prompt can be blocked in some environments (old cached page / iframe / focus loss), which reads as "no response". The new modal (same dark styling as topup/raise modals) guarantees a visible, reliable interaction.

Rant reference

Host instruction (rant 2026-08-17T10:59:47, 修复"添加部门"按钮交互 — 改用表单弹层替代 prompt):

宿主反馈:组织管理页"添加部门"按钮点击目前没有响应。代码层面 add-dept-btn 已绑定 addDept()(用 window.prompt 输入部门名与月分配),但宿主实际点击无响应——可能原因:浏览器加载了旧缓存页面 / prompt 在部分环境被拦截(iframe/无焦点)导致观感"无响应"。

Changes

  • ui/index.html: new #dept-modal (modal-overlay / modal / modal-head / form / modal-actions, matching topup-modal / raise-modal); fields: 部门名称 + 每月点数分配(正整数)
  • ui/js/app.js:
    • openDeptModal(i) — opens modal; i == null = add (title 添加部门), index = edit (title 编辑部门, prefilled current values)
    • confirmDept() — validates name (non-empty, no duplicate) + quota (positive integer), then adds/updates D.DEPARTMENTS (member dept rename linkage kept for edits), refreshes, closes
    • removed addDept() / editDept() / promptPositiveInt() (prompt-based); delete keeps window.confirm
    • bindings: #add-dept-btn → openDeptModal(null), #dept-confirm → confirmDept; dept-modal added to overlay-click-close list; ✕ close works via the generic data-modal-close handler
  • ui/README.md: org section notes modal-based add/edit

Verification

  • No window.prompt left in the org pane (promptPositiveInt / addDept / editDept removed; remaining prompts are API-key rename / operator topup, unrelated)
  • node --check ui/js/app.js passes
  • cargo test passes (1 passed)
  • cargo fmt --check passes

The "添加部门" button showed no response for the host — it relied on
window.prompt, which can be blocked (old cached page / iframe / focus)
making the click feel dead. Replace it with an in-app form modal
(dept-modal, same styling as topup/raise modals): name + monthly quota
(positive integer validation), confirm adds/updates and refreshes,
cancel closes. Edit department uses the same modal prefilled with
current values. Delete keeps its confirm. Overlay click and ✕ close
the modal; no window.prompt remains in the org pane.

Refs: rant 2026-08-17T10:59:47 (修复"添加部门"按钮交互 — 改用表单弹层)
@argszero
argszero merged commit 585b454 into main Aug 17, 2026
1 check passed
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