fix(report): align the report modal with the reference theme 1:1

- read preset reasons from the real source (ban_preset_reason via
  UserRuntime::ban_settings); the previous injection read a
  nonexistent report.categories key, so backend reasons never showed
- rebuild the modal on the reference markup contract: edit-header
  warning header, reason chips toggling the reference .active class
  (focus color), other-reason textarea, violation link, description,
  but-average modal-buts footer
- add image evidence upload gated by user_report_img_s: new
  /report/upload-image route reusing the comment upload handler with
  its own permission, preview/remove UI, up to 3 images appended to
  the report content
- render the backend report notice (user_report_desc, sanitized HTML)
  inside the modal
- widen the dialog to the reference 600px desktop geometry and share
  the form-upload preview styles with the order review modal
- extend the report contract test accordingly
This commit is contained in:
2026-09-20 14:20:09 +08:00
parent 913958820c
commit 7a80297a56
7 changed files with 329 additions and 91 deletions
@@ -169,6 +169,34 @@ test('native ban page mirrors the reference theme layout', () => {
assert.ok(!tickets.includes('name="action_taken"'), 'report process form should be status-only like the reference theme')
})
test('report modal mirrors the reference theme: preset reasons, image evidence, notice, geometry', () => {
const scripts = read('src/Core/ScriptsPart1c.php')
// 预置原因真实数据源是 ban_preset_reason(UserRuntime::ban_settings),
// 不再读取 report_settings 中不存在的 categories 键(短路已修)。
assert.match(scripts, /UserRuntime::ban_settings\(\)\['reasons'\]/)
assert.ok(!scripts.includes("$report['categories']"), 'dead report.categories source must be removed')
// 图片举证开关与举报说明随 aksrtData 注入。
assert.match(scripts, /imgEnabled/)
assert.match(scripts, /report_settings\(\)/)
const reportJs = read('assets/js/report.js')
// Zibll 同构标记:edit-header 警示头、原因徽章 active 焦点色、其它原因、
// 图片举证入口(后台开启时)、举报说明注入、but-average modal-buts 底栏。
for (const part of ['edit-header', 'toggle-radius mr10 c-red', 'data-aksrt-report-reason', 'form-but-radio', '其它原因', '违规链接', '详细描述', '添加图片举证', 'but-average modal-buts']) {
assert.ok(reportJs.includes(part), `report.js missing reference-theme part: ${part}`)
}
assert.match(reportJs, /report\/upload-image/)
assert.ok(!reportJs.includes('is-active'), 'chips must toggle the reference .active class, not a custom one')
// 举报图片上传端点存在,复用评论上传回调、独立权限(登录 + 举报 + 图片开关)。
assert.match(userController, /'\/report\/upload-image'/)
// 几何 1:1:桌面端 600px(参考主题 Bootstrap 默认模态宽)。
const css = read('assets/css/frontend/modal-runtime.css')
assert.match(css, /\.aksrt-report-modal:not\(\.aksrt-modal-runtime--bottom\) \.aksrt-modal-runtime__dialog/)
assert.match(css, /600px/)
})
test('comments expose a report entry for other users when reporting is enabled', () => {
// 举报位于“回复”右侧三点下拉菜单内(参考主题同位置),载荷走 wp_json_encode。
assert.match(commentItem, /data-aksrt-report="/)