Small UI improvements

This commit is contained in:
Pinga 2024-02-25 17:10:07 +02:00
parent fe0eaf5fdc
commit 9af773eb37
2 changed files with 20 additions and 27 deletions

View file

@ -28,17 +28,18 @@ class SupportController extends Controller
$message = $data['message'] ?? null;
if (!$subject) {
return view($response, 'admin/support/newticket.twig', [
'error' => 'Please enter a subject',
'categories' => $categories,
]);
$this->container->get('flash')->addMessage('error', 'Please enter a subject');
return $response->withHeader('Location', '/support/new')->withStatus(302);
}
if (!$message) {
return view($response, 'admin/support/newticket.twig', [
'error' => 'Please enter a message',
'categories' => $categories,
]);
$this->container->get('flash')->addMessage('error', 'Please enter a message');
return $response->withHeader('Location', '/support/new')->withStatus(302);
}
if (mb_strlen($message, 'UTF-8') > 5000) {
$this->container->get('flash')->addMessage('error', 'The provided message exceeds the 5,000 character limit');
return $response->withHeader('Location', '/support/new')->withStatus(302);
}
try {
@ -82,10 +83,9 @@ class SupportController extends Controller
Mail::send($mailsubject, $message, $from, $to);
} catch (Exception $e) {
$db->rollBack();
return view($response, 'admin/support/newticket.twig', [
'error' => $e->getMessage(),
'categories' => $categories
]);
$this->container->get('flash')->addMessage('error', 'Database error: ' . $e->getMessage());
return $response->withHeader('Location', '/support/new')->withStatus(302);
}
$this->container->get('flash')->addMessage('success', 'Support ticket ' . $subject . ' has been created successfully!');
@ -167,6 +167,11 @@ class SupportController extends Controller
}
$responseText = $data['responseText'] ?? null;
if (mb_strlen($responseText, 'UTF-8') > 5000) {
$this->container->get('flash')->addMessage('error', 'The provided message exceeds the 5,000 character limit');
return $response->withHeader('Location', '/ticket/'.$ticket_id)->withStatus(302);
}
$result = $db->selectRow('SELECT registrar_id FROM registrar_users WHERE user_id = ?', [$_SESSION['auth_user_id']]);
$clid = $_SESSION["auth_roles"] != 0 ? $result['registrar_id'] : $_SESSION['auth_user_id'];
$ticket_owner = $db->selectValue('SELECT user_id FROM support_tickets WHERE id = ?', [$ticket_id]);

View file

@ -24,19 +24,7 @@
<div class="page-body">
<div class="container-xl">
<div class="col-12">
{% if error is defined %}
<div class="alert alert-important alert-danger alert-dismissible" role="alert">
<div class="d-flex">
<div>
<svg xmlns="http://www.w3.org/2000/svg" class="icon" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"><path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M3 12a9 9 0 1 0 18 0a9 9 0 0 0 -18 0" /><path d="M12 8v4" /><path d="M12 16h.01" /></svg>
</div>
<div>
&nbsp;{{ __('Support ticket can not be created') }}: <strong>{{ error }}</strong>
</div>
</div>
<a class="btn-close" data-bs-dismiss="alert" aria-label="close"></a>
</div>
{% endif %}
{% include 'partials/flash.twig' %}
<div class="card">
<div class="card-body">
<form action="/support/new" method="post">