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
+14
View File
@@ -57,6 +57,20 @@ class UserController extends ControllerBase {
'permission_callback' => [$this, 'check_comment_image_upload_permission'],
]);
// Report evidence image upload (logged-in users; the report image setting gates the entry).
// Reuses the comment upload handler — the permission boundary differs only.
register_rest_route(self::API_NAMESPACE, '/report/upload-image', [
'methods' => 'POST',
'callback' => [$this, 'rest_upload_comment_image'],
'permission_callback' => static function (): bool {
if (!is_user_logged_in() || !class_exists('\AKSRT\Settings\UserRuntime')) {
return false;
}
$report = \AKSRT\Settings\UserRuntime::report_settings();
return !empty($report['enabled']) && !empty($report['img_enabled']);
},
]);
// Notification settings
register_rest_route(self::API_NAMESPACE, '/settings/notifications', [
'methods' => ['GET', 'POST'],