Expanded the Redact tool into ticket details area, generalized it to allow redaction in other areas as well
This commit is contained in:
54
ajax/ajax_ticket_reply_redact.php
Normal file
54
ajax/ajax_ticket_reply_redact.php
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once '../includes/ajax_header.php';
|
||||||
|
|
||||||
|
$ticket_reply_id = intval($_GET['id']);
|
||||||
|
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM ticket_replies
|
||||||
|
LEFT JOIN tickets ON ticket_id = ticket_reply_ticket_id
|
||||||
|
WHERE ticket_reply_id = $ticket_reply_id
|
||||||
|
LIMIT 1"
|
||||||
|
);
|
||||||
|
|
||||||
|
$row = mysqli_fetch_array($sql);
|
||||||
|
$ticket_reply_type = nullable_htmlentities($row['ticket_reply_type']);
|
||||||
|
$ticket_reply_time_worked = date_create($row['ticket_reply_time_worked']);
|
||||||
|
$ticket_reply_time_worked_formatted = date_format($ticket_reply_time_worked, 'H:i:s');
|
||||||
|
$ticket_reply = nullable_htmlentities($row['ticket_reply']);
|
||||||
|
$client_id = intval($row['ticket_client_id']);
|
||||||
|
|
||||||
|
// Generate the HTML form content using output buffering.
|
||||||
|
ob_start();
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title"><i class="fa fa-fw fa-edit mr-2"></i>Redacting Ticket Reply</h5>
|
||||||
|
<button type="button" class="close text-white" data-dismiss="modal">
|
||||||
|
<span>×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<form action="post.php" method="post" autocomplete="off">
|
||||||
|
<input type="hidden" name="ticket_reply_id" value="<?php echo $ticket_reply_id; ?>">
|
||||||
|
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||||
|
<input type="hidden" name="ticket_reply_type" value="<?php echo $ticket_reply_type; ?>">
|
||||||
|
<?php if (!empty($ticket_reply_time_worked)) { ?>
|
||||||
|
<input type="hidden" name="time" value="<?php echo $ticket_reply_time_worked_formatted; ?>">
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<div class="modal-body bg-white">
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<textarea class="form-control tinymceRedact" name="ticket_reply"><?php echo $ticket_reply; ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer bg-white">
|
||||||
|
<button type="submit" name="edit_ticket_reply" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
|
||||||
|
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once "../includes/ajax_footer.php";
|
||||||
59
js/app.js
59
js/app.js
@@ -166,7 +166,7 @@ tinymce.init({
|
|||||||
{ name: 'link', items: [ 'link'] },
|
{ name: 'link', items: [ 'link'] },
|
||||||
{ name: 'lists', items: [ 'bullist', 'numlist' ] },
|
{ name: 'lists', items: [ 'bullist', 'numlist' ] },
|
||||||
{ name: 'indentation', items: [ 'outdent', 'indent' ] },
|
{ name: 'indentation', items: [ 'outdent', 'indent' ] },
|
||||||
{ name: 'custom', items: ['myRedactButton'] } // Add custom button to toolbar
|
{ name: 'custom', items: ['redactButton'] } // Add custom button to toolbar
|
||||||
],
|
],
|
||||||
mobile: {
|
mobile: {
|
||||||
menubar: false,
|
menubar: false,
|
||||||
@@ -178,7 +178,7 @@ tinymce.init({
|
|||||||
license_key: 'gpl',
|
license_key: 'gpl',
|
||||||
setup: function(editor) {
|
setup: function(editor) {
|
||||||
// Add custom toolbar button with Font Awesome icon
|
// Add custom toolbar button with Font Awesome icon
|
||||||
editor.ui.registry.addButton('myRedactButton', {
|
editor.ui.registry.addButton('redactButton', {
|
||||||
icon: 'permanent-pen',
|
icon: 'permanent-pen',
|
||||||
tooltip: 'Redact', // Tooltip text for the button
|
tooltip: 'Redact', // Tooltip text for the button
|
||||||
onAction: function() {
|
onAction: function() {
|
||||||
@@ -217,7 +217,7 @@ tinymce.init({
|
|||||||
{ name: 'lists', items: ['bullist', 'numlist'] },
|
{ name: 'lists', items: ['bullist', 'numlist'] },
|
||||||
{ name: 'indentation', items: ['outdent', 'indent'] },
|
{ name: 'indentation', items: ['outdent', 'indent'] },
|
||||||
{ name: 'ai', items: ['reword', 'undo', 'redo'] },
|
{ name: 'ai', items: ['reword', 'undo', 'redo'] },
|
||||||
{ name: 'custom', items: ['myRedactButton'] } // Add custom redact button to toolbar
|
{ name: 'custom', items: ['redactButton'] } // Add custom redact button to toolbar
|
||||||
],
|
],
|
||||||
mobile: {
|
mobile: {
|
||||||
menubar: false,
|
menubar: false,
|
||||||
@@ -299,7 +299,7 @@ tinymce.init({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add the Redact button
|
// Add the Redact button
|
||||||
editor.ui.registry.addButton('myRedactButton', {
|
editor.ui.registry.addButton('redactButton', {
|
||||||
icon: 'permanent-pen',
|
icon: 'permanent-pen',
|
||||||
tooltip: 'Redact Text', // Tooltip text for the button
|
tooltip: 'Redact Text', // Tooltip text for the button
|
||||||
onAction: function() {
|
onAction: function() {
|
||||||
@@ -336,6 +336,57 @@ tinymce.init({
|
|||||||
toolbar: '',
|
toolbar: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tinymce.init({
|
||||||
|
selector: '.tinymceRedact', // Your selector
|
||||||
|
browser_spellcheck: true,
|
||||||
|
contextmenu: false,
|
||||||
|
resize: true,
|
||||||
|
min_height: 300,
|
||||||
|
max_height: 600,
|
||||||
|
promotion: false,
|
||||||
|
branding: false,
|
||||||
|
menubar: false,
|
||||||
|
statusbar: false,
|
||||||
|
toolbar: 'redactButton', // Only the redact button in the toolbar
|
||||||
|
mobile: {
|
||||||
|
menubar: false,
|
||||||
|
plugins: 'autosave lists autolink',
|
||||||
|
toolbar: 'redactButton' // Only the redact button on mobile
|
||||||
|
},
|
||||||
|
convert_urls: false,
|
||||||
|
plugins: 'link image lists table code fullscreen autoresize',
|
||||||
|
license_key: 'gpl',
|
||||||
|
setup: function(editor) {
|
||||||
|
// Disable all text input and backspace/delete actions
|
||||||
|
editor.on('keydown', function(e) {
|
||||||
|
// Prevent all key events (including backspace and delete)
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Add custom toolbar button with Font Awesome icon and label
|
||||||
|
editor.ui.registry.addButton('redactButton', {
|
||||||
|
icon: 'permanent-pen',
|
||||||
|
tooltip: 'Redact', // Tooltip text for the button
|
||||||
|
text: 'REDACT', // Add the text next to the icon
|
||||||
|
onAction: function() {
|
||||||
|
var selectedText = editor.selection.getContent({ format: 'text' });
|
||||||
|
|
||||||
|
if (selectedText) {
|
||||||
|
// Replace the selected text with [REDACTED] in bold red
|
||||||
|
var newContent = '<span style="font-weight: bold; color: red;">[REDACTED]</span>';
|
||||||
|
|
||||||
|
// Replace selected content with the new content
|
||||||
|
editor.selection.setContent(newContent);
|
||||||
|
} else {
|
||||||
|
alert('Please select a word to redact');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// DateTime
|
// DateTime
|
||||||
$('.datetimepicker').datetimepicker({
|
$('.datetimepicker').datetimepicker({
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ if (isset($_GET['ai_reword'])) {
|
|||||||
$inputJSON = file_get_contents('php://input');
|
$inputJSON = file_get_contents('php://input');
|
||||||
$input = json_decode($inputJSON, TRUE); // Convert JSON into array.
|
$input = json_decode($inputJSON, TRUE); // Convert JSON into array.
|
||||||
|
|
||||||
$promptText = "reword with html format";
|
$promptText = "reword";
|
||||||
$userText = $input['text'];
|
$userText = $input['text'];
|
||||||
|
|
||||||
// Preparing the data for the OpenAI Chat API request.
|
// Preparing the data for the OpenAI Chat API request.
|
||||||
|
|||||||
56
ticket.php
56
ticket.php
@@ -792,30 +792,40 @@ if (isset($_GET['ticket_id'])) {
|
|||||||
|
|
||||||
<!-- Right-side content -->
|
<!-- Right-side content -->
|
||||||
<div class="text-right d-flex flex-column align-items-end">
|
<div class="text-right d-flex flex-column align-items-end">
|
||||||
<?php if ($ticket_reply_type !== "Client" && empty($ticket_closed_at)) { ?>
|
<div class="card-tools d-print-none mb-2">
|
||||||
<div class="card-tools d-print-none mb-2">
|
<div class="dropdown dropleft">
|
||||||
<div class="dropdown dropleft">
|
<?php if (lookupUserPermission("module_support") >= 2) { ?>
|
||||||
<?php if (lookupUserPermission("module_support") >= 2) { ?>
|
<button class="btn btn-sm btn-tool" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||||
<button class="btn btn-sm btn-tool" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
<i class="fas fa-fw fa-ellipsis-v"></i>
|
||||||
<i class="fas fa-fw fa-ellipsis-v"></i>
|
</button>
|
||||||
</button>
|
<div class="dropdown-menu">
|
||||||
<div class="dropdown-menu">
|
<a href="#" class="dropdown-item"
|
||||||
<a class="dropdown-item"
|
data-toggle = "ajax-modal"
|
||||||
data-toggle = "ajax-modal"
|
data-modal-size = "lg"
|
||||||
data-modal-size = "lg"
|
data-ajax-url = "ajax/ajax_ticket_reply_redact.php"
|
||||||
data-ajax-url = "ajax/ajax_ticket_reply_edit.php"
|
data-ajax-id = "<?php echo $ticket_reply_id; ?>"
|
||||||
data-ajax-id = "<?php echo $ticket_reply_id; ?>"
|
>
|
||||||
>
|
<i class="fas fa-fw fa-pen text-danger mr-2"></i>Redact
|
||||||
<i class="fas fa-fw fa-edit text-secondary mr-2"></i>Edit
|
</a>
|
||||||
</a>
|
<?php if ($ticket_reply_type !== "Client" && empty($ticket_closed_at)) { ?>
|
||||||
<div class="dropdown-divider"></div>
|
<div class="dropdown-divider"></div>
|
||||||
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_ticket_reply=<?php echo $ticket_reply_id; ?>">
|
<a href="#" class="dropdown-item"
|
||||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
data-toggle = "ajax-modal"
|
||||||
</a>
|
data-modal-size = "lg"
|
||||||
</div>
|
data-ajax-url = "ajax/ajax_ticket_reply_edit.php"
|
||||||
<?php } ?>
|
data-ajax-id = "<?php echo $ticket_reply_id; ?>"
|
||||||
</div>
|
>
|
||||||
|
<i class="fas fa-fw fa-edit text-secondary mr-2"></i>Edit
|
||||||
|
</a>
|
||||||
|
<div class="dropdown-divider"></div>
|
||||||
|
<a class="dropdown-item text-danger confirm-link" href="post.php?archive_ticket_reply=<?php echo $ticket_reply_id; ?>">
|
||||||
|
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||||
|
</a>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
|
|||||||
Reference in New Issue
Block a user