Enhance ticket reply button

- Better logic on when the button should default to private/public
- Fix the new plane icon not showing when the button was checked/unchecked
This commit is contained in:
Marcus Hill 2024-02-12 18:10:37 +00:00
parent ddb8061404
commit 25d242dc86
2 changed files with 25 additions and 12 deletions

View File

@ -10,7 +10,7 @@ let respond = document.getElementById('ticket_add_reply');
checkbox.addEventListener('change', e => { checkbox.addEventListener('change', e => {
if (e.target.checked) { if (e.target.checked) {
// Public reply // Public reply
respond.innerHTML = "<i class=\"fas fa-check mr-2\"></i>Respond"; respond.innerHTML = "<i class=\"fas fa-paper-plane mr-2\"></i>Respond";
} else { } else {
// Internal note // Internal note

View File

@ -388,22 +388,35 @@ if (isset($_GET['ticket_id'])) {
</div> </div>
<div class="form-row"> <div class="form-row">
<?php
// Set the initial ticket response type (private/internal note)
// Future updates of the wording/icon are done by Javascript
// Public responses by default (maybe configurable in future?)
$ticket_reply_button_wording = "Respond";
$ticket_reply_button_check = "checked";
$ticket_reply_button_icon = "paper-plane";
// Internal responses by default if 1) the contact email is empty or 2) the contact email matches the agent responding
if (empty($contact_email) || $contact_email == $session_email) {
// Internal
$ticket_reply_button_wording = "Add note";
$ticket_reply_button_check = "";
$ticket_reply_button_icon = "sticky-note";
} ?>
<?php if (!empty($contact_email && $contact_email !== $session_email)) { ?>
<div class="col-md-2"> <div class="col-md-2">
<div class="form-group"> <div class="form-group">
<div class="custom-control custom-checkbox"> <div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="ticket_reply_type_checkbox" name="public_reply_type" value="1" checked> <input type="checkbox" class="custom-control-input" id="ticket_reply_type_checkbox" name="public_reply_type" value="1" <?php echo $ticket_reply_button_check ?>>
<label class="custom-control-label" for="ticket_reply_type_checkbox">Email contact<br><small class="text-secondary">(Public Update)</small></label> <label class="custom-control-label" for="ticket_reply_type_checkbox">Public Update<br><small class="text-secondary">(Emails contact)</small></label>
</div> </div>
</div> </div>
</div> </div>
<?php } ?>
<div class="col-md-2"> <div class="col-md-2">
<button type="submit" id="ticket_add_reply" name="add_ticket_reply" class="btn btn-primary text-bold"><i class="fas fa-paper-plane mr-2"></i>Respond</button> <button type="submit" id="ticket_add_reply" name="add_ticket_reply" class="btn btn-primary text-bold"><i class="fas fa-<?php echo $ticket_reply_button_icon ?> mr-2"></i><?php echo $ticket_reply_button_wording ?></button>
</div> </div>
</div> </div>